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,15 +75,12 @@ public class DoxiaMojo
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",
"dependencies",
"issue-tracking",
"license",
"mail-lists",
"source-repository",
"team-list" };
/**
* OutputName of all project info report files generated by Maven
*/
private static final String[] PROJECT_INFO_FILES = new String[]{"integration", "dependencies", "issue-tracking",
"license", "mail-lists", "source-repository", "team-list"};
/**
* Patterns which should be excluded by default.
*/
@ -153,10 +150,10 @@ public class DoxiaMojo
/**
* @parameter expression="${addModules}"
* default-value="true"
* default-value="true"
*/
private boolean addModules;
/**
* @parameter expression="${component.org.codehaus.plexus.siterenderer.Renderer}"
* @required
@ -239,7 +236,7 @@ public class DoxiaMojo
{
attributes.put( "project", project );
}
try
{
categorizeReports( reports );
@ -362,8 +359,8 @@ public class DoxiaMojo
tryToFindDuplicates( generatedSiteFile, duplicate );
}
// Exception if a file is duplicate
if ( ( duplicate.entrySet() != null ) && ( duplicate.entrySet().size() > 0 ) )
// Exception if a file is duplicate
if ( duplicate.size() > 0 )
{
StringBuffer sb = null;
@ -376,8 +373,9 @@ public class DoxiaMojo
{
if ( sb == null )
{
sb = new StringBuffer( "Some files are duplicates in the site directory or in the generated-site directory. "
+ "Review the following files:" );
sb = new StringBuffer(
"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" );
@ -411,8 +409,8 @@ public class DoxiaMojo
generateIndexPage( getSiteDescriptor( reports, locale ), locale );
}
// Log if a user override a project info report file
for ( int i = 0; i < PROJECT_INFO_FILES.length; i++)
// Log if a user override a project info report file
for ( int i = 0; i < PROJECT_INFO_FILES.length; i++ )
{
if ( projectInfos.size() > 0 )
{
@ -422,7 +420,7 @@ public class DoxiaMojo
}
}
}
siteRenderer.render( siteDirectoryFile, localeOutputDirectory, getSiteDescriptor( reports, locale ),
template, attributes, locale );
@ -457,14 +455,15 @@ public class DoxiaMojo
if ( parentProject != null )
{
// TODO Handle user plugin configuration
File parentSiteDir = new File( parentProject.getBasedir(), parentProject.getBuild().getDirectory()
+ File.separator + "site" + File.separator + project.getArtifactId() );
File parentSiteDir = new File( parentProject.getBasedir(),
parentProject.getBuild().getDirectory() + File.separator +
"site" + File.separator + project.getArtifactId() );
if ( !parentSiteDir.exists() )
{
parentSiteDir.mkdirs();
}
File siteDir = new File( outputDirectory );
FileUtils.copyDirectoryStructure( siteDir, parentSiteDir );
}
@ -527,7 +526,8 @@ public class DoxiaMojo
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 )
{
@ -553,7 +553,7 @@ public class DoxiaMojo
/**
* Generate a menu for modules
*
*
* @param locale the locale wanted
* @return a XML menu for modules
*/
@ -567,16 +567,18 @@ public class DoxiaMojo
List modules = project.getModules();
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( module );
buffer.append( "\" href=\"" + module + "/index.html\"/>\n" );
buffer.append( "\" href=\"" );
buffer.append( module );
buffer.append( "/index.html\"/>\n" );
}
}
buffer.append( "</menu>\n" );
return buffer.toString();
@ -584,7 +586,7 @@ public class DoxiaMojo
/**
* Generate a menu for the parent project
*
*
* @param locale the locale wanted
* @return a XML menu for the parent project
*/
@ -594,16 +596,16 @@ public class DoxiaMojo
buffer.append( "<menu name=\"" );
buffer.append( i18n.getString( "site-plugin", locale, "report.menu.parentproject" ) );
buffer.append( "\">\n" );
buffer.append( " <item name=\"" );
buffer.append( project.getParent().getArtifactId() );
buffer.append( "\" href=\"../index.html\"/>\n" );
buffer.append( "</menu>\n" );
return buffer.toString();
}
/**
* @todo should only be needed once
*/
@ -650,10 +652,10 @@ public class DoxiaMojo
{
props.put( "parentProject", getProjectParentMenu( locale ) );
}
if ( addModules )
{
if ( ( project.getModules() != null ) && ( project.getModules().size() > 0 ) )
if ( project.getModules() != null && project.getModules().size() > 0 )
{
props.put( "modules", getModulesMenu( locale ) );
}
@ -1042,15 +1044,15 @@ public class DoxiaMojo
}
return reports;
}
/**
* Convenience method that try to find duplicate files in a given directory.
* Convenience method that try to find duplicate files in a given directory.
* <p>The scan is case unsensitive.</p>
*
*
* @param directory the directory to scan
* @param duplicate the map to update
* @throws IOException if any
**/
*/
private static void tryToFindDuplicates( File directory, Map duplicate )
throws IOException
{
@ -1058,23 +1060,16 @@ public class DoxiaMojo
{
duplicate = new HashMap();
}
// The pattern as comma separated
StringBuffer excludePattern = new StringBuffer();
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 );
String defaultExcludes = StringUtils.join( DEFAULT_EXCLUDES, "," );
List siteFiles = FileUtils.getFileNames( directory, null, defaultExcludes, false );
for ( Iterator it = siteFiles.iterator(); it.hasNext(); )
{
String currentFile = ( (String) it.next() );
String currentFile = (String) it.next();
if ( currentFile.lastIndexOf( File.separator ) == -1 )
{
// ignore files directly in the directory
// ignore files directly in the directory
continue;
}
@ -1084,13 +1079,13 @@ public class DoxiaMojo
continue;
}
String key = currentFile.substring( currentFile.indexOf( File.separator ) + 1,
String key = currentFile.substring( currentFile.indexOf( File.separator ) + 1,
currentFile.lastIndexOf( "." ) );
String filePattern = "**/" + key + ".*";
List files = FileUtils.getFileNames( directory, filePattern, excludePattern.toString(), true );
if ( ( files != null ) && ( files.size() > 0 ) )
List files = FileUtils.getFileNames( directory, filePattern, defaultExcludes, true );
if ( files != null && files.size() > 0 )
{
List tmp = (List) duplicate.get( key.toLowerCase() );
if ( tmp == null )