[MPLUGIN-184] Upgrade to JDK5
Submitted by: Robert Scholte o Applied with one change (upgraded surefire version from 2.4.3 to 2.8.1) o All integration tests still passing on my machine git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1133707 13f79535-47bb-0310-9956-ffa450edef68master
parent
6c63ab9110
commit
065a85cc28
|
|
@ -212,6 +212,15 @@
|
|||
<stagingSiteURL>scp://people.apache.org/www/maven.apache.org/plugins/${project.artifactId}-${project.version}</stagingSiteURL>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.modello</groupId>
|
||||
<artifactId>modello-maven-plugin</artifactId>
|
||||
|
|
@ -227,6 +236,7 @@
|
|||
<models>
|
||||
<model>src/main/mdo/pluginRequirements.mdo</model>
|
||||
</models>
|
||||
<useJava5>true</useJava5>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public abstract class AbstractGeneratorMojo
|
|||
*
|
||||
* @parameter
|
||||
*/
|
||||
protected Set/* <String> */extractors;
|
||||
protected Set<String> extractors;
|
||||
|
||||
/**
|
||||
* @return the output directory where files will be generated.
|
||||
|
|
|
|||
|
|
@ -325,9 +325,10 @@ public class PluginReport
|
|||
|
||||
|
||||
boolean hasMavenReport = false;
|
||||
for ( Iterator i = pluginDescriptor.getMojos().iterator(); i.hasNext(); )
|
||||
for ( @SuppressWarnings( "unchecked" )
|
||||
Iterator<MojoDescriptor> i = pluginDescriptor.getMojos().iterator(); i.hasNext(); )
|
||||
{
|
||||
MojoDescriptor mojo = (MojoDescriptor) i.next();
|
||||
MojoDescriptor mojo = i.next();
|
||||
|
||||
if ( PluginUtils.isMavenReport( mojo.getImplementation(), project ) )
|
||||
{
|
||||
|
|
@ -349,13 +350,11 @@ public class PluginReport
|
|||
tableHeader( new String[] { goalColumnName, descriptionColumnName } );
|
||||
}
|
||||
|
||||
List mojos = new ArrayList();
|
||||
List<MojoDescriptor> mojos = new ArrayList<MojoDescriptor>();
|
||||
mojos.addAll( pluginDescriptor.getMojos() );
|
||||
PluginUtils.sortMojos( mojos );
|
||||
for ( Iterator i = mojos.iterator(); i.hasNext(); )
|
||||
for ( MojoDescriptor mojo : mojos )
|
||||
{
|
||||
MojoDescriptor mojo = (MojoDescriptor) i.next();
|
||||
|
||||
String goalName = mojo.getFullGoalName();
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -19,6 +19,13 @@ package org.apache.maven.tools.plugin.extractor.ant;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.Parameter;
|
||||
|
|
@ -32,14 +39,6 @@ import org.apache.maven.tools.plugin.extractor.ExtractionException;
|
|||
import org.codehaus.plexus.component.repository.ComponentRequirement;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Extracts Mojo descriptors from <a href="http://ant.apache.org">Ant</a> sources.
|
||||
*
|
||||
|
|
@ -55,25 +54,21 @@ public class AntMojoDescriptorExtractor
|
|||
private static final String SCRIPT_FILE_EXTENSION = ".build.xml";
|
||||
|
||||
/** {@inheritDoc} */
|
||||
protected List extractMojoDescriptorsFromMetadata( Map metadataFilesKeyedByBasedir,
|
||||
protected List<MojoDescriptor> extractMojoDescriptorsFromMetadata( Map<String, Set<File>> metadataFilesKeyedByBasedir,
|
||||
PluginToolsRequest request )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
List descriptors = new ArrayList();
|
||||
List<MojoDescriptor> descriptors = new ArrayList<MojoDescriptor>();
|
||||
|
||||
PluginMetadataParser parser = new PluginMetadataParser();
|
||||
|
||||
for ( Iterator mapIterator = metadataFilesKeyedByBasedir.entrySet().iterator(); mapIterator.hasNext(); )
|
||||
for ( Map.Entry<String, Set<File>> entry : metadataFilesKeyedByBasedir.entrySet() )
|
||||
{
|
||||
Map.Entry entry = (Map.Entry) mapIterator.next();
|
||||
|
||||
String basedir = (String) entry.getKey();
|
||||
Set metadataFiles = (Set) entry.getValue();
|
||||
Set<File> metadataFiles = entry.getValue();
|
||||
|
||||
for ( Iterator it = metadataFiles.iterator(); it.hasNext(); )
|
||||
for ( File metadataFile : metadataFiles )
|
||||
{
|
||||
File metadataFile = (File) it.next();
|
||||
|
||||
String basename = metadataFile.getName();
|
||||
basename = basename.substring( 0, basename.length() - METADATA_FILE_EXTENSION.length() );
|
||||
|
||||
|
|
@ -97,14 +92,12 @@ public class AntMojoDescriptorExtractor
|
|||
|
||||
try
|
||||
{
|
||||
Set mojoDescriptors = parser.parseMojoDescriptors( metadataFile );
|
||||
Set<MojoDescriptor> mojoDescriptors = parser.parseMojoDescriptors( metadataFile );
|
||||
|
||||
for ( Iterator discoveredMojoIterator = mojoDescriptors.iterator(); discoveredMojoIterator
|
||||
.hasNext(); )
|
||||
for ( MojoDescriptor descriptor : mojoDescriptors )
|
||||
{
|
||||
MojoDescriptor descriptor = (MojoDescriptor) discoveredMojoIterator.next();
|
||||
|
||||
Map paramMap = descriptor.getParameterMap();
|
||||
@SuppressWarnings( "unchecked" )
|
||||
Map<String, ?> paramMap = descriptor.getParameterMap();
|
||||
|
||||
if ( !paramMap.containsKey( "basedir" ) )
|
||||
{
|
||||
|
|
@ -175,15 +168,14 @@ public class AntMojoDescriptorExtractor
|
|||
descriptor.addParameter( param );
|
||||
}
|
||||
|
||||
List requirements = descriptor.getRequirements();
|
||||
Map reqMap = new HashMap();
|
||||
@SuppressWarnings( "unchecked" )
|
||||
List<ComponentRequirement> requirements = descriptor.getRequirements();
|
||||
Map<String, ComponentRequirement> reqMap = new HashMap<String, ComponentRequirement>();
|
||||
|
||||
if ( requirements != null )
|
||||
{
|
||||
for ( Iterator reqIterator = requirements.iterator(); reqIterator.hasNext(); )
|
||||
for ( ComponentRequirement req : requirements )
|
||||
{
|
||||
ComponentRequirement req = (ComponentRequirement) reqIterator.next();
|
||||
|
||||
reqMap.put( req.getRole(), req );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,16 @@ package org.apache.maven.tools.plugin.extractor;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
||||
|
|
@ -29,15 +38,6 @@ import org.codehaus.plexus.util.DirectoryScanner;
|
|||
import org.codehaus.plexus.util.FileUtils;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* @author jdcasey
|
||||
* @version $Id$
|
||||
|
|
@ -47,14 +47,14 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
implements MojoDescriptorExtractor
|
||||
{
|
||||
/** {@inheritDoc} */
|
||||
public List execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
public List<MojoDescriptor> execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
return execute( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public List execute( PluginToolsRequest request )
|
||||
public List<MojoDescriptor> execute( PluginToolsRequest request )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
getLogger().debug( "Running: " + getClass().getName() );
|
||||
|
|
@ -63,13 +63,15 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
|
||||
MavenProject project = request.getProject();
|
||||
|
||||
Map scriptFilesKeyedByBasedir =
|
||||
@SuppressWarnings( "unchecked" )
|
||||
Map<String, Set<File>> scriptFilesKeyedByBasedir =
|
||||
gatherFilesByBasedir( project.getBasedir(), project.getScriptSourceRoots(), scriptExtension, request );
|
||||
|
||||
List mojoDescriptors;
|
||||
List<MojoDescriptor> mojoDescriptors;
|
||||
if ( !StringUtils.isEmpty( metadataExtension ) )
|
||||
{
|
||||
Map metadataFilesKeyedByBasedir =
|
||||
@SuppressWarnings( "unchecked" )
|
||||
Map<String, Set<File>> metadataFilesKeyedByBasedir =
|
||||
gatherFilesByBasedir( project.getBasedir(), project.getScriptSourceRoots(), metadataExtension,
|
||||
request );
|
||||
|
||||
|
|
@ -90,8 +92,7 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
* @param outputDirectory not null
|
||||
* @throws ExtractionException if any
|
||||
*/
|
||||
protected void copyScriptsToOutputDirectory( Map scriptFilesKeyedByBasedir, String outputDirectory,
|
||||
PluginToolsRequest request )
|
||||
protected void copyScriptsToOutputDirectory( Map<String, Set<File>> scriptFilesKeyedByBasedir, String outputDirectory, PluginToolsRequest request )
|
||||
throws ExtractionException
|
||||
{
|
||||
File outputDir = new File( outputDirectory );
|
||||
|
|
@ -101,18 +102,14 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
outputDir.mkdirs();
|
||||
}
|
||||
|
||||
for ( Iterator it = scriptFilesKeyedByBasedir.entrySet().iterator(); it.hasNext(); )
|
||||
for ( Map.Entry<String, Set<File>> entry : scriptFilesKeyedByBasedir.entrySet() )
|
||||
{
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
File sourceDir = new File( entry.getKey() );
|
||||
|
||||
File sourceDir = new File( (String) entry.getKey() );
|
||||
Set<File> scripts = entry.getValue();
|
||||
|
||||
Set scripts = (Set) entry.getValue();
|
||||
|
||||
for ( Iterator scriptIterator = scripts.iterator(); scriptIterator.hasNext(); )
|
||||
for ( File scriptFile : scripts )
|
||||
{
|
||||
File scriptFile = (File) scriptIterator.next();
|
||||
|
||||
String relativePath = scriptFile.getPath().substring( sourceDir.getPath().length() );
|
||||
|
||||
if ( relativePath.charAt( 0 ) == File.separatorChar )
|
||||
|
|
@ -146,16 +143,13 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
* @param scriptFileExtension not null
|
||||
* @return map with subdirs paths as key
|
||||
*/
|
||||
protected Map gatherFilesByBasedir( File basedir, List directories, String scriptFileExtension,
|
||||
PluginToolsRequest request )
|
||||
protected Map<String, Set<File>> gatherFilesByBasedir( File basedir, List<String> directories, String scriptFileExtension, PluginToolsRequest request )
|
||||
{
|
||||
Map sourcesByBasedir = new TreeMap();
|
||||
Map<String, Set<File>> sourcesByBasedir = new TreeMap<String, Set<File>>();
|
||||
|
||||
for ( Iterator it = directories.iterator(); it.hasNext(); )
|
||||
for ( String resourceDir : directories )
|
||||
{
|
||||
Set sources = new HashSet();
|
||||
|
||||
String resourceDir = (String) it.next();
|
||||
Set<File> sources = new HashSet<File>();
|
||||
|
||||
getLogger().debug( "Scanning script dir: " + resourceDir + " with extractor: " + getClass().getName() );
|
||||
File dir = new File( resourceDir );
|
||||
|
|
@ -204,7 +198,7 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
* @throws ExtractionException if any
|
||||
* @throws InvalidPluginDescriptorException if any
|
||||
*/
|
||||
protected List extractMojoDescriptorsFromMetadata( Map metadataFilesKeyedByBasedir,
|
||||
protected List<MojoDescriptor> extractMojoDescriptorsFromMetadata( Map<String, Set<File>> metadataFilesKeyedByBasedir,
|
||||
PluginToolsRequest request )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
|
|
@ -230,7 +224,7 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
* @throws ExtractionException if any
|
||||
* @throws InvalidPluginDescriptorException if any
|
||||
*/
|
||||
protected List extractMojoDescriptors( Map scriptFilesKeyedByBasedir, PluginToolsRequest request )
|
||||
protected List<MojoDescriptor> extractMojoDescriptors( Map<String, Set<File>> scriptFilesKeyedByBasedir, PluginToolsRequest request )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package org.apache.maven.tools.plugin.extractor;
|
|||
*/
|
||||
|
||||
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||
|
|
@ -46,7 +47,7 @@ public interface MojoDescriptorExtractor
|
|||
* @deprecated Use {@link MojoDescriptorExtractor#execute(PluginToolsRequest)} instead.
|
||||
* Provided for backward compatibility with maven-plugin-plugin < 2.5.
|
||||
*/
|
||||
List execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
List<MojoDescriptor> execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
throws ExtractionException, InvalidPluginDescriptorException;
|
||||
|
||||
/**
|
||||
|
|
@ -58,6 +59,6 @@ public interface MojoDescriptorExtractor
|
|||
* @throws InvalidPluginDescriptorException if any
|
||||
* @since 2.5
|
||||
*/
|
||||
List execute( PluginToolsRequest request )
|
||||
List<MojoDescriptor> execute( PluginToolsRequest request )
|
||||
throws ExtractionException, InvalidPluginDescriptorException;
|
||||
}
|
||||
|
|
@ -105,9 +105,10 @@ public class PluginDescriptorGenerator
|
|||
|
||||
if ( pluginDescriptor.getMojos() != null )
|
||||
{
|
||||
for ( Iterator it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
|
||||
for ( @SuppressWarnings( "unchecked" )
|
||||
Iterator<MojoDescriptor> it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
|
||||
{
|
||||
MojoDescriptor descriptor = (MojoDescriptor) it.next();
|
||||
MojoDescriptor descriptor = it.next();
|
||||
processMojoDescriptor( descriptor, w );
|
||||
}
|
||||
}
|
||||
|
|
@ -322,20 +323,19 @@ public class PluginDescriptorGenerator
|
|||
// Parameters
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
List parameters = mojoDescriptor.getParameters();
|
||||
@SuppressWarnings( "unchecked" )
|
||||
List<Parameter> parameters = mojoDescriptor.getParameters();
|
||||
|
||||
w.startElement( "parameters" );
|
||||
|
||||
Map requirements = new LinkedHashMap();
|
||||
Map<String, Requirement> requirements = new LinkedHashMap<String, Requirement>();
|
||||
|
||||
Set configuration = new LinkedHashSet();
|
||||
Set<Parameter> configuration = new LinkedHashSet<Parameter>();
|
||||
|
||||
if ( parameters != null )
|
||||
{
|
||||
for ( int j = 0; j < parameters.size(); j++ )
|
||||
for ( Parameter parameter : parameters )
|
||||
{
|
||||
Parameter parameter = (Parameter) parameters.get( j );
|
||||
|
||||
String expression = parameter.getExpression();
|
||||
|
||||
if ( StringUtils.isNotEmpty( expression ) && expression.startsWith( "${component." ) )
|
||||
|
|
@ -422,10 +422,8 @@ public class PluginDescriptorGenerator
|
|||
{
|
||||
w.startElement( "configuration" );
|
||||
|
||||
for ( Iterator i = configuration.iterator(); i.hasNext(); )
|
||||
for ( Parameter parameter : configuration )
|
||||
{
|
||||
Parameter parameter = (Parameter) i.next();
|
||||
|
||||
w.startElement( parameter.getName() );
|
||||
|
||||
String type = parameter.getType();
|
||||
|
|
@ -458,10 +456,10 @@ public class PluginDescriptorGenerator
|
|||
{
|
||||
w.startElement( "requirements" );
|
||||
|
||||
for ( Iterator i = requirements.keySet().iterator(); i.hasNext(); )
|
||||
for ( Map.Entry<String, Requirement> entry : requirements.entrySet() )
|
||||
{
|
||||
String key = (String) i.next();
|
||||
Requirement requirement = (Requirement) requirements.get( key );
|
||||
String key = entry.getKey();
|
||||
Requirement requirement = entry.getValue();
|
||||
|
||||
w.startElement( "requirement" );
|
||||
|
||||
|
|
|
|||
|
|
@ -103,9 +103,10 @@ public class PluginHelpGenerator
|
|||
MojoDescriptor helpDescriptor = makeHelpDescriptor( pluginDescriptor );
|
||||
|
||||
// Verify that no help goal already exists
|
||||
for ( Iterator it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
|
||||
for ( @SuppressWarnings( "unchecked" )
|
||||
Iterator<MojoDescriptor> it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
|
||||
{
|
||||
MojoDescriptor descriptor = (MojoDescriptor) it.next();
|
||||
MojoDescriptor descriptor = it.next();
|
||||
|
||||
if ( descriptor.getGoal().equals( helpDescriptor.getGoal() )
|
||||
&& !descriptor.getImplementation().equals( helpDescriptor.getImplementation() ) )
|
||||
|
|
@ -240,10 +241,11 @@ public class PluginHelpGenerator
|
|||
*/
|
||||
private static String discoverPackageName( PluginDescriptor pluginDescriptor )
|
||||
{
|
||||
Map packageNames = new HashMap();
|
||||
for ( Iterator it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
|
||||
Map<String, Integer> packageNames = new HashMap<String, Integer>();
|
||||
for ( @SuppressWarnings( "unchecked" )
|
||||
Iterator<MojoDescriptor> it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
|
||||
{
|
||||
MojoDescriptor descriptor = (MojoDescriptor) it.next();
|
||||
MojoDescriptor descriptor = it.next();
|
||||
|
||||
String impl = descriptor.getImplementation();
|
||||
if ( impl.lastIndexOf( '.' ) != -1 )
|
||||
|
|
@ -267,9 +269,8 @@ public class PluginHelpGenerator
|
|||
|
||||
String packageName = "";
|
||||
int max = 0;
|
||||
for ( Iterator it = packageNames.keySet().iterator(); it.hasNext(); )
|
||||
for ( String key : packageNames.keySet() )
|
||||
{
|
||||
String key = it.next().toString();
|
||||
int value = ( (Integer) packageNames.get( key ) ).intValue();
|
||||
if ( value > max )
|
||||
{
|
||||
|
|
@ -399,9 +400,10 @@ public class PluginHelpGenerator
|
|||
private static void writeVariables( Writer writer, MojoDescriptor helpDescriptor )
|
||||
throws IOException
|
||||
{
|
||||
for ( Iterator it = helpDescriptor.getParameters().iterator(); it.hasNext(); )
|
||||
for ( @SuppressWarnings( "unchecked" )
|
||||
Iterator<Parameter> it = helpDescriptor.getParameters().iterator(); it.hasNext(); )
|
||||
{
|
||||
Parameter param = (Parameter) it.next();
|
||||
Parameter param = it.next();
|
||||
writer.write( " /**" + LS );
|
||||
writer.write( " * " + StringUtils.escape( param.getDescription() ) + LS );
|
||||
writer.write( " * " + LS );
|
||||
|
|
@ -434,12 +436,13 @@ public class PluginHelpGenerator
|
|||
private static void writeExecute( Writer writer, PluginDescriptor pluginDescriptor, MojoDescriptor helpDescriptor )
|
||||
throws IOException
|
||||
{
|
||||
List mojoDescriptors = new ArrayList();
|
||||
List<MojoDescriptor> mojoDescriptors = new ArrayList<MojoDescriptor>();
|
||||
|
||||
mojoDescriptors.add( helpDescriptor );
|
||||
for ( Iterator it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
|
||||
for ( @SuppressWarnings( "unchecked" )
|
||||
Iterator<MojoDescriptor> it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
|
||||
{
|
||||
MojoDescriptor mojoDescriptor = (MojoDescriptor) it.next();
|
||||
MojoDescriptor mojoDescriptor = it.next();
|
||||
|
||||
if ( !helpDescriptor.getGoal().equals( mojoDescriptor.getGoal() ) )
|
||||
{
|
||||
|
|
@ -509,9 +512,9 @@ public class PluginHelpGenerator
|
|||
|
||||
writer.write( LS );
|
||||
|
||||
for ( Iterator it = mojoDescriptors.iterator(); it.hasNext(); )
|
||||
for ( Iterator<MojoDescriptor> it = mojoDescriptors.iterator(); it.hasNext(); )
|
||||
{
|
||||
MojoDescriptor descriptor = (MojoDescriptor) it.next();
|
||||
MojoDescriptor descriptor = it.next();
|
||||
|
||||
writeGoal( writer, descriptor );
|
||||
}
|
||||
|
|
@ -556,7 +559,8 @@ public class PluginHelpGenerator
|
|||
|
||||
if ( descriptor.getParameters() != null && descriptor.getParameters().size() > 0 )
|
||||
{
|
||||
List params = descriptor.getParameters();
|
||||
@SuppressWarnings( "unchecked" )
|
||||
List<Parameter> params = descriptor.getParameters();
|
||||
|
||||
PluginUtils.sortMojoParameters( params );
|
||||
|
||||
|
|
@ -566,10 +570,8 @@ public class PluginHelpGenerator
|
|||
writer.write( " append( sb, \"Available parameters:\", 1 );" + LS );
|
||||
writer.write( " append( sb, \"\", 0 );" + LS );
|
||||
|
||||
for ( Iterator it = params.iterator(); it.hasNext(); )
|
||||
for ( Parameter parameter : params )
|
||||
{
|
||||
Parameter parameter = (Parameter) it.next();
|
||||
|
||||
if ( parameter.isEditable() )
|
||||
{
|
||||
writer.write( LS );
|
||||
|
|
|
|||
|
|
@ -109,9 +109,10 @@ public class PluginXdocGenerator
|
|||
{
|
||||
if ( request.getPluginDescriptor().getMojos() != null )
|
||||
{
|
||||
for ( Iterator it = request.getPluginDescriptor().getMojos().iterator(); it.hasNext(); )
|
||||
for ( @SuppressWarnings( "unchecked" )
|
||||
Iterator<MojoDescriptor> it = request.getPluginDescriptor().getMojos().iterator(); it.hasNext(); )
|
||||
{
|
||||
MojoDescriptor descriptor = (MojoDescriptor) it.next();
|
||||
MojoDescriptor descriptor = it.next();
|
||||
|
||||
processMojoDescriptor( descriptor, destinationDirectory );
|
||||
}
|
||||
|
|
@ -442,10 +443,11 @@ public class PluginXdocGenerator
|
|||
*/
|
||||
private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w )
|
||||
{
|
||||
List parameterList = mojoDescriptor.getParameters();
|
||||
@SuppressWarnings( "unchecked" )
|
||||
List<Parameter> parameterList = mojoDescriptor.getParameters();
|
||||
|
||||
//remove components and read-only parameters
|
||||
List list = filterParameters( parameterList );
|
||||
List<Parameter> list = filterParameters( parameterList );
|
||||
|
||||
if ( list != null && list.size() > 0 )
|
||||
{
|
||||
|
|
@ -470,16 +472,14 @@ public class PluginXdocGenerator
|
|||
* @param parameterList not null
|
||||
* @return the parameters list without components.
|
||||
*/
|
||||
private List filterParameters( List parameterList )
|
||||
private List<Parameter> filterParameters( List<Parameter> parameterList )
|
||||
{
|
||||
List filtered = new ArrayList();
|
||||
List<Parameter> filtered = new ArrayList<Parameter>();
|
||||
|
||||
if ( parameterList != null )
|
||||
{
|
||||
for ( Iterator parameters = parameterList.iterator(); parameters.hasNext(); )
|
||||
for ( Parameter parameter : parameterList )
|
||||
{
|
||||
Parameter parameter = (Parameter) parameters.next();
|
||||
|
||||
if ( parameter.isEditable() )
|
||||
{
|
||||
String expression = parameter.getExpression();
|
||||
|
|
@ -500,14 +500,14 @@ public class PluginXdocGenerator
|
|||
* @param parameterList not null
|
||||
* @param w not null
|
||||
*/
|
||||
private void writeParameterDetails( MojoDescriptor mojoDescriptor, List parameterList, XMLWriter w )
|
||||
private void writeParameterDetails( MojoDescriptor mojoDescriptor, List<Parameter> parameterList, XMLWriter w )
|
||||
{
|
||||
w.startElement( "subsection" );
|
||||
w.addAttribute( "name", getString( "pluginxdoc.mojodescriptor.parameter.details" ) );
|
||||
|
||||
for ( Iterator parameters = parameterList.iterator(); parameters.hasNext(); )
|
||||
for ( Iterator<Parameter> parameters = parameterList.iterator(); parameters.hasNext(); )
|
||||
{
|
||||
Parameter parameter = (Parameter) parameters.next();
|
||||
Parameter parameter = parameters.next();
|
||||
|
||||
w.startElement( "p" );
|
||||
w.writeMarkup( format( "pluginxdoc.mojodescriptor.parameter.name_internal", parameter.getName() ) );
|
||||
|
|
@ -633,16 +633,16 @@ public class PluginXdocGenerator
|
|||
* @param parameterList not null
|
||||
* @param w not null
|
||||
*/
|
||||
private void writeParameterSummary( MojoDescriptor mojoDescriptor, List parameterList, XMLWriter w )
|
||||
private void writeParameterSummary( MojoDescriptor mojoDescriptor, List<Parameter> parameterList, XMLWriter w )
|
||||
{
|
||||
List requiredParams = getParametersByRequired( true, parameterList );
|
||||
List<Parameter> requiredParams = getParametersByRequired( true, parameterList );
|
||||
if ( requiredParams.size() > 0 )
|
||||
{
|
||||
writeParameterList( mojoDescriptor, getString( "pluginxdoc.mojodescriptor.requiredParameters" ),
|
||||
requiredParams, w );
|
||||
}
|
||||
|
||||
List optionalParams = getParametersByRequired( false, parameterList );
|
||||
List<Parameter> optionalParams = getParametersByRequired( false, parameterList );
|
||||
if ( optionalParams.size() > 0 )
|
||||
{
|
||||
writeParameterList( mojoDescriptor, getString( "pluginxdoc.mojodescriptor.optionalParameters" ),
|
||||
|
|
@ -656,7 +656,7 @@ public class PluginXdocGenerator
|
|||
* @param parameterList not null
|
||||
* @param w not null
|
||||
*/
|
||||
private void writeParameterList( MojoDescriptor mojoDescriptor, String title, List parameterList, XMLWriter w )
|
||||
private void writeParameterList( MojoDescriptor mojoDescriptor, String title, List<Parameter> parameterList, XMLWriter w )
|
||||
{
|
||||
w.startElement( "subsection" );
|
||||
w.addAttribute( "name", title );
|
||||
|
|
@ -679,10 +679,8 @@ public class PluginXdocGenerator
|
|||
w.endElement(); //th
|
||||
w.endElement(); //tr
|
||||
|
||||
for ( Iterator parameters = parameterList.iterator(); parameters.hasNext(); )
|
||||
for ( Parameter parameter : parameterList )
|
||||
{
|
||||
Parameter parameter = (Parameter) parameters.next();
|
||||
|
||||
w.startElement( "tr" );
|
||||
w.startElement( "td" );
|
||||
w.writeMarkup( format( "pluginxdoc.mojodescriptor.parameter.name_link", parameter.getName() ) );
|
||||
|
|
@ -744,14 +742,12 @@ public class PluginXdocGenerator
|
|||
* @param parameterList not null
|
||||
* @return list of parameters depending the value of <code>required</code>
|
||||
*/
|
||||
private List getParametersByRequired( boolean required, List parameterList )
|
||||
private List<Parameter> getParametersByRequired( boolean required, List<Parameter> parameterList )
|
||||
{
|
||||
List list = new ArrayList();
|
||||
List<Parameter> list = new ArrayList<Parameter>();
|
||||
|
||||
for ( Iterator parameters = parameterList.iterator(); parameters.hasNext(); )
|
||||
for ( Parameter parameter : parameterList )
|
||||
{
|
||||
Parameter parameter = (Parameter) parameters.next();
|
||||
|
||||
if ( parameter.isRequired() == required )
|
||||
{
|
||||
list.add( parameter );
|
||||
|
|
|
|||
|
|
@ -19,6 +19,11 @@ package org.apache.maven.tools.plugin.scanner;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
|
|
@ -31,12 +36,6 @@ import org.codehaus.plexus.logging.AbstractLogEnabled;
|
|||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.logging.console.ConsoleLogger;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author jdcasey
|
||||
*/
|
||||
|
|
@ -45,19 +44,19 @@ public class DefaultMojoScanner
|
|||
implements MojoScanner
|
||||
{
|
||||
|
||||
private Map mojoDescriptorExtractors;
|
||||
private Map<String, MojoDescriptorExtractor> mojoDescriptorExtractors;
|
||||
|
||||
/**
|
||||
* The names of the active extractors
|
||||
*/
|
||||
private Set/* <String> */activeExtractors;
|
||||
private Set<String> activeExtractors;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*
|
||||
* @param extractors not null
|
||||
*/
|
||||
public DefaultMojoScanner( Map extractors )
|
||||
public DefaultMojoScanner( Map<String, MojoDescriptorExtractor> extractors )
|
||||
{
|
||||
this.mojoDescriptorExtractors = extractors;
|
||||
|
||||
|
|
@ -84,15 +83,14 @@ public class DefaultMojoScanner
|
|||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
Logger logger = getLogger();
|
||||
Set activeExtractorsInternal = getActiveExtractors();
|
||||
Set<String> activeExtractorsInternal = getActiveExtractors();
|
||||
|
||||
logger.debug( "Using " + activeExtractorsInternal.size() + " mojo extractors." );
|
||||
|
||||
int numMojoDescriptors = 0;
|
||||
|
||||
for ( Iterator it = activeExtractorsInternal.iterator(); it.hasNext(); )
|
||||
for ( String language : activeExtractorsInternal )
|
||||
{
|
||||
String language = (String) it.next();
|
||||
MojoDescriptorExtractor extractor = (MojoDescriptorExtractor) mojoDescriptorExtractors.get( language );
|
||||
|
||||
if ( extractor == null )
|
||||
|
|
@ -102,16 +100,14 @@ public class DefaultMojoScanner
|
|||
|
||||
logger.info( "Applying mojo extractor for language: " + language );
|
||||
|
||||
List extractorDescriptors = extractor.execute( request );
|
||||
List<MojoDescriptor> extractorDescriptors = extractor.execute( request );
|
||||
|
||||
logger.info( "Mojo extractor for language: " + language + " found " + extractorDescriptors.size()
|
||||
+ " mojo descriptors." );
|
||||
numMojoDescriptors += extractorDescriptors.size();
|
||||
|
||||
for ( Iterator descriptorIt = extractorDescriptors.iterator(); descriptorIt.hasNext(); )
|
||||
for ( MojoDescriptor descriptor : extractorDescriptors )
|
||||
{
|
||||
MojoDescriptor descriptor = (MojoDescriptor) descriptorIt.next();
|
||||
|
||||
logger.debug( "Adding mojo: " + descriptor + " to plugin descriptor." );
|
||||
|
||||
descriptor.setPluginDescriptor( request.getPluginDescriptor() );
|
||||
|
|
@ -132,20 +128,19 @@ public class DefaultMojoScanner
|
|||
*
|
||||
* @return A Set containing the names of the active extractors.
|
||||
*/
|
||||
protected Set/* <String> */getActiveExtractors()
|
||||
protected Set<String> getActiveExtractors()
|
||||
{
|
||||
Set/* <String> */result = activeExtractors;
|
||||
Set<String> result = activeExtractors;
|
||||
|
||||
if ( result == null )
|
||||
{
|
||||
result = new HashSet/* <String> */( mojoDescriptorExtractors.keySet() );
|
||||
result = new HashSet<String>( mojoDescriptorExtractors.keySet() );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void setActiveExtractors( Set/* <String> */extractors )
|
||||
public void setActiveExtractors( Set<String> extractors )
|
||||
{
|
||||
if ( extractors == null )
|
||||
{
|
||||
|
|
@ -153,12 +148,10 @@ public class DefaultMojoScanner
|
|||
}
|
||||
else
|
||||
{
|
||||
this.activeExtractors = new HashSet/* <String> */();
|
||||
this.activeExtractors = new HashSet<String>();
|
||||
|
||||
for ( Iterator i = extractors.iterator(); i.hasNext(); )
|
||||
for ( String extractor : extractors )
|
||||
{
|
||||
String extractor = (String) i.next();
|
||||
|
||||
if ( extractor != null && extractor.length() > 0 )
|
||||
{
|
||||
this.activeExtractors.add( extractor );
|
||||
|
|
|
|||
|
|
@ -66,6 +66,6 @@ public interface MojoScanner
|
|||
* all the scanner's extractors are considered active. Set entries that are <code>null</code> or
|
||||
* empty ("") will be ignored.
|
||||
*/
|
||||
void setActiveExtractors( Set/* <String> */extractors );
|
||||
void setActiveExtractors( Set<String> extractors );
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,9 +114,10 @@ public final class PluginUtils
|
|||
{
|
||||
w.startElement( "dependencies" );
|
||||
|
||||
for ( Iterator it = pluginDescriptor.getDependencies().iterator(); it.hasNext(); )
|
||||
for ( @SuppressWarnings( "unchecked" )
|
||||
Iterator<ComponentDependency> it = pluginDescriptor.getDependencies().iterator(); it.hasNext(); )
|
||||
{
|
||||
ComponentDependency dep = (ComponentDependency) it.next();
|
||||
ComponentDependency dep = it.next();
|
||||
|
||||
w.startElement( "dependency" );
|
||||
|
||||
|
|
@ -138,14 +139,12 @@ public final class PluginUtils
|
|||
* @param dependencies not null list of <code>Dependency</code>
|
||||
* @return list of component dependencies
|
||||
*/
|
||||
public static List toComponentDependencies( List dependencies )
|
||||
public static List<ComponentDependency> toComponentDependencies( List<Dependency> dependencies )
|
||||
{
|
||||
List componentDeps = new LinkedList();
|
||||
List<ComponentDependency> componentDeps = new LinkedList<ComponentDependency>();
|
||||
|
||||
for ( Iterator it = dependencies.iterator(); it.hasNext(); )
|
||||
for ( Dependency dependency : dependencies )
|
||||
{
|
||||
Dependency dependency = (Dependency) it.next();
|
||||
|
||||
ComponentDependency cd = new ComponentDependency();
|
||||
|
||||
cd.setArtifactId( dependency.getArtifactId() );
|
||||
|
|
@ -196,7 +195,7 @@ public final class PluginUtils
|
|||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
||||
if ( project != null )
|
||||
{
|
||||
List classPathStrings;
|
||||
List<String> classPathStrings;
|
||||
try
|
||||
{
|
||||
classPathStrings = project.getCompileClasspathElements();
|
||||
|
|
@ -210,8 +209,8 @@ public final class PluginUtils
|
|||
throw (RuntimeException) new IllegalArgumentException().initCause( e );
|
||||
}
|
||||
|
||||
List urls = new ArrayList( classPathStrings.size() );
|
||||
for ( Iterator it = classPathStrings.iterator(); it.hasNext(); )
|
||||
List<URL> urls = new ArrayList<URL>( classPathStrings.size() );
|
||||
for ( Iterator<String> it = classPathStrings.iterator(); it.hasNext(); )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -227,7 +226,7 @@ public final class PluginUtils
|
|||
classLoader );
|
||||
}
|
||||
|
||||
Class clazz = null;
|
||||
Class<?> clazz = null;
|
||||
try
|
||||
{
|
||||
clazz = Class.forName( impl, false, classLoader );
|
||||
|
|
@ -417,17 +416,17 @@ public final class PluginUtils
|
|||
* @param mojoDescriptors The mojo descriptors to sort, may be <code>null</code>.
|
||||
* @see MojoDescriptor#getGoal()
|
||||
*/
|
||||
public static void sortMojos( List mojoDescriptors )
|
||||
public static void sortMojos( List<MojoDescriptor> mojoDescriptors )
|
||||
{
|
||||
if ( mojoDescriptors != null )
|
||||
{
|
||||
Collections.sort( mojoDescriptors, new Comparator()
|
||||
Collections.sort( mojoDescriptors, new Comparator<MojoDescriptor>()
|
||||
{
|
||||
/** {@inheritDoc} */
|
||||
public int compare( Object arg0, Object arg1 )
|
||||
public int compare( MojoDescriptor arg0, MojoDescriptor arg1 )
|
||||
{
|
||||
MojoDescriptor mojo0 = (MojoDescriptor) arg0;
|
||||
MojoDescriptor mojo1 = (MojoDescriptor) arg1;
|
||||
MojoDescriptor mojo0 = arg0;
|
||||
MojoDescriptor mojo1 = arg1;
|
||||
|
||||
return mojo0.getGoal().compareToIgnoreCase( mojo1.getGoal() );
|
||||
}
|
||||
|
|
@ -442,14 +441,14 @@ public final class PluginUtils
|
|||
* @see Parameter#getName()
|
||||
* @since 2.4.4
|
||||
*/
|
||||
public static void sortMojoParameters( List parameters )
|
||||
public static void sortMojoParameters( List<Parameter> parameters )
|
||||
{
|
||||
if ( parameters != null )
|
||||
{
|
||||
Collections.sort( parameters, new Comparator()
|
||||
Collections.sort( parameters, new Comparator<Parameter>()
|
||||
{
|
||||
/** {@inheritDoc} */
|
||||
public int compare( Object arg0, Object arg1 )
|
||||
public int compare( Parameter arg0, Parameter arg1 )
|
||||
{
|
||||
Parameter parameter1 = (Parameter) arg0;
|
||||
Parameter parameter2 = (Parameter) arg1;
|
||||
|
|
@ -534,7 +533,7 @@ public final class PluginUtils
|
|||
* A stack of {@link Counter} objects corresponding to the nesting of (un-)ordered lists. A
|
||||
* <code>null</code> element denotes an unordered list.
|
||||
*/
|
||||
private Stack numbering = new Stack();
|
||||
private Stack<Counter> numbering = new Stack<Counter>();
|
||||
|
||||
/**
|
||||
* A flag whether an implicit line break is pending in the output buffer. This flag is used to postpone the
|
||||
|
|
|
|||
|
|
@ -19,21 +19,20 @@ package org.apache.maven.tools.plugin.extractor.beanshell;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||
import org.apache.maven.tools.plugin.extractor.AbstractScriptedMojoDescriptorExtractor;
|
||||
import org.apache.maven.tools.plugin.extractor.ExtractionException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import bsh.EvalError;
|
||||
import bsh.Interpreter;
|
||||
|
||||
|
|
@ -56,22 +55,18 @@ public class BeanshellMojoDescriptorExtractor
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
protected List extractMojoDescriptors( Map scriptFilesKeyedByBasedir, PluginToolsRequest request )
|
||||
protected List<MojoDescriptor> extractMojoDescriptors( Map<String, Set<File>> scriptFilesKeyedByBasedir, PluginToolsRequest request )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
List descriptors = new ArrayList();
|
||||
List<MojoDescriptor> descriptors = new ArrayList<MojoDescriptor>();
|
||||
|
||||
for ( Iterator mapIterator = scriptFilesKeyedByBasedir.entrySet().iterator(); mapIterator.hasNext(); )
|
||||
for ( Map.Entry<String, Set<File>> entry : scriptFilesKeyedByBasedir.entrySet() )
|
||||
{
|
||||
Map.Entry entry = (Map.Entry) mapIterator.next();
|
||||
String basedir = entry.getKey();
|
||||
Set<File> metadataFiles = entry.getValue();
|
||||
|
||||
String basedir = (String) entry.getKey();
|
||||
Set metadataFiles = (Set) entry.getValue();
|
||||
|
||||
for ( Iterator it = metadataFiles.iterator(); it.hasNext(); )
|
||||
for ( File scriptFile : metadataFiles )
|
||||
{
|
||||
File scriptFile = (File) it.next();
|
||||
|
||||
String relativePath = null;
|
||||
|
||||
if ( basedir.endsWith( "/" ) )
|
||||
|
|
|
|||
|
|
@ -454,13 +454,11 @@ public class JavaMojoDescriptorExtractor
|
|||
// We're resolving class-level, ancestor-class-field, local-class-field order here.
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
Map rawParams = extractFieldParameterTags( javaClass );
|
||||
Map<String, JavaField> rawParams = extractFieldParameterTags( javaClass );
|
||||
|
||||
for ( Iterator it = rawParams.entrySet().iterator(); it.hasNext(); )
|
||||
for ( Map.Entry<String, JavaField> entry : rawParams.entrySet() )
|
||||
{
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
|
||||
JavaField field = (JavaField) entry.getValue();
|
||||
JavaField field = entry.getValue();
|
||||
|
||||
Type type = field.getType();
|
||||
|
||||
|
|
@ -506,7 +504,7 @@ public class JavaMojoDescriptorExtractor
|
|||
|
||||
pd.setRequirement( new Requirement( role, roleHint ) );
|
||||
|
||||
pd.setName( (String) entry.getKey() );
|
||||
pd.setName( entry.getKey() );
|
||||
|
||||
pd.setEditable( false );
|
||||
/* TODO: or better like this? Need @component fields be editable for the user?
|
||||
|
|
@ -535,7 +533,7 @@ public class JavaMojoDescriptorExtractor
|
|||
}
|
||||
else
|
||||
{
|
||||
pd.setName( (String) entry.getKey() );
|
||||
pd.setName( entry.getKey() );
|
||||
}
|
||||
|
||||
pd.setRequired( field.getTagByName( JavaMojoAnnotation.REQUIRED ) != null );
|
||||
|
|
@ -593,9 +591,9 @@ public class JavaMojoDescriptorExtractor
|
|||
* @param javaClass not null
|
||||
* @return map with Mojo parameters names as keys
|
||||
*/
|
||||
private Map extractFieldParameterTags( JavaClass javaClass )
|
||||
private Map<String, JavaField> extractFieldParameterTags( JavaClass javaClass )
|
||||
{
|
||||
Map rawParams;
|
||||
Map<String, JavaField> rawParams;
|
||||
|
||||
// we have to add the parent fields first, so that they will be overwritten by the local fields if
|
||||
// that actually happens...
|
||||
|
|
@ -607,7 +605,7 @@ public class JavaMojoDescriptorExtractor
|
|||
}
|
||||
else
|
||||
{
|
||||
rawParams = new TreeMap();
|
||||
rawParams = new TreeMap<String, JavaField>();
|
||||
}
|
||||
|
||||
JavaField[] classFields = javaClass.getFields();
|
||||
|
|
@ -629,19 +627,19 @@ public class JavaMojoDescriptorExtractor
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public List execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
public List<MojoDescriptor> execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
return execute( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public List execute( PluginToolsRequest request )
|
||||
public List<MojoDescriptor> execute( PluginToolsRequest request )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
JavaClass[] javaClasses = discoverClasses( request );
|
||||
|
||||
List descriptors = new ArrayList();
|
||||
List<MojoDescriptor> descriptors = new ArrayList<MojoDescriptor>();
|
||||
|
||||
for ( int i = 0; i < javaClasses.length; i++ )
|
||||
{
|
||||
|
|
@ -673,9 +671,10 @@ public class JavaMojoDescriptorExtractor
|
|||
|
||||
MavenProject project = request.getProject();
|
||||
|
||||
for ( Iterator i = project.getCompileSourceRoots().iterator(); i.hasNext(); )
|
||||
for ( @SuppressWarnings( "unchecked" )
|
||||
Iterator<String> i = project.getCompileSourceRoots().iterator(); i.hasNext(); )
|
||||
{
|
||||
builder.addSourceTree( new File( (String) i.next() ) );
|
||||
builder.addSourceTree( new File( i.next() ) );
|
||||
}
|
||||
|
||||
// TODO be more dynamic
|
||||
|
|
@ -695,13 +694,14 @@ public class JavaMojoDescriptorExtractor
|
|||
protected void validate( MojoDescriptor mojoDescriptor )
|
||||
throws InvalidParameterException
|
||||
{
|
||||
List parameters = mojoDescriptor.getParameters();
|
||||
@SuppressWarnings( "unchecked" )
|
||||
List<Parameter> parameters = mojoDescriptor.getParameters();
|
||||
|
||||
if ( parameters != null )
|
||||
{
|
||||
for ( int j = 0; j < parameters.size(); j++ )
|
||||
{
|
||||
validateParameter( (Parameter) parameters.get( j ), j );
|
||||
validateParameter( parameters.get( j ), j );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ public abstract class AbstractMojoTaglet
|
|||
}
|
||||
else
|
||||
{
|
||||
List l = getOnlyValues( getAllowedValue() );
|
||||
List<String> l = getOnlyValues( getAllowedValue() );
|
||||
if ( isNotEmpty( tagValue ) )
|
||||
{
|
||||
if ( l.contains( tagValue ) )
|
||||
|
|
@ -300,7 +300,7 @@ public abstract class AbstractMojoTaglet
|
|||
}
|
||||
else
|
||||
{
|
||||
List l = getOnlyValues( getAllowedValue() );
|
||||
List<String> l = getOnlyValues( getAllowedValue() );
|
||||
if ( isNotEmpty( tagValue ) )
|
||||
{
|
||||
if ( l.contains( tagValue ) )
|
||||
|
|
@ -347,7 +347,7 @@ public abstract class AbstractMojoTaglet
|
|||
{
|
||||
sb.append( "<DL>" );
|
||||
|
||||
Enumeration names = att.getAttributeNames();
|
||||
Enumeration<?> names = att.getAttributeNames();
|
||||
while ( names.hasMoreElements() )
|
||||
{
|
||||
Object key = names.nextElement();
|
||||
|
|
@ -383,14 +383,14 @@ public abstract class AbstractMojoTaglet
|
|||
* @return a list of parsed Strings or <code>Collections.EMPTY_LIST</code>.
|
||||
* By convention, the default value is the first element.
|
||||
*/
|
||||
private static List getOnlyValues( String text )
|
||||
private static List<String> getOnlyValues( String text )
|
||||
{
|
||||
if ( text.indexOf( "|" ) == -1 )
|
||||
{
|
||||
return Collections.EMPTY_LIST;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List l = new ArrayList();
|
||||
List<String> l = new ArrayList<String>();
|
||||
StringTokenizer token = new StringTokenizer( text, "|" );
|
||||
while ( token.hasMoreTokens() )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -105,10 +105,10 @@ public class MojoAggregatorTypeTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoAggregatorTypeTaglet tag = new MojoAggregatorTypeTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -107,10 +107,10 @@ public class MojoComponentFieldTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoComponentFieldTaglet tag = new MojoComponentFieldTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -104,10 +104,10 @@ public class MojoConfiguratorTypeTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoConfiguratorTypeTaglet tag = new MojoConfiguratorTypeTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -110,10 +110,10 @@ public class MojoExecuteTypeTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoExecuteTypeTaglet tag = new MojoExecuteTypeTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -104,10 +104,10 @@ public class MojoExecutionStrategyTypeTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoExecutionStrategyTypeTaglet tag = new MojoExecutionStrategyTypeTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -104,10 +104,10 @@ public class MojoGoalTypeTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoGoalTypeTaglet tag = new MojoGoalTypeTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -105,10 +105,10 @@ public class MojoInheritByDefaultTypeTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoInheritByDefaultTypeTaglet tag = new MojoInheritByDefaultTypeTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -104,10 +104,10 @@ public class MojoInstantiationStrategyTypeTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoInstantiationStrategyTypeTaglet tag = new MojoInstantiationStrategyTypeTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -111,10 +111,10 @@ public class MojoParameterFieldTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoParameterFieldTaglet tag = new MojoParameterFieldTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -104,10 +104,10 @@ public class MojoPhaseTypeTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoPhaseTypeTaglet tag = new MojoPhaseTypeTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -108,10 +108,10 @@ public class MojoReadOnlyFieldTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoReadOnlyFieldTaglet tag = new MojoReadOnlyFieldTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -108,10 +108,10 @@ public class MojoRequiredFieldTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoRequiredFieldTaglet tag = new MojoRequiredFieldTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -104,10 +104,10 @@ public class MojoRequiresDependencyCollectionTypeTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoRequiresDependencyCollectionTypeTaglet tag = new MojoRequiresDependencyCollectionTypeTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -105,10 +105,10 @@ public class MojoRequiresDependencyResolutionTypeTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoRequiresDependencyResolutionTypeTaglet tag = new MojoRequiresDependencyResolutionTypeTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -105,10 +105,10 @@ public class MojoRequiresDirectInvocationTypeTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoRequiresDirectInvocationTypeTaglet tag = new MojoRequiresDirectInvocationTypeTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -105,10 +105,10 @@ public class MojoRequiresOnLineTypeTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoRequiresOnLineTypeTaglet tag = new MojoRequiresOnLineTypeTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -105,10 +105,10 @@ public class MojoRequiresProjectTypeTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoRequiresProjectTypeTaglet tag = new MojoRequiresProjectTypeTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -105,10 +105,10 @@ public class MojoRequiresReportsTypeTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoRequiresReportsTypeTaglet tag = new MojoRequiresReportsTypeTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -103,10 +103,10 @@ public class MojoThreadSafeTypeTaglet
|
|||
*
|
||||
* @param tagletMap the map to register this tag to.
|
||||
*/
|
||||
public static void register( Map tagletMap )
|
||||
public static void register( Map<String, Taglet> tagletMap )
|
||||
{
|
||||
MojoThreadSafeTypeTaglet tag = new MojoThreadSafeTypeTaglet();
|
||||
Taglet t = (Taglet) tagletMap.get( tag.getName() );
|
||||
Taglet t = tagletMap.get( tag.getName() );
|
||||
if ( t != null )
|
||||
{
|
||||
tagletMap.remove( tag.getName() );
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@
|
|||
<model>src/main/mdo/plugin-metadata.mdo</model>
|
||||
</models>
|
||||
<version>1.0.0</version>
|
||||
<useJava5>true</useJava5>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,13 @@ package org.apache.maven.plugin.tools.model;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.plugin.descriptor.DuplicateParameterException;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.Parameter;
|
||||
|
|
@ -29,14 +36,6 @@ import org.codehaus.plexus.util.ReaderFactory;
|
|||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Parser for plugin metadata.
|
||||
*
|
||||
|
|
@ -53,10 +52,10 @@ public class PluginMetadataParser
|
|||
* @return a set of <code>MojoDescriptor</code>
|
||||
* @throws PluginMetadataParseException if any
|
||||
*/
|
||||
public Set parseMojoDescriptors( File metadataFile )
|
||||
public Set<MojoDescriptor> parseMojoDescriptors( File metadataFile )
|
||||
throws PluginMetadataParseException
|
||||
{
|
||||
Set descriptors = new HashSet();
|
||||
Set<MojoDescriptor> descriptors = new HashSet<MojoDescriptor>();
|
||||
|
||||
Reader reader = null;
|
||||
|
||||
|
|
@ -68,14 +67,12 @@ public class PluginMetadataParser
|
|||
|
||||
PluginMetadata pluginMetadata = metadataReader.read( reader );
|
||||
|
||||
List mojos = pluginMetadata.getMojos();
|
||||
List<Mojo> mojos = pluginMetadata.getMojos();
|
||||
|
||||
if ( mojos != null && !mojos.isEmpty() )
|
||||
{
|
||||
for ( Iterator it = mojos.iterator(); it.hasNext(); )
|
||||
for ( Mojo mojo :mojos )
|
||||
{
|
||||
Mojo mojo = (Mojo) it.next();
|
||||
|
||||
MojoDescriptor descriptor = asDescriptor( metadataFile, mojo );
|
||||
|
||||
descriptors.add( descriptor );
|
||||
|
|
@ -137,15 +134,12 @@ public class PluginMetadataParser
|
|||
descriptor.setExecutePhase( le.getPhase() );
|
||||
}
|
||||
|
||||
List parameters = mojo.getParameters();
|
||||
List<org.apache.maven.plugin.tools.model.Parameter> parameters = mojo.getParameters();
|
||||
|
||||
if ( parameters != null && !parameters.isEmpty() )
|
||||
{
|
||||
for ( Iterator it = parameters.iterator(); it.hasNext(); )
|
||||
for ( org.apache.maven.plugin.tools.model.Parameter param : parameters )
|
||||
{
|
||||
org.apache.maven.plugin.tools.model.Parameter param =
|
||||
(org.apache.maven.plugin.tools.model.Parameter) it.next();
|
||||
|
||||
Parameter dParam = new Parameter();
|
||||
dParam.setAlias( param.getAlias() );
|
||||
dParam.setDeprecated( param.getDeprecation() );
|
||||
|
|
@ -186,14 +180,12 @@ public class PluginMetadataParser
|
|||
}
|
||||
}
|
||||
|
||||
List components = mojo.getComponents();
|
||||
List<Component> components = mojo.getComponents();
|
||||
|
||||
if ( components != null && !components.isEmpty() )
|
||||
{
|
||||
for ( Iterator it = components.iterator(); it.hasNext(); )
|
||||
for ( Component component : components )
|
||||
{
|
||||
Component component = (Component) it.next();
|
||||
|
||||
ComponentRequirement cr = new ComponentRequirement();
|
||||
cr.setRole( component.getRole() );
|
||||
cr.setRoleHint( component.getHint() );
|
||||
|
|
|
|||
21
pom.xml
21
pom.xml
|
|
@ -38,6 +38,13 @@
|
|||
<description>The Maven Plugin Tools contains the necessary tools to be able to produce Maven Plugins in a variety of languages.</description>
|
||||
<url>http://maven.apache.org/plugin-tools/</url>
|
||||
<inceptionYear>2004</inceptionYear>
|
||||
|
||||
<contributors>
|
||||
<contributor>
|
||||
<name>Robert Scholte</name>
|
||||
<timezone>+1</timezone>
|
||||
</contributor>
|
||||
</contributors>
|
||||
|
||||
<mailingLists>
|
||||
<mailingList>
|
||||
|
|
@ -220,6 +227,20 @@
|
|||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.8.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
|
|
|
|||
Loading…
Reference in New Issue