rollback last set of changes, and fix the bug in the existing revision by storing the filenames in a list rather than the identical keys in a set

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@227282 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-08-04 00:35:39 +00:00
parent 71cb5dc399
commit 0a637acedd
1 changed files with 24 additions and 48 deletions

View File

@ -51,14 +51,13 @@
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer; import java.util.StringTokenizer;
/** /**
@ -257,10 +256,9 @@ public void execute()
} }
} }
Locale locale;
for ( Iterator iterator = localesList.iterator(); iterator.hasNext(); ) for ( Iterator iterator = localesList.iterator(); iterator.hasNext(); )
{ {
locale = (Locale) iterator.next(); Locale locale = (Locale) iterator.next();
File localeOutputDirectory = getOuputDirectory( locale ); File localeOutputDirectory = getOuputDirectory( locale );
@ -273,10 +271,9 @@ public void execute()
//Generate reports //Generate reports
if ( reports != null ) if ( reports != null )
{ {
MavenReport report;
for ( Iterator j = reports.iterator(); j.hasNext(); ) for ( Iterator j = reports.iterator(); j.hasNext(); )
{ {
report = (MavenReport) j.next(); MavenReport report = (MavenReport) j.next();
getLog().info( "Generate \"" + report.getName( locale ) + "\" report." ); getLog().info( "Generate \"" + report.getName( locale ) + "\" report." );
@ -367,11 +364,11 @@ public void execute()
if ( duplicate.size() > 0 ) if ( duplicate.size() > 0 )
{ {
StringBuffer sb = null; StringBuffer sb = null;
Map.Entry entry;
for ( Iterator it = duplicate.entrySet().iterator(); it.hasNext(); ) for ( Iterator it = duplicate.entrySet().iterator(); it.hasNext(); )
{ {
entry = (Map.Entry) it.next(); Map.Entry entry = (Map.Entry) it.next();
Set values = (Set) entry.getValue(); Collection values = (Collection) entry.getValue();
if ( values.size() > 1 ) if ( values.size() > 1 )
{ {
@ -615,12 +612,11 @@ private String getProjectParentMenu( Locale locale )
} }
/** /**
* @todo should only be needed once
*
* @param reports a list of reports * @param reports a list of reports
* @param locale the current locale * @param locale the current locale
* @return the inpustream * @return the inpustream
* @throws MojoExecutionException is any * @throws MojoExecutionException is any
* @todo should only be needed once
*/ */
private InputStream getSiteDescriptor( List reports, Locale locale ) private InputStream getSiteDescriptor( List reports, Locale locale )
throws MojoExecutionException throws MojoExecutionException
@ -1011,10 +1007,9 @@ private List getReports()
List reports = new ArrayList(); List reports = new ArrayList();
if ( reportPlugins != null ) if ( reportPlugins != null )
{ {
ReportPlugin reportPlugin;
for ( Iterator it = reportPlugins.iterator(); it.hasNext(); ) for ( Iterator it = reportPlugins.iterator(); it.hasNext(); )
{ {
reportPlugin = (ReportPlugin) it.next(); ReportPlugin reportPlugin = (ReportPlugin) it.next();
try try
{ {
@ -1029,10 +1024,9 @@ private List getReports()
} }
else else
{ {
ReportSet reportSet;
for ( Iterator j = reportSets.iterator(); j.hasNext(); ) for ( Iterator j = reportSets.iterator(); j.hasNext(); )
{ {
reportSet = (ReportSet) j.next(); ReportSet reportSet = (ReportSet) j.next();
reportsList = pluginManager.getReports( reportPlugin, reportSet, project, session ); reportsList = pluginManager.getReports( reportPlugin, reportSet, project, session );
} }
@ -1073,51 +1067,33 @@ private static void tryToFindDuplicates( File directory, Map duplicate )
throws IOException throws IOException
{ {
String defaultExcludes = StringUtils.join( DEFAULT_EXCLUDES, "," ); String defaultExcludes = StringUtils.join( DEFAULT_EXCLUDES, "," );
List siteFiles = FileUtils.getFileNames( directory, null, defaultExcludes, false );
List siteFileNames = FileUtils.getFileNames( directory, null, defaultExcludes, false ); for ( Iterator it = siteFiles.iterator(); it.hasNext(); )
String currentFileName;
for ( Iterator it = siteFileNames.iterator(); it.hasNext(); )
{ {
currentFileName = (String) it.next(); String currentFile = (String) it.next();
if ( currentFileName.lastIndexOf( File.separator ) == -1 ) if ( currentFile.lastIndexOf( File.separator ) == -1 )
{ {
// ignore files directly in the directory // ignore files directly in the directory
continue; continue;
} }
if ( currentFileName.lastIndexOf( "." ) == -1 ) if ( currentFile.lastIndexOf( "." ) == -1 )
{ {
// ignore files without extension // ignore files without extension
continue; continue;
} }
String key = currentFileName.substring( currentFileName.indexOf( File.separator ) + 1, String key = currentFile.substring( currentFile.indexOf( File.separator ) + 1,
currentFileName.lastIndexOf( "." ) ); currentFile.lastIndexOf( "." ) );
String filePattern = "**/" + key + ".*"; List tmp = (List) duplicate.get( key.toLowerCase() );
if ( tmp == null )
List duplicateFileNames = FileUtils.getFileNames( directory, filePattern, defaultExcludes, false );
Set duplicatedFileNamesSet = (Set) duplicate.get( key.toLowerCase() );
if ( duplicatedFileNamesSet == null )
{ {
duplicatedFileNamesSet = new HashSet(); tmp = new ArrayList();
duplicate.put( key.toLowerCase(), tmp );
} }
tmp.add( currentFile );
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 );
} }
} }
} }