You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2005/07/30 07:59:39 UTC
svn commit: r226476 -
/maven/components/trunk/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java
Author: brett
Date: Fri Jul 29 22:59:30 2005
New Revision: 226476
URL: http://svn.apache.org/viewcvs?rev=226476&view=rev
Log:
clean up code a little before attempting a bugfix
Modified:
maven/components/trunk/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java
Modified: maven/components/trunk/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java?rev=226476&r1=226475&r2=226476&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java Fri Jul 29 22:59:30 2005
@@ -75,15 +75,12 @@
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 @@
/**
* @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 @@
{
attributes.put( "project", project );
}
-
+
try
{
categorizeReports( reports );
@@ -362,8 +359,8 @@
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 @@
{
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 @@
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 @@
}
}
}
-
+
siteRenderer.render( siteDirectoryFile, localeOutputDirectory, getSiteDescriptor( reports, locale ),
template, attributes, locale );
@@ -457,14 +455,15 @@
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 @@
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 @@
/**
* Generate a menu for modules
- *
+ *
* @param locale the locale wanted
* @return a XML menu for modules
*/
@@ -567,16 +567,18 @@
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 @@
/**
* Generate a menu for the parent project
- *
+ *
* @param locale the locale wanted
* @return a XML menu for the parent project
*/
@@ -594,16 +596,16 @@
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 @@
{
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 @@
}
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 @@
{
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 @@
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 )
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org