From 4f34ea4f933b3a7870e5ebfdbf255d1e1f1b514e Mon Sep 17 00:00:00 2001 From: Vincent Siveton Date: Wed, 3 Aug 2005 13:11:10 +0000 Subject: [PATCH] Rolling back to still allow exception on duplicate files and some small improvements. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@227216 13f79535-47bb-0310-9956-ffa450edef68 --- maven-plugins/maven-site-plugin/pom.xml | 4 -- .../org/apache/maven/doxia/DoxiaMojo.java | 72 +++++++++++++------ 2 files changed, 50 insertions(+), 26 deletions(-) diff --git a/maven-plugins/maven-site-plugin/pom.xml b/maven-plugins/maven-site-plugin/pom.xml index 3396d5647e..15080f7576 100644 --- a/maven-plugins/maven-site-plugin/pom.xml +++ b/maven-plugins/maven-site-plugin/pom.xml @@ -61,10 +61,6 @@ wagon-ssh 1.0-alpha-4 - - plexus - plexus-utils - diff --git a/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java b/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java index f6fe33f218..228b2b944e 100644 --- a/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java +++ b/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/doxia/DoxiaMojo.java @@ -257,9 +257,10 @@ public class DoxiaMojo } } + Locale locale; for ( Iterator iterator = localesList.iterator(); iterator.hasNext(); ) { - Locale locale = (Locale) iterator.next(); + locale = (Locale) iterator.next(); File localeOutputDirectory = getOuputDirectory( locale ); @@ -272,9 +273,10 @@ public class DoxiaMojo //Generate reports if ( reports != null ) { + MavenReport report; for ( Iterator j = reports.iterator(); j.hasNext(); ) { - MavenReport report = (MavenReport) j.next(); + report = (MavenReport) j.next(); getLog().info( "Generate \"" + report.getName( locale ) + "\" report." ); @@ -365,10 +367,10 @@ public class DoxiaMojo if ( duplicate.size() > 0 ) { StringBuffer sb = null; - + Map.Entry entry; for ( Iterator it = duplicate.entrySet().iterator(); it.hasNext(); ) { - Map.Entry entry = (Map.Entry) it.next(); + entry = (Map.Entry) it.next(); Set values = (Set) entry.getValue(); if ( values.size() > 1 ) @@ -614,6 +616,11 @@ subprojects... /** * @todo should only be needed once + * + * @param reports a list of reports + * @param locale the current locale + * @return the inpustream + * @throws MojoExecutionException is any */ private InputStream getSiteDescriptor( List reports, Locale locale ) throws MojoExecutionException @@ -663,7 +670,8 @@ subprojects... { if ( project.getModules() != null && project.getModules().size() > 0 ) { - props.put( "modules", getModulesMenu( locale ) ); + /* See the Not working section, around line 460*/ + //props.put( "modules", getModulesMenu( locale ) ); } } @@ -1003,9 +1011,10 @@ subprojects... List reports = new ArrayList(); if ( reportPlugins != null ) { + ReportPlugin reportPlugin; for ( Iterator it = reportPlugins.iterator(); it.hasNext(); ) { - ReportPlugin reportPlugin = (ReportPlugin) it.next(); + reportPlugin = (ReportPlugin) it.next(); try { @@ -1020,9 +1029,10 @@ subprojects... } else { + ReportSet reportSet; for ( Iterator j = reportSets.iterator(); j.hasNext(); ) { - ReportSet reportSet = (ReportSet) j.next(); + reportSet = (ReportSet) j.next(); reportsList = pluginManager.getReports( reportPlugin, reportSet, project, session ); } @@ -1052,8 +1062,8 @@ subprojects... } /** - * Convenience method that try to find duplicate files in a given directory. - *

The scan is case unsensitive.

+ * Convenience method that try to find duplicate files in sub-directories of a given directory. + *

The scan is case sensitive.

* * @param directory the directory to scan * @param duplicate the map to update @@ -1063,33 +1073,51 @@ subprojects... throws IOException { 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(); + + List siteFileNames = FileUtils.getFileNames( directory, null, defaultExcludes, false ); - if ( currentFile.lastIndexOf( File.separator ) == -1 ) + String currentFileName; + for ( Iterator it = siteFileNames.iterator(); it.hasNext(); ) + { + currentFileName = (String) it.next(); + + if ( currentFileName.lastIndexOf( File.separator ) == -1 ) { // ignore files directly in the directory continue; } - if ( currentFile.lastIndexOf( "." ) == -1 ) + if ( currentFileName.lastIndexOf( "." ) == -1 ) { // ignore files without extension continue; } - String key = currentFile.substring( currentFile.indexOf( File.separator ) + 1, - currentFile.lastIndexOf( "." ) ); + String key = currentFileName.substring( currentFileName.indexOf( File.separator ) + 1, + currentFileName.lastIndexOf( "." ) ); - Set tmp = (Set) duplicate.get( key.toLowerCase() ); - if ( tmp == null ) + String filePattern = "**/" + key + ".*"; + + List duplicateFileNames = FileUtils.getFileNames( directory, filePattern, defaultExcludes, false ); + Set duplicatedFileNamesSet = (Set) duplicate.get( key.toLowerCase() ); + if ( duplicatedFileNamesSet == null ) { - tmp = new HashSet(); - duplicate.put( key.toLowerCase(), tmp ); + duplicatedFileNamesSet = new HashSet(); } - tmp.add( key ); + + String tmp; + for ( Iterator it2 = duplicateFileNames.iterator(); it2.hasNext(); ) + { + tmp = (String) it2.next(); + if ( tmp.lastIndexOf( File.separator ) == -1 ) + { + // ignore files directly in the directory + continue; + } + + duplicatedFileNamesSet.add( directory.getAbsolutePath() + File.separator + tmp ); + } + duplicate.put( key.toLowerCase(), duplicatedFileNamesSet ); } } }