[MPLUGIN-110] Amend API to pass PluginToolsRequest around instead of project and pluginDescriptor. This will allow expansion of parameter passing in the future to include things like encoding, etc.
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@746360 13f79535-47bb-0310-9956-ffa450edef68master
parent
0f407357e3
commit
9f303ca83c
|
|
@ -61,7 +61,7 @@
|
|||
<properties>
|
||||
<doxiaVersion>1.0-alpha-10</doxiaVersion>
|
||||
<doxia-sitetoolsVersion>1.0-alpha-10</doxia-sitetoolsVersion>
|
||||
<pluginToolsVersion>2.5-SNAPSHOT</pluginToolsVersion>
|
||||
<pluginToolsVersion>[2.5-SNAPSHOT,)</pluginToolsVersion>
|
||||
</properties>
|
||||
|
||||
<!-- Copy from project up -->
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ import org.apache.maven.plugin.MojoExecutionException;
|
|||
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||
import org.apache.maven.tools.plugin.extractor.ExtractionException;
|
||||
import org.apache.maven.tools.plugin.generator.Generator;
|
||||
import org.apache.maven.tools.plugin.scanner.MojoScanner;
|
||||
|
|
@ -144,8 +146,10 @@ public abstract class AbstractGeneratorMojo
|
|||
try
|
||||
{
|
||||
pluginDescriptor.setDependencies( PluginUtils.toComponentDependencies( project.getRuntimeDependencies() ) );
|
||||
|
||||
PluginToolsRequest request = new DefaultPluginToolsRequest( project, pluginDescriptor );
|
||||
|
||||
mojoScanner.populatePluginDescriptor( project, pluginDescriptor );
|
||||
mojoScanner.populatePluginDescriptor( request );
|
||||
|
||||
getOutputDirectory().mkdirs();
|
||||
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ package org.apache.maven.tools.plugin.extractor.ant;
|
|||
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.Parameter;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.plugin.tools.model.PluginMetadataParseException;
|
||||
import org.apache.maven.plugin.tools.model.PluginMetadataParser;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.path.PathTranslator;
|
||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||
import org.apache.maven.tools.plugin.extractor.AbstractScriptedMojoDescriptorExtractor;
|
||||
import org.apache.maven.tools.plugin.extractor.ExtractionException;
|
||||
import org.codehaus.plexus.component.repository.ComponentRequirement;
|
||||
|
|
@ -56,7 +56,7 @@ public class AntMojoDescriptorExtractor
|
|||
|
||||
/** {@inheritDoc} */
|
||||
protected List extractMojoDescriptorsFromMetadata( Map metadataFilesKeyedByBasedir,
|
||||
PluginDescriptor pluginDescriptor )
|
||||
PluginToolsRequest request )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
List descriptors = new ArrayList();
|
||||
|
|
@ -218,7 +218,7 @@ public class AntMojoDescriptorExtractor
|
|||
descriptor.setComponentComposer( "map-oriented" );
|
||||
descriptor.setComponentConfigurator( "map-oriented" );
|
||||
|
||||
descriptor.setPluginDescriptor( pluginDescriptor );
|
||||
descriptor.setPluginDescriptor( request.getPluginDescriptor() );
|
||||
|
||||
descriptors.add( descriptor );
|
||||
}
|
||||
|
|
@ -234,13 +234,13 @@ public class AntMojoDescriptorExtractor
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
protected String getScriptFileExtension()
|
||||
protected String getScriptFileExtension( PluginToolsRequest request )
|
||||
{
|
||||
return SCRIPT_FILE_EXTENSION;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
protected String getMetadataFileExtension()
|
||||
protected String getMetadataFileExtension( PluginToolsRequest request )
|
||||
{
|
||||
return METADATA_FILE_EXTENSION;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@ import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
|
|||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.Parameter;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.path.PathTranslator;
|
||||
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||
import org.apache.maven.tools.plugin.extractor.ExtractionException;
|
||||
import org.codehaus.plexus.component.repository.ComponentRequirement;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
|
@ -36,7 +39,9 @@ public class AntMojoDescriptorExtractorTest
|
|||
pd.setVersion( "1" );
|
||||
pd.setGoalPrefix( "mytest" );
|
||||
|
||||
List metadata = new AntMojoDescriptorExtractor().extractMojoDescriptorsFromMetadata( scriptMap, pd );
|
||||
PluginToolsRequest request = new DefaultPluginToolsRequest( new MavenProject(), pd );
|
||||
|
||||
List metadata = new AntMojoDescriptorExtractor().extractMojoDescriptorsFromMetadata( scriptMap, request );
|
||||
|
||||
assertEquals( 2, metadata.size() );
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
package org.apache.maven.tools.plugin;
|
||||
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link PluginToolsRequest}, which is used to pass parameters to components
|
||||
* used to extract {@link MojoDescriptor} instances from different types of metadata for a given
|
||||
* plugin.
|
||||
*
|
||||
* @author jdcasey
|
||||
*/
|
||||
public class DefaultPluginToolsRequest
|
||||
implements PluginToolsRequest
|
||||
{
|
||||
|
||||
private PluginDescriptor pluginDescriptor;
|
||||
private MavenProject project;
|
||||
|
||||
public DefaultPluginToolsRequest( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
{
|
||||
this.project = project;
|
||||
this.pluginDescriptor = pluginDescriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public PluginDescriptor getPluginDescriptor()
|
||||
{
|
||||
return pluginDescriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public MavenProject getProject()
|
||||
{
|
||||
return project;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package org.apache.maven.tools.plugin;
|
||||
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
|
||||
/**
|
||||
* Request that encapsulates all information relevant to the process of extracting {@link MojoDescriptor}
|
||||
* instances from metadata for a certain type of mojo.
|
||||
*
|
||||
* @author jdcasey
|
||||
*/
|
||||
public interface PluginToolsRequest
|
||||
{
|
||||
|
||||
/**
|
||||
* Return the current {@link MavenProject} instance in use.
|
||||
*/
|
||||
MavenProject getProject();
|
||||
|
||||
/**
|
||||
* Return the {@link PluginDescriptor} currently being populated as part of the build of the
|
||||
* current plugin project.
|
||||
*/
|
||||
PluginDescriptor getPluginDescriptor();
|
||||
|
||||
}
|
||||
|
|
@ -22,6 +22,8 @@ package org.apache.maven.tools.plugin.extractor;
|
|||
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.util.DirectoryScanner;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
|
@ -47,28 +49,37 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
/** {@inheritDoc} */
|
||||
public List execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
return execute( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public List execute( PluginToolsRequest request )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
getLogger().debug( "Running: " + getClass().getName() );
|
||||
String metadataExtension = getMetadataFileExtension();
|
||||
String scriptExtension = getScriptFileExtension();
|
||||
String metadataExtension = getMetadataFileExtension( request );
|
||||
String scriptExtension = getScriptFileExtension( request );
|
||||
|
||||
MavenProject project = request.getProject();
|
||||
|
||||
Map scriptFilesKeyedByBasedir =
|
||||
gatherFilesByBasedir( project.getBasedir(), project.getScriptSourceRoots(), scriptExtension );
|
||||
gatherFilesByBasedir( project.getBasedir(), project.getScriptSourceRoots(), scriptExtension, request );
|
||||
|
||||
List mojoDescriptors;
|
||||
if ( !StringUtils.isEmpty( metadataExtension ) )
|
||||
{
|
||||
Map metadataFilesKeyedByBasedir =
|
||||
gatherFilesByBasedir( project.getBasedir(), project.getScriptSourceRoots(), metadataExtension );
|
||||
gatherFilesByBasedir( project.getBasedir(), project.getScriptSourceRoots(), metadataExtension, request );
|
||||
|
||||
mojoDescriptors = extractMojoDescriptorsFromMetadata( metadataFilesKeyedByBasedir, pluginDescriptor );
|
||||
mojoDescriptors = extractMojoDescriptorsFromMetadata( metadataFilesKeyedByBasedir, request );
|
||||
}
|
||||
else
|
||||
{
|
||||
mojoDescriptors = extractMojoDescriptors( scriptFilesKeyedByBasedir, pluginDescriptor );
|
||||
mojoDescriptors = extractMojoDescriptors( scriptFilesKeyedByBasedir, request );
|
||||
}
|
||||
|
||||
copyScriptsToOutputDirectory( scriptFilesKeyedByBasedir, project.getBuild().getOutputDirectory() );
|
||||
copyScriptsToOutputDirectory( scriptFilesKeyedByBasedir, project.getBuild().getOutputDirectory(), request );
|
||||
|
||||
return mojoDescriptors;
|
||||
}
|
||||
|
|
@ -78,7 +89,7 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
* @param outputDirectory not null
|
||||
* @throws ExtractionException if any
|
||||
*/
|
||||
protected void copyScriptsToOutputDirectory( Map scriptFilesKeyedByBasedir, String outputDirectory )
|
||||
protected void copyScriptsToOutputDirectory( Map scriptFilesKeyedByBasedir, String outputDirectory, PluginToolsRequest request )
|
||||
throws ExtractionException
|
||||
{
|
||||
File outputDir = new File( outputDirectory );
|
||||
|
|
@ -133,7 +144,7 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
* @param scriptFileExtension not null
|
||||
* @return map with subdirs paths as key
|
||||
*/
|
||||
protected Map gatherFilesByBasedir( File basedir, List directories, String scriptFileExtension )
|
||||
protected Map gatherFilesByBasedir( File basedir, List directories, String scriptFileExtension, PluginToolsRequest request )
|
||||
{
|
||||
Map sourcesByBasedir = new TreeMap();
|
||||
|
||||
|
|
@ -191,7 +202,7 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
* @throws InvalidPluginDescriptorException if any
|
||||
*/
|
||||
protected List extractMojoDescriptorsFromMetadata( Map metadataFilesKeyedByBasedir,
|
||||
PluginDescriptor pluginDescriptor )
|
||||
PluginToolsRequest request )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
return null;
|
||||
|
|
@ -202,7 +213,7 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
*
|
||||
* @return always null
|
||||
*/
|
||||
protected String getMetadataFileExtension()
|
||||
protected String getMetadataFileExtension( PluginToolsRequest request )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
@ -216,7 +227,7 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
* @throws ExtractionException if any
|
||||
* @throws InvalidPluginDescriptorException if any
|
||||
*/
|
||||
protected List extractMojoDescriptors( Map scriptFilesKeyedByBasedir, PluginDescriptor pluginDescriptor )
|
||||
protected List extractMojoDescriptors( Map scriptFilesKeyedByBasedir, PluginToolsRequest request )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
return null;
|
||||
|
|
@ -225,6 +236,6 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
/**
|
||||
* @return the file extension like <code>.bsh</code> for BeanShell.
|
||||
*/
|
||||
protected abstract String getScriptFileExtension();
|
||||
protected abstract String getScriptFileExtension( PluginToolsRequest request );
|
||||
|
||||
}
|
||||
|
|
@ -22,6 +22,7 @@ package org.apache.maven.tools.plugin.extractor;
|
|||
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -34,15 +35,28 @@ public interface MojoDescriptorExtractor
|
|||
/** Plexus role for lookup */
|
||||
String ROLE = MojoDescriptorExtractor.class.getName();
|
||||
|
||||
|
||||
/**
|
||||
* Execute the mojo extraction.
|
||||
*
|
||||
* @param project not null Maven project
|
||||
* @param pluginDescriptor not null plugin descriptor
|
||||
* @return a list of mojo descriptors.
|
||||
* @throws ExtractionException if any
|
||||
* @throws InvalidPluginDescriptorException if any
|
||||
*
|
||||
* @deprecated Use {@link MojoDescriptorExtractor#execute(PluginToolsRequest)} instead.
|
||||
* Provided for backward compatibility with maven-plugin-plugin < 2.5.
|
||||
*/
|
||||
List execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
throws ExtractionException, InvalidPluginDescriptorException;
|
||||
|
||||
/**
|
||||
* Execute the mojo extraction.
|
||||
*
|
||||
* @param request The {@link PluginToolsRequest} containing information for the extraction process.
|
||||
* @return a list of mojo descriptors.
|
||||
* @throws ExtractionException if any
|
||||
* @throws InvalidPluginDescriptorException if any
|
||||
*/
|
||||
List execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
List execute( PluginToolsRequest request )
|
||||
throws ExtractionException, InvalidPluginDescriptorException;
|
||||
}
|
||||
|
|
@ -23,6 +23,8 @@ 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;
|
||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||
import org.apache.maven.tools.plugin.extractor.ExtractionException;
|
||||
import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
|
|
@ -73,6 +75,13 @@ public class DefaultMojoScanner
|
|||
/** {@inheritDoc} */
|
||||
public void populatePluginDescriptor( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
populatePluginDescriptor( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void populatePluginDescriptor( PluginToolsRequest request )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
Logger logger = getLogger();
|
||||
Set activeExtractorsInternal = getActiveExtractors();
|
||||
|
|
@ -93,7 +102,7 @@ public class DefaultMojoScanner
|
|||
|
||||
logger.info( "Applying mojo extractor for language: " + language );
|
||||
|
||||
List extractorDescriptors = extractor.execute( project, pluginDescriptor );
|
||||
List extractorDescriptors = extractor.execute( request );
|
||||
|
||||
logger.info( "Mojo extractor for language: " + language + " found " + extractorDescriptors.size()
|
||||
+ " mojo descriptors." );
|
||||
|
|
@ -105,9 +114,9 @@ public class DefaultMojoScanner
|
|||
|
||||
logger.debug( "Adding mojo: " + descriptor + " to plugin descriptor." );
|
||||
|
||||
descriptor.setPluginDescriptor( pluginDescriptor );
|
||||
descriptor.setPluginDescriptor( request.getPluginDescriptor() );
|
||||
|
||||
pluginDescriptor.addMojo( descriptor );
|
||||
request.getPluginDescriptor().addMojo( descriptor );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ package org.apache.maven.tools.plugin.scanner;
|
|||
import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||
import org.apache.maven.tools.plugin.extractor.ExtractionException;
|
||||
|
||||
import java.util.Set;
|
||||
|
|
@ -40,10 +41,21 @@ public interface MojoScanner
|
|||
* @param pluginDescriptor not null
|
||||
* @throws ExtractionException if any
|
||||
* @throws InvalidPluginDescriptorException if any
|
||||
*
|
||||
* @deprecated Use {@link MojoScanner#populatePluginDescriptor(PluginToolsRequest)} instead.
|
||||
* Provided for backward compatibility with maven-plugin-plugin < 2.5.
|
||||
*/
|
||||
void populatePluginDescriptor( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
throws ExtractionException, InvalidPluginDescriptorException;
|
||||
|
||||
/**
|
||||
* @param project not null
|
||||
* @param pluginDescriptor not null
|
||||
* @throws ExtractionException if any
|
||||
* @throws InvalidPluginDescriptorException if any
|
||||
*/
|
||||
void populatePluginDescriptor( PluginToolsRequest request )
|
||||
throws ExtractionException, InvalidPluginDescriptorException;
|
||||
|
||||
/**
|
||||
* Sets the active extractors.
|
||||
|
|
|
|||
|
|
@ -19,9 +19,13 @@ package org.apache.maven.tools.plugin.scanner;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
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;
|
||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||
import org.apache.maven.tools.plugin.extractor.ExtractionException;
|
||||
import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
|
||||
|
||||
import java.util.Collections;
|
||||
|
|
@ -41,12 +45,19 @@ public class ScannerTestExtractor
|
|||
}
|
||||
|
||||
public List execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
throws InvalidPluginDescriptorException, ExtractionException
|
||||
{
|
||||
MojoDescriptor desc = new MojoDescriptor();
|
||||
desc.setPluginDescriptor( pluginDescriptor );
|
||||
desc.setGoal( goal );
|
||||
return execute( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
|
||||
}
|
||||
|
||||
return Collections.singletonList( desc );
|
||||
public List execute( PluginToolsRequest request )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
MojoDescriptor desc = new MojoDescriptor();
|
||||
desc.setPluginDescriptor( request.getPluginDescriptor() );
|
||||
desc.setGoal( goal );
|
||||
|
||||
return Collections.singletonList( desc );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -22,6 +22,8 @@ package org.apache.maven.tools.plugin.scanner;
|
|||
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;
|
||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||
import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
|
||||
|
||||
import java.util.Collections;
|
||||
|
|
@ -35,9 +37,14 @@ public class TestExtractor
|
|||
{
|
||||
|
||||
public List execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
{
|
||||
return execute( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
|
||||
}
|
||||
|
||||
public List execute( PluginToolsRequest request )
|
||||
{
|
||||
MojoDescriptor desc = new MojoDescriptor();
|
||||
desc.setPluginDescriptor( pluginDescriptor );
|
||||
desc.setPluginDescriptor( request.getPluginDescriptor() );
|
||||
desc.setGoal( "testGoal" );
|
||||
|
||||
return Collections.singletonList( desc );
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import bsh.Interpreter;
|
|||
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.tools.plugin.PluginToolsRequest;
|
||||
import org.apache.maven.tools.plugin.extractor.AbstractScriptedMojoDescriptorExtractor;
|
||||
import org.apache.maven.tools.plugin.extractor.ExtractionException;
|
||||
|
||||
|
|
@ -49,13 +50,13 @@ public class BeanshellMojoDescriptorExtractor
|
|||
extends AbstractScriptedMojoDescriptorExtractor
|
||||
{
|
||||
/** {@inheritDoc} */
|
||||
protected String getScriptFileExtension()
|
||||
protected String getScriptFileExtension( PluginToolsRequest request )
|
||||
{
|
||||
return ".bsh";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
protected List extractMojoDescriptors( Map scriptFilesKeyedByBasedir, PluginDescriptor pluginDescriptor )
|
||||
protected List extractMojoDescriptors( Map scriptFilesKeyedByBasedir, PluginToolsRequest request )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
List descriptors = new ArrayList();
|
||||
|
|
@ -82,7 +83,7 @@ public class BeanshellMojoDescriptorExtractor
|
|||
|
||||
relativePath = relativePath.replace( '\\', '/' );
|
||||
|
||||
MojoDescriptor mojoDescriptor = createMojoDescriptor( basedir, relativePath, pluginDescriptor );
|
||||
MojoDescriptor mojoDescriptor = createMojoDescriptor( basedir, relativePath, request.getPluginDescriptor() );
|
||||
descriptors.add( mojoDescriptor );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ import org.apache.maven.plugin.descriptor.Parameter;
|
|||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.Requirement;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
|
||||
import org.apache.maven.tools.plugin.PluginToolsRequest;
|
||||
import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
|
||||
import org.apache.maven.tools.plugin.extractor.ExtractionException;
|
||||
|
||||
|
|
@ -580,7 +582,14 @@ public class JavaMojoDescriptorExtractor
|
|||
public List execute( MavenProject project, PluginDescriptor pluginDescriptor )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
JavaClass[] javaClasses = discoverClasses( project );
|
||||
return execute( new DefaultPluginToolsRequest( project, pluginDescriptor ) );
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public List execute( PluginToolsRequest request )
|
||||
throws ExtractionException, InvalidPluginDescriptorException
|
||||
{
|
||||
JavaClass[] javaClasses = discoverClasses( request.getProject() );
|
||||
|
||||
List descriptors = new ArrayList();
|
||||
|
||||
|
|
@ -591,7 +600,7 @@ public class JavaMojoDescriptorExtractor
|
|||
if ( tag != null )
|
||||
{
|
||||
MojoDescriptor mojoDescriptor = createMojoDescriptor( javaClasses[i] );
|
||||
mojoDescriptor.setPluginDescriptor( pluginDescriptor );
|
||||
mojoDescriptor.setPluginDescriptor( request.getPluginDescriptor() );
|
||||
|
||||
// Validate the descriptor as best we can before allowing it to be processed.
|
||||
validate( mojoDescriptor );
|
||||
|
|
|
|||
2
pom.xml
2
pom.xml
|
|
@ -154,7 +154,7 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||
<artifactId>maven-plugin-tools-api</artifactId>
|
||||
<version>${pluginToolsVersion}</version>
|
||||
<version>[${pluginToolsVersion},)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||
|
|
|
|||
Loading…
Reference in New Issue