clean up code a little before attempting a bugfix

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@226476 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-07-30 05:59:30 +00:00
parent 3f2362e528
commit 475b0eb767
1 changed files with 49 additions and 54 deletions

View File

@ -75,14 +75,11 @@ public class DoxiaMojo
private static final String DEFAULT_TEMPLATE = RESOURCE_DIR + "/maven-site.vm"; private static final String DEFAULT_TEMPLATE = RESOURCE_DIR + "/maven-site.vm";
/** OutputName of all project info report files generated by Maven */ /**
private static final String[] PROJECT_INFO_FILES = new String[] { "integration", * OutputName of all project info report files generated by Maven
"dependencies", */
"issue-tracking", private static final String[] PROJECT_INFO_FILES = new String[]{"integration", "dependencies", "issue-tracking",
"license", "license", "mail-lists", "source-repository", "team-list"};
"mail-lists",
"source-repository",
"team-list" };
/** /**
* Patterns which should be excluded by default. * Patterns which should be excluded by default.
@ -363,7 +360,7 @@ public class DoxiaMojo
} }
// Exception if a file is duplicate // Exception if a file is duplicate
if ( ( duplicate.entrySet() != null ) && ( duplicate.entrySet().size() > 0 ) ) if ( duplicate.size() > 0 )
{ {
StringBuffer sb = null; StringBuffer sb = null;
@ -376,8 +373,9 @@ public class DoxiaMojo
{ {
if ( sb == null ) if ( sb == null )
{ {
sb = new StringBuffer( "Some files are duplicates in the site directory or in the generated-site directory. " sb = new StringBuffer(
+ "Review the following files:" ); "Some files are duplicates in the site directory or in the generated-site directory. " +
"Review the following files:" );
} }
sb.append( "\n" ).append( entry.getKey() ).append( "\n" ); sb.append( "\n" ).append( entry.getKey() ).append( "\n" );
@ -412,7 +410,7 @@ public class DoxiaMojo
} }
// Log if a user override a project info report file // Log if a user override a project info report file
for ( int i = 0; i < PROJECT_INFO_FILES.length; i++) for ( int i = 0; i < PROJECT_INFO_FILES.length; i++ )
{ {
if ( projectInfos.size() > 0 ) if ( projectInfos.size() > 0 )
{ {
@ -457,8 +455,9 @@ public class DoxiaMojo
if ( parentProject != null ) if ( parentProject != null )
{ {
// TODO Handle user plugin configuration // TODO Handle user plugin configuration
File parentSiteDir = new File( parentProject.getBasedir(), parentProject.getBuild().getDirectory() File parentSiteDir = new File( parentProject.getBasedir(),
+ File.separator + "site" + File.separator + project.getArtifactId() ); parentProject.getBuild().getDirectory() + File.separator +
"site" + File.separator + project.getArtifactId() );
if ( !parentSiteDir.exists() ) if ( !parentSiteDir.exists() )
{ {
@ -527,7 +526,8 @@ public class DoxiaMojo
return buffer.toString(); return buffer.toString();
} }
private void writeReportSubMenu( List reports, StringBuffer buffer, Locale locale, String key, String indexFilename ) private void writeReportSubMenu( List reports, StringBuffer buffer, Locale locale, String key,
String indexFilename )
{ {
if ( reports.size() > 0 ) if ( reports.size() > 0 )
{ {
@ -567,13 +567,15 @@ public class DoxiaMojo
List modules = project.getModules(); List modules = project.getModules();
if ( project.getModules() != null ) if ( project.getModules() != null )
{ {
for (Iterator it = modules.iterator(); it.hasNext();) for ( Iterator it = modules.iterator(); it.hasNext(); )
{ {
String module = (String)it.next(); String module = (String) it.next();
buffer.append( " <item name=\"" ); buffer.append( " <item name=\"" );
buffer.append( module ); buffer.append( module );
buffer.append( "\" href=\"" + module + "/index.html\"/>\n" ); buffer.append( "\" href=\"" );
buffer.append( module );
buffer.append( "/index.html\"/>\n" );
} }
} }
@ -653,7 +655,7 @@ public class DoxiaMojo
if ( addModules ) if ( addModules )
{ {
if ( ( project.getModules() != null ) && ( project.getModules().size() > 0 ) ) if ( project.getModules() != null && project.getModules().size() > 0 )
{ {
props.put( "modules", getModulesMenu( locale ) ); props.put( "modules", getModulesMenu( locale ) );
} }
@ -1050,7 +1052,7 @@ public class DoxiaMojo
* @param directory the directory to scan * @param directory the directory to scan
* @param duplicate the map to update * @param duplicate the map to update
* @throws IOException if any * @throws IOException if any
**/ */
private static void tryToFindDuplicates( File directory, Map duplicate ) private static void tryToFindDuplicates( File directory, Map duplicate )
throws IOException throws IOException
{ {
@ -1059,18 +1061,11 @@ public class DoxiaMojo
duplicate = new HashMap(); duplicate = new HashMap();
} }
// The pattern as comma separated String defaultExcludes = StringUtils.join( DEFAULT_EXCLUDES, "," );
StringBuffer excludePattern = new StringBuffer(); List siteFiles = FileUtils.getFileNames( directory, null, defaultExcludes, false );
for ( int i = 0; i < DEFAULT_EXCLUDES.length; i++ )
{
excludePattern.append( DEFAULT_EXCLUDES[i] ).append( "," );
}
excludePattern.deleteCharAt( excludePattern.length() - 1 );
List siteFiles = FileUtils.getFileNames( directory, null, excludePattern.toString(), false );
for ( Iterator it = siteFiles.iterator(); it.hasNext(); ) for ( Iterator it = siteFiles.iterator(); it.hasNext(); )
{ {
String currentFile = ( (String) it.next() ); String currentFile = (String) it.next();
if ( currentFile.lastIndexOf( File.separator ) == -1 ) if ( currentFile.lastIndexOf( File.separator ) == -1 )
{ {
@ -1089,8 +1084,8 @@ public class DoxiaMojo
String filePattern = "**/" + key + ".*"; String filePattern = "**/" + key + ".*";
List files = FileUtils.getFileNames( directory, filePattern, excludePattern.toString(), true ); List files = FileUtils.getFileNames( directory, filePattern, defaultExcludes, true );
if ( ( files != null ) && ( files.size() > 0 ) ) if ( files != null && files.size() > 0 )
{ {
List tmp = (List) duplicate.get( key.toLowerCase() ); List tmp = (List) duplicate.get( key.toLowerCase() );
if ( tmp == null ) if ( tmp == null )