You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2010/08/15 22:50:01 UTC
svn commit: r985751 -
/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/
Author: hboutemy
Date: Sun Aug 15 20:50:00 2010
New Revision: 985751
URL: http://svn.apache.org/viewvc?rev=985751&view=rev
Log:
added Java 5 generics
Modified:
maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java
maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java
maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java
maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java
maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestFixJavadocMojo.java
maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestJavadocJar.java
maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestJavadocReport.java
Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java?rev=985751&r1=985750&r2=985751&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java Sun Aug 15 20:50:00 2010
@@ -302,7 +302,7 @@ public abstract class AbstractFixJavadoc
private ArtifactRepository localRepository;
/**
- * Output directory where Java classes will be rewrited.
+ * Output directory where Java classes will be rewritten.
*
* @parameter expression="${outputDirectory}" default-value="${project.build.sourceDirectory}"
*/
@@ -340,13 +340,13 @@ public abstract class AbstractFixJavadoc
private String[] fixTagsSplitted;
/** New classes found by Clirr. */
- private List clirrNewClasses;
+ private List<String> clirrNewClasses;
/** New Methods in a Class (the key) found by Clirr. */
- private Map clirrNewMethods;
+ private Map<String, List<String>> clirrNewMethods;
/** List of classes where <code>*since</code> is added. Will be used to add or not this tag in the methods. */
- private List sinceClasses;
+ private List<String> sinceClasses;
/** {@inheritDoc} */
public void execute()
@@ -429,10 +429,10 @@ public abstract class AbstractFixJavadoc
* @param p not null maven project.
* @return the list of source paths for the given project.
*/
- protected List getProjectSourceRoots( MavenProject p )
+ protected List<String> getProjectSourceRoots( MavenProject p )
{
return ( p.getCompileSourceRoots() == null ? Collections.EMPTY_LIST
- : new LinkedList( p.getCompileSourceRoots() ) );
+ : new LinkedList<String>( p.getCompileSourceRoots() ) );
}
/**
@@ -440,11 +440,11 @@ public abstract class AbstractFixJavadoc
* @return the compile classpath elements
* @throws DependencyResolutionRequiredException if any
*/
- protected List getCompileClasspathElements( MavenProject p )
+ protected List<String> getCompileClasspathElements( MavenProject p )
throws DependencyResolutionRequiredException
{
return ( p.getCompileClasspathElements() == null ? Collections.EMPTY_LIST
- : new LinkedList( p.getCompileClasspathElements() ) );
+ : new LinkedList<String>( p.getCompileClasspathElements() ) );
}
/**
@@ -487,7 +487,7 @@ public abstract class AbstractFixJavadoc
if ( !FIX_TAGS_ALL.equalsIgnoreCase( fixTags.trim() ) )
{
String[] split = StringUtils.split( fixTags, "," );
- List filtered = new LinkedList();
+ List<String> filtered = new LinkedList<String>();
for ( int j = 0; j < split.length; j++ )
{
String s = split[j].trim();
@@ -697,8 +697,8 @@ public abstract class AbstractFixJavadoc
getLog().info( "Clirr output file was created: " + clirrTextOutputFile.getAbsolutePath() );
}
- clirrNewClasses = new LinkedList();
- clirrNewMethods = new LinkedHashMap();
+ clirrNewClasses = new LinkedList<String>();
+ clirrNewMethods = new LinkedHashMap<String, List<String>>();
BufferedReader input = new BufferedReader( ReaderFactory.newReader( clirrTextOutputFile, "UTF-8" ) );
String line = null;
@@ -732,15 +732,15 @@ public abstract class AbstractFixJavadoc
// 7011 - Method Added
// 7012 - Method Added to Interface
// 8000 - Class Added
- List list;
+ List<String> list;
String[] splits2;
switch ( code )
{
case 7011:
- list = (List) clirrNewMethods.get( split[2].trim() );
+ list = clirrNewMethods.get( split[2].trim() );
if ( list == null )
{
- list = new ArrayList();
+ list = new ArrayList<String>();
}
splits2 = StringUtils.split( split[3].trim(), "'" );
if ( splits2.length != 3 )
@@ -752,10 +752,10 @@ public abstract class AbstractFixJavadoc
break;
case 7012:
- list = (List) clirrNewMethods.get( split[2].trim() );
+ list = clirrNewMethods.get( split[2].trim() );
if ( list == null )
{
- list = new ArrayList();
+ list = new ArrayList<String>();
}
splits2 = StringUtils.split( split[3].trim(), "'" );
if ( splits2.length != 3 )
@@ -823,10 +823,10 @@ public abstract class AbstractFixJavadoc
return null;
}
- List javaFiles = new LinkedList();
- for ( Iterator i = getProjectSourceRoots( project ).iterator(); i.hasNext(); )
+ List<File> javaFiles = new LinkedList<File>();
+ for ( String sourceRoot : getProjectSourceRoots( project ) )
{
- File f = new File( (String) i.next() );
+ File f = new File( sourceRoot );
if ( f.isDirectory() )
{
javaFiles.addAll( FileUtils.getFiles( f, includes, excludes, true ) );
@@ -843,9 +843,8 @@ public abstract class AbstractFixJavadoc
JavaDocBuilder builder = new JavaDocBuilder();
builder.getClassLibrary().addClassLoader( getProjectClassLoader() );
builder.setEncoding( encoding );
- for ( Iterator i = javaFiles.iterator(); i.hasNext(); )
+ for ( File f : javaFiles )
{
- File f = (File) i.next();
if ( !f.getAbsolutePath().toLowerCase( Locale.ENGLISH ).endsWith( ".java" )
&& getLog().isWarnEnabled() )
{
@@ -878,7 +877,7 @@ public abstract class AbstractFixJavadoc
{
if ( projectClassLoader == null )
{
- List classPath;
+ List<String> classPath;
try
{
classPath = getCompileClasspathElements( project );
@@ -888,13 +887,12 @@ public abstract class AbstractFixJavadoc
throw new MojoExecutionException( "DependencyResolutionRequiredException: " + e.getMessage(), e );
}
- List urls = new ArrayList( classPath.size() );
- Iterator iter = classPath.iterator();
- while ( iter.hasNext() )
+ List<URL> urls = new ArrayList<URL>( classPath.size() );
+ for ( String filename : classPath )
{
try
{
- urls.add( new File( ( (String) iter.next() ) ).toURL() );
+ urls.add( new File( filename ).toURL() );
}
catch ( MalformedURLException e )
{
@@ -1120,7 +1118,7 @@ public abstract class AbstractFixJavadoc
*/
private boolean isInLevel( String[] modifiers )
{
- List modifiersAsList = Arrays.asList( modifiers );
+ List<String> modifiersAsList = Arrays.asList( modifiers );
if ( LEVEL_PUBLIC.equalsIgnoreCase( level.trim() ) )
{
@@ -1852,9 +1850,9 @@ public abstract class AbstractFixJavadoc
else
{
// write unknown tags
- for ( Iterator it = javaEntityTags.getUnknownTags().iterator(); it.hasNext(); )
+ for ( Iterator<String> it = javaEntityTags.getUnknownTags().iterator(); it.hasNext(); )
{
- String originalJavadocTag = it.next().toString();
+ String originalJavadocTag = it.next();
if ( StringUtils.removeDuplicateWhitespace( originalJavadocTag ).trim()
.indexOf( "@" + docletTag.getName() ) != -1 )
@@ -1868,9 +1866,9 @@ public abstract class AbstractFixJavadoc
}
else
{
- for ( Iterator it = javaEntityTags.getUnknownTags().iterator(); it.hasNext(); )
+ for ( Iterator<String> it = javaEntityTags.getUnknownTags().iterator(); it.hasNext(); )
{
- String originalJavadocTag = it.next().toString();
+ String originalJavadocTag = it.next();
if ( StringUtils.removeDuplicateWhitespace( originalJavadocTag ).trim()
.indexOf( "@" + docletTag.getName() ) != -1 )
@@ -2034,7 +2032,7 @@ public abstract class AbstractFixJavadoc
}
// Maybe a RuntimeException
- Class clazz = getRuntimeExceptionClass( javaMethod.getParentClass(), exceptionClassName );
+ Class<?> clazz = getRuntimeExceptionClass( javaMethod.getParentClass(), exceptionClassName );
if ( clazz != null )
{
sb.append( StringUtils.replace( originalJavadocTag, exceptionClassName, clazz.getName() ) );
@@ -2596,24 +2594,20 @@ public abstract class AbstractFixJavadoc
}
}
- Class clazz = getClass( javaMethod.getParentClass().getFullyQualifiedName() );
+ Class<?> clazz = getClass( javaMethod.getParentClass().getFullyQualifiedName() );
- List interfaces = ClassUtils.getAllInterfaces( clazz );
- for ( Iterator it = interfaces.iterator(); it.hasNext(); )
+ List<Class<?>>interfaces = ClassUtils.getAllInterfaces( clazz );
+ for ( Class<?> intface : interfaces )
{
- Class intface = (Class) it.next();
-
if ( isInherited( intface, javaMethod ) )
{
return true;
}
}
- List classes = ClassUtils.getAllSuperclasses( clazz );
- for ( Iterator it = classes.iterator(); it.hasNext(); )
+ List<Class<?>> classes = ClassUtils.getAllSuperclasses( clazz );
+ for ( Class<?> superClass : classes )
{
- Class superClass = (Class) it.next();
-
if ( isInherited( superClass, javaMethod ) )
{
return true;
@@ -2630,7 +2624,7 @@ public abstract class AbstractFixJavadoc
* <code>false</code> otherwise.
* @see #isInherited(JavaMethod)
*/
- private boolean isInherited( Class clazz, JavaMethod javaMethod )
+ private boolean isInherited( Class<?> clazz, JavaMethod javaMethod )
{
Method[] methods = clazz.getDeclaredMethods();
for ( int i = 0; i < methods.length; i++ )
@@ -2752,17 +2746,15 @@ public abstract class AbstractFixJavadoc
return false;
}
- List clirrMethods = (List) clirrNewMethods.get( javaMethod.getParentClass().getFullyQualifiedName() );
+ List<String> clirrMethods = clirrNewMethods.get( javaMethod.getParentClass().getFullyQualifiedName() );
if ( clirrMethods == null )
{
return false;
}
- for ( Iterator it = clirrMethods.iterator(); it.hasNext(); )
+ for ( String clirrMethod : clirrMethods )
{
// see net.sf.clirr.core.internal.checks.MethodSetCheck#getMethodId(JavaType clazz, Method method)
- String clirrMethod = (String) it.next();
-
String retrn = "";
if ( javaMethod.getReturns() != null )
{
@@ -2796,7 +2788,7 @@ public abstract class AbstractFixJavadoc
* @see {@link ClassUtils#getClass(ClassLoader, String, boolean)}
* @see {@link #getProjectClassLoader()}
*/
- private Class getClass( String className )
+ private Class<?> getClass( String className )
throws MojoExecutionException
{
try
@@ -2824,14 +2816,14 @@ public abstract class AbstractFixJavadoc
* @return a RuntimeException assignable class.
* @see #getClass(String)
*/
- private Class getRuntimeExceptionClass( JavaClass currentClass, String exceptionClassName )
+ private Class<?> getRuntimeExceptionClass( JavaClass currentClass, String exceptionClassName )
{
String[] potentialClassNames =
new String[] { exceptionClassName, currentClass.getPackage().getName() + "." + exceptionClassName,
currentClass.getPackage().getName() + "." + currentClass.getName() + "$" + exceptionClassName,
"java.lang." + exceptionClassName };
- Class clazz = null;
+ Class<?> clazz = null;
for ( int i = 0; i < potentialClassNames.length; i++ )
{
try
@@ -2858,7 +2850,7 @@ public abstract class AbstractFixJavadoc
{
if ( sinceClasses == null )
{
- sinceClasses = new ArrayList();
+ sinceClasses = new ArrayList<String>();
}
sinceClasses.add( javaClass.getFullyQualifiedName() );
}
@@ -3254,7 +3246,7 @@ public abstract class AbstractFixJavadoc
}
String[] javaClassContentLines = getLines( javaClassContent );
- List list = new LinkedList();
+ List<String> list = new LinkedList<String>();
for ( int i = entity.getLineNumber() - 2; i >= 0; i-- )
{
String line = javaClassContentLines[i];
@@ -3363,14 +3355,14 @@ public abstract class AbstractFixJavadoc
return content;
}
- List linesList = new LinkedList();
+ List<String> linesList = new LinkedList<String>();
linesList.addAll( Arrays.asList( lines ) );
Collections.reverse( linesList );
- for ( Iterator it = linesList.iterator(); it.hasNext(); )
+ for ( Iterator<String> it = linesList.iterator(); it.hasNext(); )
{
- String line = (String) it.next();
+ String line = it.next();
if ( line.trim().equals( "*" ) )
{
@@ -3446,7 +3438,7 @@ public abstract class AbstractFixJavadoc
private static String[] getLines( final String content )
throws IOException
{
- List lines = new LinkedList();
+ List<String> lines = new LinkedList<String>();
BufferedReader reader = new BufferedReader( new StringReader( content ) );
String line = reader.readLine();
@@ -3528,7 +3520,7 @@ public abstract class AbstractFixJavadoc
if ( params[0].trim().equals( "<" ) && params[2].trim().equals( ">" ) )
{
String param = params[1];
- List l = new ArrayList( Arrays.asList( params ) );
+ List<String> l = new ArrayList<String>( Arrays.asList( params ) );
l.set( 1, "<" + param + ">" );
l.remove( 0 );
l.remove( 1 );
@@ -3549,31 +3541,31 @@ public abstract class AbstractFixJavadoc
private final boolean isJavaMethod;
/** List of tag names. */
- private List namesTags;
+ private List<String> namesTags;
/** Map with java parameter as key and original Javadoc lines as values. */
- private Map tagParams;
+ private Map<String, String> tagParams;
/** Original javadoc lines. */
private String tagReturn;
/** Map with java throw as key and original Javadoc lines as values. */
- private Map tagThrows;
+ private Map<String, String> tagThrows;
/** Original javadoc lines for unknown tags. */
- private List unknownsTags;
+ private List<String> unknownsTags;
public JavaEntityTags( AbstractInheritableJavaEntity entity, boolean isJavaMethod )
{
this.entity = entity;
this.isJavaMethod = isJavaMethod;
- this.namesTags = new LinkedList();
- this.tagParams = new LinkedHashMap();
- this.tagThrows = new LinkedHashMap();
- this.unknownsTags = new LinkedList();
+ this.namesTags = new LinkedList<String>();
+ this.tagParams = new LinkedHashMap<String, String>();
+ this.tagThrows = new LinkedHashMap<String, String>();
+ this.unknownsTags = new LinkedList<String>();
}
- public List getNamesTags()
+ public List<String> getNamesTags()
{
return namesTags;
}
@@ -3588,7 +3580,7 @@ public abstract class AbstractFixJavadoc
tagReturn = s;
}
- public List getUnknownTags()
+ public List<String> getUnknownTags()
{
return unknownsTags;
}
Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java?rev=985751&r1=985750&r2=985751&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java Sun Aug 15 20:50:00 2010
@@ -393,7 +393,7 @@ public abstract class AbstractJavadocMoj
*
* @parameter expression="${project.remoteArtifactRepositories}"
*/
- private List remoteRepositories;
+ private List<ArtifactRepository> remoteRepositories;
/**
* The projects in the reactor for aggregation report.
@@ -1691,11 +1691,11 @@ public abstract class AbstractJavadocMoj
* @return the list of directories where compiled classes are placed for the given project. These dirs are
* added in the javadoc classpath.
*/
- protected List getProjectBuildOutputDirs( MavenProject p )
+ protected List<String> getProjectBuildOutputDirs( MavenProject p )
{
if ( StringUtils.isEmpty( p.getBuild().getOutputDirectory() ) )
{
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
return Collections.singletonList( p.getBuild().getOutputDirectory() );
@@ -1705,11 +1705,11 @@ public abstract class AbstractJavadocMoj
* @param p not null maven project
* @return the list of source paths for the given project
*/
- protected List getProjectSourceRoots( MavenProject p )
+ protected List<String> getProjectSourceRoots( MavenProject p )
{
if ( "pom".equals( p.getPackaging().toLowerCase() ) )
{
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
return ( p.getCompileSourceRoots() == null ? Collections.EMPTY_LIST
@@ -1720,11 +1720,11 @@ public abstract class AbstractJavadocMoj
* @param p not null maven project
* @return the list of source paths for the execution project of the given project
*/
- protected List getExecutionProjectSourceRoots( MavenProject p )
+ protected List<String> getExecutionProjectSourceRoots( MavenProject p )
{
if ( "pom".equals( p.getExecutionProject().getPackaging().toLowerCase() ) )
{
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
return ( p.getExecutionProject().getCompileSourceRoots() == null ? Collections.EMPTY_LIST
@@ -1735,10 +1735,10 @@ public abstract class AbstractJavadocMoj
* @param p not null maven project
* @return the list of artifacts for the given project
*/
- protected List getProjectArtifacts( MavenProject p )
+ protected List<Artifact> getProjectArtifacts( MavenProject p )
{
return ( p.getCompileArtifacts() == null ? Collections.EMPTY_LIST
- : new LinkedList( p.getCompileArtifacts() ) );
+ : new LinkedList<Artifact>( p.getCompileArtifacts() ) );
}
/**
@@ -1834,15 +1834,15 @@ public abstract class AbstractJavadocMoj
throw new MavenReportException( "Failed to generate javadoc options file: " + e.getMessage(), e );
}
- List sourcePaths = getSourcePaths();
- List files = getFiles( sourcePaths );
+ List<String> sourcePaths = getSourcePaths();
+ List<String> files = getFiles( sourcePaths );
if ( !canGenerateReport( files ) )
{
return;
}
- List packageNames = getPackageNames( sourcePaths, files );
- List filesWithUnnamedPackages = getFilesWithUnnamedPackages( sourcePaths, files );
+ List<String> packageNames = getPackageNames( sourcePaths, files );
+ List<String> filesWithUnnamedPackages = getFilesWithUnnamedPackages( sourcePaths, files );
// ----------------------------------------------------------------------
// Find the javadoc executable and version
@@ -1902,7 +1902,7 @@ public abstract class AbstractJavadocMoj
cmd.createArg().setValue( additionalJOption );
}
- List arguments = new ArrayList();
+ List<String> arguments = new ArrayList<String>();
// ----------------------------------------------------------------------
// Wrap Javadoc options
@@ -1997,17 +1997,17 @@ public abstract class AbstractJavadocMoj
* @return a List that contains the specific path for every source file
* @throws MavenReportException
*/
- protected List getFiles( List sourcePaths )
+ protected List<String> getFiles( List<String> sourcePaths )
throws MavenReportException
{
- List files = new ArrayList();
+ List<String> files = new ArrayList<String>();
if ( StringUtils.isEmpty( subpackages ) )
{
String[] excludedPackages = getExcludedPackages();
- for ( Iterator i = sourcePaths.iterator(); i.hasNext(); )
+ for ( String sourcePath : sourcePaths )
{
- File sourceDirectory = new File( (String) i.next() );
+ File sourceDirectory = new File( sourcePath );
JavadocUtil.addFilesFromSource( files, sourceDirectory, excludedPackages );
}
}
@@ -2022,14 +2022,14 @@ public abstract class AbstractJavadocMoj
* @return a List of the project absolute source paths as <code>String</code>
* @see JavadocUtil#pruneDirs(MavenProject, List)
*/
- protected List getSourcePaths()
+ protected List<String> getSourcePaths()
throws MavenReportException
{
- List sourcePaths;
+ List<String> sourcePaths;
if ( StringUtils.isEmpty( sourcepath ) )
{
- sourcePaths = new ArrayList( JavadocUtil.pruneDirs( project, getProjectSourceRoots( project ) ) );
+ sourcePaths = new ArrayList<String>( JavadocUtil.pruneDirs( project, getProjectSourceRoots( project ) ) );
if ( project.getExecutionProject() != null )
{
@@ -2046,7 +2046,7 @@ public abstract class AbstractJavadocMoj
File javadocDir = getJavadocDirectory();
if ( javadocDir.exists() && javadocDir.isDirectory() )
{
- List l =
+ List<String> l =
JavadocUtil.pruneDirs( project,
Collections.singletonList( getJavadocDirectory().getAbsolutePath() ) );
sourcePaths.addAll( l );
@@ -2060,13 +2060,11 @@ public abstract class AbstractJavadocMoj
if ( isAggregator() && project.isExecutionRoot() )
{
- for ( Iterator i = reactorProjects.iterator(); i.hasNext(); )
+ for ( MavenProject subProject : reactorProjects )
{
- MavenProject subProject = (MavenProject) i.next();
-
if ( subProject != project )
{
- List sourceRoots = getProjectSourceRoots( subProject );
+ List<String> sourceRoots = getProjectSourceRoots( subProject );
if ( subProject.getExecutionProject() != null )
{
@@ -2084,7 +2082,7 @@ public abstract class AbstractJavadocMoj
File javadocDir = new File( subProject.getBasedir(), javadocDirRelative );
if ( javadocDir.exists() && javadocDir.isDirectory() )
{
- List l =
+ List<String> l =
JavadocUtil.pruneDirs( subProject,
Collections.singletonList( javadocDir.getAbsolutePath() ) );
sourcePaths.addAll( l );
@@ -2095,11 +2093,11 @@ public abstract class AbstractJavadocMoj
}
else
{
- sourcePaths = new ArrayList( Arrays.asList( JavadocUtil.splitPath( sourcepath ) ) );
+ sourcePaths = new ArrayList<String>( Arrays.asList( JavadocUtil.splitPath( sourcepath ) ) );
sourcePaths = JavadocUtil.pruneDirs( project, sourcePaths );
if ( getJavadocDirectory() != null )
{
- List l =
+ List<String> l =
JavadocUtil.pruneDirs( project,
Collections.singletonList( getJavadocDirectory().getAbsolutePath() ) );
sourcePaths.addAll( l );
@@ -2201,7 +2199,7 @@ public abstract class AbstractJavadocMoj
* @param files the project files
* @return a boolean that indicates whether javadoc report can be generated or not
*/
- protected boolean canGenerateReport( List files )
+ protected boolean canGenerateReport( List<String> files )
{
boolean canGenerate = true;
@@ -2218,7 +2216,7 @@ public abstract class AbstractJavadocMoj
* @return the compile artifacts from the result
* @see JavadocUtil#getCompileArtifacts(Set, boolean)
*/
- protected List getCompileArtifacts( ArtifactResolutionResult result )
+ protected List<Artifact> getCompileArtifacts( ArtifactResolutionResult result )
{
return JavadocUtil.getCompileArtifacts( result.getArtifacts(), false );
}
@@ -2235,10 +2233,10 @@ public abstract class AbstractJavadocMoj
* @return a String that contains the exclude argument that will be used by javadoc
* @throws MavenReportException
*/
- private String getExcludedPackages( List sourcePaths )
+ private String getExcludedPackages( List<String> sourcePaths )
throws MavenReportException
{
- List excludedNames = null;
+ List<String> excludedNames = null;
if ( StringUtils.isNotEmpty( sourcepath ) && StringUtils.isNotEmpty( subpackages ) )
{
@@ -2252,9 +2250,9 @@ public abstract class AbstractJavadocMoj
if ( StringUtils.isNotEmpty( subpackages ) && excludedNames != null )
{
// add the excludedpackage names
- for ( Iterator it = excludedNames.iterator(); it.hasNext(); )
+ for ( Iterator<String> it = excludedNames.iterator(); it.hasNext(); )
{
- String str = (String) it.next();
+ String str = it.next();
excludeArg = excludeArg + str;
if ( it.hasNext() )
@@ -2275,7 +2273,7 @@ public abstract class AbstractJavadocMoj
* string (colon (<code>:</code>) on Solaris or semi-colon (<code>;</code>) on Windows).
* @see File#pathSeparator
*/
- private String getSourcePath( List sourcePaths )
+ private String getSourcePath( List<String> sourcePaths )
{
String sourcePath = null;
@@ -2355,8 +2353,8 @@ public abstract class AbstractJavadocMoj
private String getClasspath()
throws MavenReportException
{
- List classpathElements = new ArrayList();
- Map compileArtifactMap = new HashMap();
+ List<String> classpathElements = new ArrayList<String>();
+ Map<String, Artifact> compileArtifactMap = new HashMap<String, Artifact>();
classpathElements.addAll( getProjectBuildOutputDirs( project ) );
@@ -2366,15 +2364,13 @@ public abstract class AbstractJavadocMoj
{
try
{
- for ( Iterator i = reactorProjects.iterator(); i.hasNext(); )
+ for ( MavenProject subProject : reactorProjects )
{
- MavenProject subProject = (MavenProject) i.next();
-
if ( subProject != project )
{
classpathElements.addAll( getProjectBuildOutputDirs( subProject ) );
- Set dependencyArtifacts = subProject.createArtifacts( factory, null, null );
+ Set<Artifact> dependencyArtifacts = subProject.createArtifacts( factory, null, null );
if ( !dependencyArtifacts.isEmpty() )
{
ArtifactResolutionResult result = null;
@@ -2423,11 +2419,9 @@ public abstract class AbstractJavadocMoj
sb.append( subProject.getGroupId() ).append( ":" );
sb.append( subProject.getArtifactId() ).append( ":" );
sb.append( subProject.getVersion() ).append( '\n' );
- for ( Iterator it = compileArtifactMap.keySet().iterator(); it.hasNext(); )
+ for ( String key : compileArtifactMap.keySet() )
{
- String key = it.next().toString();
-
- Artifact a = (Artifact) compileArtifactMap.get( key );
+ Artifact a = compileArtifactMap.get( key );
sb.append( a.getFile() ).append( '\n' );
}
@@ -2443,12 +2437,10 @@ public abstract class AbstractJavadocMoj
}
}
- for ( Iterator it = compileArtifactMap.keySet().iterator(); it.hasNext(); )
+ for ( String key : compileArtifactMap.keySet() )
{
- String key = it.next().toString();
-
- Artifact a = (Artifact) compileArtifactMap.get( key );
- classpathElements.add( a.getFile() );
+ Artifact a = compileArtifactMap.get( key );
+ classpathElements.add( a.getFile().toString() );
}
return StringUtils.join( classpathElements.iterator(), File.pathSeparator );
@@ -2478,41 +2470,41 @@ public abstract class AbstractJavadocMoj
* @param artifactList the list of artifacts that will be put in the map
* @throws MavenReportException if any
*/
- private void populateCompileArtifactMap( Map compileArtifactMap, Collection artifactList )
+ private void populateCompileArtifactMap( Map<String, Artifact> compileArtifactMap, Collection<Artifact> artifactList )
throws MavenReportException
{
- if ( artifactList != null )
+ if ( artifactList == null )
{
- for ( Iterator i = artifactList.iterator(); i.hasNext(); )
- {
- Artifact newArtifact = (Artifact) i.next();
+ return;
+ }
- File file = newArtifact.getFile();
+ for ( Artifact newArtifact : artifactList )
+ {
+ File file = newArtifact.getFile();
- if ( file == null )
- {
- throw new MavenReportException( "Error in plugin descriptor - "
- + "dependency was not resolved for artifact: " + newArtifact.getGroupId() + ":"
- + newArtifact.getArtifactId() + ":" + newArtifact.getVersion() );
- }
+ if ( file == null )
+ {
+ throw new MavenReportException( "Error in plugin descriptor - "
+ + "dependency was not resolved for artifact: " + newArtifact.getGroupId() + ":"
+ + newArtifact.getArtifactId() + ":" + newArtifact.getVersion() );
+ }
- if ( compileArtifactMap.get( newArtifact.getDependencyConflictId() ) != null )
- {
- Artifact oldArtifact =
- (Artifact) compileArtifactMap.get( newArtifact.getDependencyConflictId() );
+ if ( compileArtifactMap.get( newArtifact.getDependencyConflictId() ) != null )
+ {
+ Artifact oldArtifact =
+ (Artifact) compileArtifactMap.get( newArtifact.getDependencyConflictId() );
- ArtifactVersion oldVersion = new DefaultArtifactVersion( oldArtifact.getVersion() );
- ArtifactVersion newVersion = new DefaultArtifactVersion( newArtifact.getVersion() );
- if ( newVersion.compareTo( oldVersion ) > 0 )
- {
- compileArtifactMap.put( newArtifact.getDependencyConflictId(), newArtifact );
- }
- }
- else
+ ArtifactVersion oldVersion = new DefaultArtifactVersion( oldArtifact.getVersion() );
+ ArtifactVersion newVersion = new DefaultArtifactVersion( newArtifact.getVersion() );
+ if ( newVersion.compareTo( oldVersion ) > 0 )
{
compileArtifactMap.put( newArtifact.getDependencyConflictId(), newArtifact );
}
}
+ else
+ {
+ compileArtifactMap.put( newArtifact.getDependencyConflictId(), newArtifact );
+ }
}
}
@@ -3213,23 +3205,21 @@ public abstract class AbstractJavadocMoj
// Find its transitive dependencies in the local repo
MavenProject artifactProject =
mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories, localRepository );
- Set dependencyArtifacts = artifactProject.createArtifacts( factory, null, null );
+ Set<Artifact> dependencyArtifacts = artifactProject.createArtifacts( factory, null, null );
if ( !dependencyArtifacts.isEmpty() )
{
ArtifactResolutionResult result =
resolver.resolveTransitively( dependencyArtifacts, artifactProject.getArtifact(),
artifactProject.getRemoteArtifactRepositories(),
localRepository, artifactMetadataSource );
- Set artifacts = result.getArtifacts();
+ Set<Artifact> artifacts = result.getArtifacts();
- Map compileArtifactMap = new HashMap();
+ Map<String, Artifact> compileArtifactMap = new HashMap<String, Artifact>();
populateCompileArtifactMap( compileArtifactMap, artifacts );
- for ( Iterator it = compileArtifactMap.keySet().iterator(); it.hasNext(); )
+ for ( String key : compileArtifactMap.keySet() )
{
- String key = it.next().toString();
-
- Artifact a = (Artifact) compileArtifactMap.get( key );
+ Artifact a = compileArtifactMap.get( key );
path.add( a.getFile().getAbsolutePath() );
}
}
@@ -3571,7 +3561,7 @@ public abstract class AbstractJavadocMoj
* @param b the flag which controls if the argument is added or not.
* @param value the argument value to be added.
*/
- private void addArgIf( List arguments, boolean b, String value )
+ private void addArgIf( List<String> arguments, boolean b, String value )
{
if ( b )
{
@@ -3590,7 +3580,7 @@ public abstract class AbstractJavadocMoj
* @see #addArgIf(java.util.List,boolean,String)
* @see #isJavaDocVersionAtLeast(float)
*/
- private void addArgIf( List arguments, boolean b, String value, float requiredJavaVersion )
+ private void addArgIf( List<String> arguments, boolean b, String value, float requiredJavaVersion )
{
if ( b )
{
@@ -3621,7 +3611,7 @@ public abstract class AbstractJavadocMoj
* @param value the argument value to be added.
* @see #addArgIfNotEmpty(java.util.List,String,String,boolean)
*/
- private void addArgIfNotEmpty( List arguments, String key, String value )
+ private void addArgIfNotEmpty( List<String> arguments, String key, String value )
{
addArgIfNotEmpty( arguments, key, value, false );
}
@@ -3641,7 +3631,7 @@ public abstract class AbstractJavadocMoj
* @see #addArgIfNotEmpty(List, String, String, boolean, boolean)
* @see #isJavaDocVersionAtLeast(float)
*/
- private void addArgIfNotEmpty( List arguments, String key, String value, boolean repeatKey,
+ private void addArgIfNotEmpty( List<String> arguments, String key, String value, boolean repeatKey,
boolean splitValue, float requiredJavaVersion )
{
if ( StringUtils.isNotEmpty( value ) )
@@ -3674,7 +3664,8 @@ public abstract class AbstractJavadocMoj
* @param repeatKey repeat or not the key in the command line
* @param splitValue if <code>true</code> given value will be tokenized by comma
*/
- private void addArgIfNotEmpty( List arguments, String key, String value, boolean repeatKey, boolean splitValue )
+ private void addArgIfNotEmpty( List<String> arguments, String key, String value, boolean repeatKey,
+ boolean splitValue )
{
if ( StringUtils.isNotEmpty( value ) )
{
@@ -3719,7 +3710,7 @@ public abstract class AbstractJavadocMoj
* @param value the argument value to be added.
* @param repeatKey repeat or not the key in the command line
*/
- private void addArgIfNotEmpty( List arguments, String key, String value, boolean repeatKey )
+ private void addArgIfNotEmpty( List<String> arguments, String key, String value, boolean repeatKey )
{
addArgIfNotEmpty( arguments, key, value, repeatKey, true );
}
@@ -3734,7 +3725,7 @@ public abstract class AbstractJavadocMoj
* @param requiredJavaVersion the required Java version, for example 1.31f or 1.4f
* @see #addArgIfNotEmpty(java.util.List, String, String, float, boolean)
*/
- private void addArgIfNotEmpty( List arguments, String key, String value, float requiredJavaVersion )
+ private void addArgIfNotEmpty( List<String> arguments, String key, String value, float requiredJavaVersion )
{
addArgIfNotEmpty( arguments, key, value, requiredJavaVersion, false );
}
@@ -3751,7 +3742,7 @@ public abstract class AbstractJavadocMoj
* @see #addArgIfNotEmpty(java.util.List,String,String)
* @see #isJavaDocVersionAtLeast(float)
*/
- private void addArgIfNotEmpty( List arguments, String key, String value, float requiredJavaVersion,
+ private void addArgIfNotEmpty( List<String> arguments, String key, String value, float requiredJavaVersion,
boolean repeatKey )
{
if ( StringUtils.isNotEmpty( value ) )
@@ -3980,10 +3971,8 @@ public abstract class AbstractJavadocMoj
if ( isAggregator() && project.isExecutionRoot() )
{
- for ( Iterator i = reactorProjects.iterator(); i.hasNext(); )
+ for ( MavenProject subProject : reactorProjects )
{
- MavenProject subProject = (MavenProject) i.next();
-
if ( subProject != project )
{
String javadocDirRelative =
@@ -4082,7 +4071,7 @@ public abstract class AbstractJavadocMoj
* @param files not null
* @return the list of package names for files in the sourcePaths
*/
- private List getPackageNames( List sourcePaths, List files )
+ private List<String> getPackageNames( List<String> sourcePaths, List<String> files )
{
return getPackageNamesOrFilesWithUnnamedPackages( sourcePaths, files, true );
}
@@ -4092,7 +4081,7 @@ public abstract class AbstractJavadocMoj
* @param files not null
* @return a list files with unnamed package names for files in the sourecPaths
*/
- private List getFilesWithUnnamedPackages( List sourcePaths, List files )
+ private List<String> getFilesWithUnnamedPackages( List<String> sourcePaths, List<String> files )
{
return getPackageNamesOrFilesWithUnnamedPackages( sourcePaths, files, false );
}
@@ -4105,23 +4094,22 @@ public abstract class AbstractJavadocMoj
* @see #getFiles(List)
* @see #getSourcePaths()
*/
- private List getPackageNamesOrFilesWithUnnamedPackages( List sourcePaths, List files, boolean onlyPackageName )
+ private List<String> getPackageNamesOrFilesWithUnnamedPackages( List<String> sourcePaths, List<String> files,
+ boolean onlyPackageName )
{
- List returnList = new ArrayList();
+ List<String> returnList = new ArrayList<String>();
if ( !StringUtils.isEmpty( sourcepath ) )
{
return returnList;
}
- for ( Iterator it = files.iterator(); it.hasNext(); )
+ for ( String currentFile : files )
{
- String currentFile = (String) it.next();
currentFile = currentFile.replace( '\\', '/' );
- for ( Iterator it2 = sourcePaths.iterator(); it2.hasNext(); )
+ for ( String currentSourcePath : sourcePaths )
{
- String currentSourcePath = (String) it2.next();
currentSourcePath = currentSourcePath.replace( '\\', '/' );
if ( !currentSourcePath.endsWith( "/" ) )
@@ -4176,7 +4164,7 @@ public abstract class AbstractJavadocMoj
* @throws MavenReportException if any
* @see #OPTIONS_FILE_NAME
*/
- private void addCommandLineOptions( Commandline cmd, List arguments, File javadocOutputDirectory )
+ private void addCommandLineOptions( Commandline cmd, List<String> arguments, File javadocOutputDirectory )
throws MavenReportException
{
File optionsFile = new File( javadocOutputDirectory, OPTIONS_FILE_NAME );
@@ -4216,7 +4204,7 @@ public abstract class AbstractJavadocMoj
* @see #ARGFILE_FILE_NAME
* @see #FILES_FILE_NAME
*/
- private void addCommandLineArgFile( Commandline cmd, File javadocOutputDirectory, List files )
+ private void addCommandLineArgFile( Commandline cmd, File javadocOutputDirectory, List<String> files )
throws MavenReportException
{
File argfileFile;
@@ -4263,7 +4251,7 @@ public abstract class AbstractJavadocMoj
* @throws MavenReportException if any
* @see #PACKAGES_FILE_NAME
*/
- private void addCommandLinePackages( Commandline cmd, File javadocOutputDirectory, List packageNames )
+ private void addCommandLinePackages( Commandline cmd, File javadocOutputDirectory, List<String> packageNames )
throws MavenReportException
{
File packagesFile = new File( javadocOutputDirectory, PACKAGES_FILE_NAME );
@@ -4344,7 +4332,7 @@ public abstract class AbstractJavadocMoj
}
this.locale = localeObject.toString();
- final List availableLocalesList = Arrays.asList( Locale.getAvailableLocales() );
+ final List<Locale> availableLocalesList = Arrays.asList( Locale.getAvailableLocales() );
if ( StringUtils.isNotEmpty( localeObject.getVariant() )
&& !availableLocalesList.contains( localeObject ) )
{
@@ -4433,17 +4421,14 @@ public abstract class AbstractJavadocMoj
* @return true if ALL missing artifacts are found in the reactor.
* @see DefaultPluginManager#checkRequiredMavenVersion( plugin, localRepository, remoteRepositories )
*/
- private boolean checkMissingArtifactsInReactor( Collection dependencyArtifacts, Collection missing )
+ private boolean checkMissingArtifactsInReactor( Collection<Artifact> dependencyArtifacts,
+ Collection<Artifact> missing )
{
- Set foundInReactor = new HashSet();
- Iterator iter = missing.iterator();
- while ( iter.hasNext() )
+ Set<MavenProject> foundInReactor = new HashSet<MavenProject>();
+ for ( Artifact mArtifact : missing )
{
- Artifact mArtifact = (Artifact) iter.next();
- Iterator pIter = reactorProjects.iterator();
- while ( pIter.hasNext() )
+ for ( MavenProject p : reactorProjects )
{
- MavenProject p = (MavenProject) pIter.next();
if ( p.getArtifactId().equals( mArtifact.getArtifactId() )
&& p.getGroupId().equals( mArtifact.getGroupId() )
&& p.getVersion().equals( mArtifact.getVersion() ) )
@@ -4477,7 +4462,7 @@ public abstract class AbstractJavadocMoj
* @throws MavenReportException if any
* @see <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javadoc.html#javadocoptions">http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javadoc.html#javadocoptions</a>
*/
- private void addJavadocOptions( List arguments, List sourcePaths )
+ private void addJavadocOptions( List<String> arguments, List<String> sourcePaths )
throws MavenReportException
{
validateJavadocOptions();
@@ -4569,7 +4554,7 @@ public abstract class AbstractJavadocMoj
* @see <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javadoc.html#standard">
* http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javadoc.html#standard</a>
*/
- private void addStandardDocletOptions( File javadocOutputDirectory, List arguments )
+ private void addStandardDocletOptions( File javadocOutputDirectory, List<String> arguments )
throws MavenReportException
{
validateStandardDocletOptions();
@@ -4695,7 +4680,7 @@ public abstract class AbstractJavadocMoj
* @param arguments not null
* @throws MavenReportException
*/
- private void addGroups( List arguments )
+ private void addGroups( List<String> arguments )
throws MavenReportException
{
Set<Group> groups = collectGroups();
@@ -4729,7 +4714,7 @@ public abstract class AbstractJavadocMoj
* @param arguments not null
* @throws MavenReportException
*/
- private void addTags( List arguments )
+ private void addTags( List<String> arguments )
throws MavenReportException
{
Set<Tag> tags = collectTags();
@@ -4770,7 +4755,7 @@ public abstract class AbstractJavadocMoj
*
* @param arguments not null
*/
- private void addTaglets( List arguments )
+ private void addTaglets( List<String> arguments )
{
if ( taglets == null )
{
@@ -4801,7 +4786,7 @@ public abstract class AbstractJavadocMoj
* @throws MavenReportException if any
* @see JavadocUtil#getTagletClassNames(File)
*/
- private void addTagletsFromTagletArtifacts( List arguments )
+ private void addTagletsFromTagletArtifacts( List<String> arguments )
throws MavenReportException
{
Set<TagletArtifact> tArtifacts = new LinkedHashSet<TagletArtifact>();
@@ -4839,9 +4824,9 @@ public abstract class AbstractJavadocMoj
return;
}
- List tagletsPath = new ArrayList();
+ List<String> tagletsPath = new ArrayList<String>();
- for ( TagletArtifact aTagletArtifact: tArtifacts )
+ for ( TagletArtifact aTagletArtifact : tArtifacts )
{
if ( ( StringUtils.isNotEmpty( aTagletArtifact.getGroupId() ) )
&& ( StringUtils.isNotEmpty( aTagletArtifact.getArtifactId() ) )
@@ -4872,16 +4857,14 @@ public abstract class AbstractJavadocMoj
tagletsPath = JavadocUtil.pruneFiles( tagletsPath );
- for ( Iterator it = tagletsPath.iterator(); it.hasNext(); )
+ for ( String tagletJar : tagletsPath )
{
- String tagletJar = (String) it.next();
-
if ( !tagletJar.toLowerCase( Locale.ENGLISH ).endsWith( ".jar" ) )
{
continue;
}
- List tagletClasses;
+ List<String> tagletClasses;
try
{
tagletClasses = JavadocUtil.getTagletClassNames( new File( tagletJar ) );
@@ -4931,10 +4914,8 @@ public abstract class AbstractJavadocMoj
if ( tagletClasses != null && !tagletClasses.isEmpty() )
{
- for ( Iterator it2 = tagletClasses.iterator(); it2.hasNext(); )
+ for ( String tagletClass : tagletClasses )
{
- String tagletClass = (String) it2.next();
-
addArgIfNotEmpty( arguments, "-taglet", JavadocUtil.quotedArgument( tagletClass ),
SINCE_JAVADOC_1_4 );
}
@@ -5063,7 +5044,7 @@ public abstract class AbstractJavadocMoj
inputResourceName = inputResourceName.replaceFirst( "//*", "" );
}
- List classPath = new ArrayList();
+ List<String> classPath = new ArrayList<String>();
classPath.add( project.getBuild().getSourceDirectory() );
URL resourceURL = getResource( classPath, inputResourceName );
@@ -5074,9 +5055,9 @@ public abstract class AbstractJavadocMoj
}
classPath.clear();
- for ( Iterator it = project.getBuild().getResources().iterator(); it.hasNext(); )
+ for ( Iterator<Resource> it = project.getBuild().getResources().iterator(); it.hasNext(); )
{
- Resource resource = (Resource) it.next();
+ Resource resource = it.next();
classPath.add( resource.getDirectory() );
}
@@ -5104,9 +5085,9 @@ public abstract class AbstractJavadocMoj
Plugin javadocPlugin = getPlugin( project, pluginId );
if ( javadocPlugin != null && javadocPlugin.getDependencies() != null )
{
- for ( Iterator it = javadocPlugin.getDependencies().iterator(); it.hasNext(); )
+ for ( Iterator<Dependency> it = javadocPlugin.getDependencies().iterator(); it.hasNext(); )
{
- Dependency dependency = (Dependency) it.next();
+ Dependency dependency = it.next();
JavadocPathArtifact javadocPathArtifact = new JavadocPathArtifact();
javadocPathArtifact.setGroupId( dependency.getGroupId() );
@@ -5171,15 +5152,14 @@ public abstract class AbstractJavadocMoj
* @see ClassLoader#getResource(String)
* @since 2.6
*/
- private URL getResource( final List classPath, final String resource )
+ private URL getResource( final List<String> classPath, final String resource )
{
- List urls = new ArrayList( classPath.size() );
- Iterator iter = classPath.iterator();
- while ( iter.hasNext() )
+ List<URL> urls = new ArrayList<URL>( classPath.size() );
+ for ( String filename : classPath )
{
try
{
- urls.add( new File( ( (String) iter.next() ) ).toURL() );
+ urls.add( new File( filename ).toURL() );
}
catch ( MalformedURLException e )
{
@@ -5263,17 +5243,15 @@ public abstract class AbstractJavadocMoj
{
if ( !( detectOfflineLinks && !isAggregator() && reactorProjects != null ) )
{
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
getLog().debug( "Try to add links for modules..." );
- List modulesLinks = new ArrayList();
+ List<OfflineLink> modulesLinks = new ArrayList<OfflineLink>();
String javadocDirRelative = PathUtils.toRelative( project.getBasedir(), getOutputDirectory() );
- for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
+ for ( MavenProject p : reactorProjects )
{
- MavenProject p = (MavenProject) it.next();
-
if ( p.getPackaging().equals( "pom" ) )
{
continue;
@@ -5367,15 +5345,15 @@ public abstract class AbstractJavadocMoj
{
if ( !detectLinks )
{
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
getLog().debug( "Try to add links for dependencies..." );
- List dependenciesLinks = new ArrayList();
- for ( Iterator it = project.getDependencyArtifacts().iterator(); it.hasNext(); )
+ List<String> dependenciesLinks = new ArrayList<String>();
+ for ( Iterator<Artifact> it = project.getDependencyArtifacts().iterator(); it.hasNext(); )
{
- Artifact artifact = (Artifact) it.next();
+ Artifact artifact = it.next();
if ( artifact != null && artifact.getFile() != null && artifact.getFile().exists() )
{
Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java?rev=985751&r1=985750&r2=985751&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocJar.java Sun Aug 15 20:50:00 2010
@@ -33,9 +33,8 @@ import org.codehaus.plexus.archiver.jar.
import java.io.File;
import java.io.IOException;
-import java.util.Locale;
import java.util.List;
-import java.util.Iterator;
+import java.util.Locale;
/**
* Bundles the Javadoc documentation for <code>main Java code</code> in an <b>NON aggregator</b> project into
@@ -291,11 +290,10 @@ public class JavadocJar
archiver.getArchiver().addDirectory( contentDirectory, DEFAULT_INCLUDES, DEFAULT_EXCLUDES );
}
- List resources = project.getBuild().getResources();
+ List<Resource> resources = project.getBuild().getResources();
- for ( Iterator i = resources.iterator(); i.hasNext(); )
+ for ( Resource r : resources )
{
- Resource r = (Resource) i.next();
if ( r.getDirectory().endsWith( "maven-shared-archive-resources" ) )
{
archiver.getArchiver().addDirectory( new File( r.getDirectory() ) );
Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java?rev=985751&r1=985750&r2=985751&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocReport.java Sun Aug 15 20:50:00 2010
@@ -206,8 +206,8 @@ public class JavadocReport
if ( !this.isAggregator() || ( this.isAggregator() && this.project.isExecutionRoot() ) )
{
- List sourcePaths;
- List files;
+ List<String> sourcePaths;
+ List<String> files;
try
{
sourcePaths = getSourcePaths();
Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java?rev=985751&r1=985750&r2=985751&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/JavadocUtil.java Sun Aug 15 20:50:00 2010
@@ -37,7 +37,6 @@ import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.NoSuchElementException;
@@ -182,15 +181,15 @@ public class JavadocUtil
* @param excludedPackages the package names to be excluded in the javadoc
* @return a List of the source files to be excluded in the generated javadoc
*/
- protected static List getExcludedNames( List sourcePaths, String[] subpackagesList, String[] excludedPackages )
+ protected static List<String> getExcludedNames( List<String> sourcePaths, String[] subpackagesList,
+ String[] excludedPackages )
{
- List excludedNames = new ArrayList();
- for ( Iterator i = sourcePaths.iterator(); i.hasNext(); )
+ List<String> excludedNames = new ArrayList<String>();
+ for ( String path : sourcePaths )
{
- String path = (String) i.next();
for ( int j = 0; j < subpackagesList.length; j++ )
{
- List excludes = getExcludedPackages( path, excludedPackages );
+ List<String> excludes = getExcludedPackages( path, excludedPackages );
excludedNames.addAll( excludes );
}
}
@@ -204,7 +203,7 @@ public class JavadocUtil
* @return list of compile artifacts with compile scope
* @deprecated since 2.5, using {@link #getCompileArtifacts(Set, boolean)} instead of.
*/
- protected static List getCompileArtifacts( Set artifacts )
+ protected static List<Artifact> getCompileArtifacts( Set<Artifact> artifacts )
{
return getCompileArtifacts( artifacts, false );
}
@@ -215,14 +214,12 @@ public class JavadocUtil
* @param withTestScope flag to include or not the artifacts with test scope
* @return list of compile artifacts with or without test scope.
*/
- protected static List getCompileArtifacts( Set artifacts, boolean withTestScope )
+ protected static List<Artifact> getCompileArtifacts( Set<Artifact> artifacts, boolean withTestScope )
{
- List list = new ArrayList( artifacts.size() );
+ List<Artifact> list = new ArrayList<Artifact>( artifacts.size() );
- for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+ for ( Artifact a : artifacts )
{
- Artifact a = (Artifact) i.next();
-
// TODO: classpath check doesn't belong here - that's the other method
if ( a.getArtifactHandler().isAddedToClasspath() )
{
@@ -349,7 +346,7 @@ public class JavadocUtil
return;
}
- List excludes = new ArrayList();
+ List<String> excludes = new ArrayList<String>();
excludes.addAll( Arrays.asList( FileUtils.getDefaultExcludes() ) );
if ( StringUtils.isNotEmpty( excludedocfilessubdir ) )
@@ -363,22 +360,20 @@ public class JavadocUtil
}
}
- List docFiles =
+ List<String> docFiles =
FileUtils.getDirectoryNames( javadocDir, "resources,**/doc-files",
StringUtils.join( excludes.iterator(), "," ), false, true );
- for ( Iterator it = docFiles.iterator(); it.hasNext(); )
+ for ( String docFile : docFiles )
{
- String docFile = (String) it.next();
-
File docFileOutput = new File( outputDirectory, docFile );
FileUtils.mkdir( docFileOutput.getAbsolutePath() );
FileUtils.copyDirectoryStructure( new File( javadocDir, docFile ), docFileOutput );
- List files =
+ List<String> files =
FileUtils.getFileAndDirectoryNames( docFileOutput, StringUtils.join( excludes.iterator(), "," ),
null, true, true, true, true );
- for ( Iterator it2 = files.iterator(); it2.hasNext(); )
+ for ( String filename : files )
{
- File file = new File( it2.next().toString() );
+ File file = new File( filename );
if ( file.isDirectory() )
{
@@ -401,9 +396,9 @@ public class JavadocUtil
* @param excludePackages package names to be excluded in the javadoc
* @return a StringBuffer that contains the appended file names of the files to be included in the javadoc
*/
- protected static List getIncludedFiles( File sourceDirectory, String[] fileList, String[] excludePackages )
+ protected static List<String> getIncludedFiles( File sourceDirectory, String[] fileList, String[] excludePackages )
{
- List files = new ArrayList();
+ List<String> files = new ArrayList<String>();
for ( int j = 0; j < fileList.length; j++ )
{
@@ -475,9 +470,9 @@ public class JavadocUtil
* @param excludePackagenames package names to be excluded in the javadoc
* @return a List of the packagenames to be excluded
*/
- protected static List getExcludedPackages( String sourceDirectory, String[] excludePackagenames )
+ protected static List<String> getExcludedPackages( String sourceDirectory, String[] excludePackagenames )
{
- List files = new ArrayList();
+ List<String> files = new ArrayList<String>();
for ( int i = 0; i < excludePackagenames.length; i++ )
{
String[] fileList = FileUtils.getFilesFromExtension( sourceDirectory, new String[] { "java" } );
@@ -497,10 +492,9 @@ public class JavadocUtil
}
}
- List excluded = new ArrayList();
- for ( Iterator it = files.iterator(); it.hasNext(); )
+ List<String> excluded = new ArrayList<String>();
+ for ( String file : files )
{
- String file = (String) it.next();
int idx = file.lastIndexOf( File.separatorChar );
String tmpStr = file.substring( 0, idx );
tmpStr = tmpStr.replace( '\\', '/' );
@@ -523,12 +517,12 @@ public class JavadocUtil
* @param files the variable that contains the appended filenames of the files to be included in the javadoc
* @param excludePackages the packages to be excluded in the javadocs
*/
- protected static void addFilesFromSource( List files, File sourceDirectory, String[] excludePackages )
+ protected static void addFilesFromSource( List<String> files, File sourceDirectory, String[] excludePackages )
{
String[] fileList = FileUtils.getFilesFromExtension( sourceDirectory.getPath(), new String[] { "java" } );
if ( fileList != null && fileList.length != 0 )
{
- List tmpFiles = getIncludedFiles( sourceDirectory, fileList, excludePackages );
+ List<String> tmpFiles = getIncludedFiles( sourceDirectory, fileList, excludePackages );
files.addAll( tmpFiles );
}
}
@@ -899,10 +893,10 @@ public class JavadocUtil
* @throws ClassNotFoundException if any
* @throws NoClassDefFoundError if any
*/
- protected static List getTagletClassNames( File jarFile )
+ protected static List<String> getTagletClassNames( File jarFile )
throws IOException, ClassNotFoundException, NoClassDefFoundError
{
- List classes = getClassNamesFromJar( jarFile );
+ List<String> classes = getClassNamesFromJar( jarFile );
ClassLoader cl;
// Needed to find com.sun.tools.doclets.Taglet class
@@ -916,14 +910,12 @@ public class JavadocUtil
cl = new URLClassLoader( new URL[] { jarFile.toURI().toURL() }, null );
}
- List tagletClasses = new ArrayList();
+ List<String> tagletClasses = new ArrayList<String>();
- Class tagletClass = cl.loadClass( "com.sun.tools.doclets.Taglet" );
- for ( Iterator it = classes.iterator(); it.hasNext(); )
+ Class<?> tagletClass = cl.loadClass( "com.sun.tools.doclets.Taglet" );
+ for ( String s : classes )
{
- String s = (String) it.next();
-
- Class c = cl.loadClass( s );
+ Class<?> c = cl.loadClass( s );
if ( tagletClass.isAssignableFrom( c ) && !Modifier.isAbstract( c.getModifiers() ) )
{
@@ -996,7 +988,7 @@ public class JavadocUtil
* @throws MavenInvocationException if any
* @since 2.6
*/
- protected static void invokeMaven( Log log, File localRepositoryDir, File projectFile, List goals,
+ protected static void invokeMaven( Log log, File localRepositoryDir, File projectFile, List<String> goals,
Properties properties, File invokerLog )
throws MavenInvocationException
{
@@ -1148,14 +1140,14 @@ public class JavadocUtil
return null;
}
- List subpaths = new ArrayList();
+ List<String> subpaths = new ArrayList<String>();
PathTokenizer pathTokenizer = new PathTokenizer( path );
while ( pathTokenizer.hasMoreTokens() )
{
subpaths.add( pathTokenizer.nextToken() );
}
- return (String[]) subpaths.toArray( new String[0] );
+ return subpaths.toArray( new String[subpaths.size()] );
}
/**
@@ -1193,7 +1185,7 @@ public class JavadocUtil
* @return all class names from the given jar file.
* @throws IOException if any or if the jarFile is null or doesn't exist.
*/
- private static List getClassNamesFromJar( File jarFile )
+ private static List<String> getClassNamesFromJar( File jarFile )
throws IOException
{
if ( jarFile == null || !jarFile.exists() || !jarFile.isFile() )
@@ -1201,7 +1193,7 @@ public class JavadocUtil
throw new IOException( "The jar '" + jarFile + "' doesn't exist or is not a file." );
}
- List classes = new ArrayList();
+ List<String> classes = new ArrayList<String>();
JarInputStream jarStream = null;
try
@@ -1210,11 +1202,6 @@ public class JavadocUtil
JarEntry jarEntry = jarStream.getNextJarEntry();
while ( jarEntry != null )
{
- if ( jarEntry == null )
- {
- break;
- }
-
if ( jarEntry.getName().toLowerCase( Locale.ENGLISH ).endsWith( ".class" ) )
{
String name = jarEntry.getName().substring( 0, jarEntry.getName().indexOf( "." ) );
@@ -1247,7 +1234,7 @@ public class JavadocUtil
* @since 2.6
*/
private static InvocationResult invoke( Log log, Invoker invoker, InvocationRequest request, File invokerLog,
- List goals, Properties properties, String mavenOpts )
+ List<String> goals, Properties properties, String mavenOpts )
throws MavenInvocationException
{
PrintStream ps;
Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestFixJavadocMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestFixJavadocMojo.java?rev=985751&r1=985750&r2=985751&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestFixJavadocMojo.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestFixJavadocMojo.java Sun Aug 15 20:50:00 2010
@@ -43,18 +43,18 @@ public class TestFixJavadocMojo
extends AbstractFixJavadocMojo
{
/** {@inheritDoc} */
- protected List getProjectSourceRoots( MavenProject p )
+ protected List<String> getProjectSourceRoots( MavenProject p )
{
return ( p.getTestCompileSourceRoots() == null ? Collections.EMPTY_LIST
- : new LinkedList( p.getTestCompileSourceRoots() ) );
+ : new LinkedList<String>( p.getTestCompileSourceRoots() ) );
}
/** {@inheritDoc} */
- protected List getCompileClasspathElements( MavenProject p )
+ protected List<String> getCompileClasspathElements( MavenProject p )
throws DependencyResolutionRequiredException
{
return ( p.getTestClasspathElements() == null ? Collections.EMPTY_LIST
- : new LinkedList( p.getTestClasspathElements() ) );
+ : new LinkedList<String>( p.getTestClasspathElements() ) );
}
/** {@inheritDoc} */
Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestJavadocJar.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestJavadocJar.java?rev=985751&r1=985750&r2=985751&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestJavadocJar.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestJavadocJar.java Sun Aug 15 20:50:00 2010
@@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.plugin.javadoc.resolver.SourceResolverConfig;
import org.apache.maven.project.MavenProject;
@@ -152,9 +153,9 @@ public class TestJavadocJar
}
/** {@inheritDoc} */
- protected List getProjectBuildOutputDirs( MavenProject p )
+ protected List<String> getProjectBuildOutputDirs( MavenProject p )
{
- List dirs = new ArrayList();
+ List<String> dirs = new ArrayList<String>();
if ( StringUtils.isNotEmpty( p.getBuild().getOutputDirectory() ) )
{
dirs.add( p.getBuild().getOutputDirectory() );
@@ -168,35 +169,35 @@ public class TestJavadocJar
}
/** {@inheritDoc} */
- protected List getProjectSourceRoots( MavenProject p )
+ protected List<String> getProjectSourceRoots( MavenProject p )
{
if ( "pom".equals( p.getPackaging().toLowerCase() ) )
{
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
return p.getTestCompileSourceRoots();
}
/** {@inheritDoc} */
- protected List getExecutionProjectSourceRoots( MavenProject p )
+ protected List<String> getExecutionProjectSourceRoots( MavenProject p )
{
if ( "pom".equals( p.getExecutionProject().getPackaging().toLowerCase() ) )
{
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
return p.getExecutionProject().getTestCompileSourceRoots();
}
/** {@inheritDoc} */
- protected List getProjectArtifacts( MavenProject p )
+ protected List<Artifact> getProjectArtifacts( MavenProject p )
{
return p.getTestArtifacts();
}
/** {@inheritDoc} */
- protected List getCompileArtifacts( ArtifactResolutionResult result )
+ protected List<Artifact> getCompileArtifacts( ArtifactResolutionResult result )
{
return JavadocUtil.getCompileArtifacts( result.getArtifacts(), true );
}
Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestJavadocReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestJavadocReport.java?rev=985751&r1=985750&r2=985751&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestJavadocReport.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/TestJavadocReport.java Sun Aug 15 20:50:00 2010
@@ -27,6 +27,7 @@ import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
+import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.plugin.javadoc.resolver.SourceResolverConfig;
import org.apache.maven.project.MavenProject;
@@ -233,9 +234,9 @@ public class TestJavadocReport
// ----------------------------------------------------------------------
/** {@inheritDoc} */
- protected List getProjectBuildOutputDirs( MavenProject p )
+ protected List<String> getProjectBuildOutputDirs( MavenProject p )
{
- List dirs = new ArrayList();
+ List<String> dirs = new ArrayList<String>();
if ( StringUtils.isNotEmpty( p.getBuild().getOutputDirectory() ) )
{
dirs.add( p.getBuild().getOutputDirectory() );
@@ -249,33 +250,34 @@ public class TestJavadocReport
}
/** {@inheritDoc} */
- protected List getProjectSourceRoots( MavenProject p )
+ protected List<String> getProjectSourceRoots( MavenProject p )
{
if ( "pom".equals( p.getPackaging().toLowerCase() ) )
{
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
return ( p.getTestCompileSourceRoots() == null ? Collections.EMPTY_LIST
- : new LinkedList( p.getTestCompileSourceRoots() ) );
+ : new LinkedList<String>( p.getTestCompileSourceRoots() ) );
}
/** {@inheritDoc} */
- protected List getExecutionProjectSourceRoots( MavenProject p )
+ protected List<String> getExecutionProjectSourceRoots( MavenProject p )
{
if ( "pom".equals( p.getExecutionProject().getPackaging().toLowerCase() ) )
{
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
return ( p.getExecutionProject().getTestCompileSourceRoots() == null ? Collections.EMPTY_LIST
- : new LinkedList( p.getExecutionProject().getTestCompileSourceRoots() ) );
+ : new LinkedList<String>( p.getExecutionProject().getTestCompileSourceRoots() ) );
}
/** {@inheritDoc} */
- protected List getProjectArtifacts( MavenProject p )
+ protected List<Artifact> getProjectArtifacts( MavenProject p )
{
- return ( p.getTestArtifacts() == null ? Collections.EMPTY_LIST : new LinkedList( p.getTestArtifacts() ) );
+ return ( p.getTestArtifacts() == null ? Collections.EMPTY_LIST
+ : new LinkedList<Artifact>( p.getTestArtifacts() ) );
}
/** {@inheritDoc} */
@@ -303,7 +305,7 @@ public class TestJavadocReport
}
/** {@inheritDoc} */
- protected List getCompileArtifacts( ArtifactResolutionResult result )
+ protected List<Artifact> getCompileArtifacts( ArtifactResolutionResult result )
{
return JavadocUtil.getCompileArtifacts( result.getArtifacts(), true );
}