o Refactored mojo/plugin generation, extraction, etc. to accommodate multiple mojo languages.

o Tested with java mojos, mboot to verify nothing broken by refactor.
o TODO: Add marmalade support tests...currently only java-mojos are supported in mboot2, so this isn't going to interrupt things.
o TODO: Once marmalade support is tested, add to the list of artifacts built by mboot2.


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163369 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-02-20 16:25:22 +00:00
parent 2011539175
commit 98002718c3
71 changed files with 1681 additions and 1692 deletions

View File

@ -26,16 +26,13 @@ Marmalade Support
- a marmalade-based mojo should look something like:
+---+
<mojo xmlns="m2:mojo" xmlns:doco="marmalade:doco">
<mojo xmlns="m2:mojo" xmlns:marmalade-control="marmalade:marmalade-control" marmalade-control:el="none">
<metadata>
<id>mmld</id>
<name>mmldCompile</name>
<lifecyclePhase>compile</lifecyclePhase>
<doco:description>
Used to compile marmalade scripts into java beans.
</doco:description>
<description>Used to compile marmalade scripts into java beans.</description>
<requiresDependencyResolution/>
<instantiationStrategy/>
@ -65,6 +62,7 @@ Marmalade Support
</mojo>
+---+
[NOTE] All empty elements above signify optional elements, usage specification.
[[2]] <<Marmalade mojo packager.>>
@ -72,26 +70,36 @@ Marmalade Support
[[a]] Locate all *.mmld files within the scripts directory of the project.
The scripts directory should be tied to the script language within
the POM. Until we have multiple language support in the POM, we'll
use something like: <<<xpath(build/marmaladeSourceDirectory)>>>.
[[b]] For each script found:
[[i]] Execute the script with "gatherMetadata=true" in the context.
[[ii]] Retrieve the mojo descriptor from the "descriptor" variable
in the context.
[[ii]] Retrieve the mojo descriptor from the resulting "metadata"
variable in the context.
[[iii]] Add the relative script path to the mojo descriptor.
[[iii]] Cache the mojo descriptor in aggregator for subsequent
output to plugin descriptor file.
[[c]] Copy all scripts to the target directory. Preserve relative paths.
[[d]] <<Process Disjoint:>> <Allow other mojo-descriptor collectors to
run, aggregating their descriptors in similar fashion to [b.iii]
above.>
[[iv]] Cache the mojo descriptor for later aggregation.
[[c]] Use the project's dependencies and other info to form the plugin
[[e]] Use the project's dependencies and other info to form the plugin
descriptor's header (non-mojo-specific info).
[[d]] Use the PluginGenerator from maven-plugin-tools to generate a
[[f]] Use the PluginGenerator from maven-plugin-tools to generate a
META-INF/plexus/plugin.xml to the target directory.
[[e]] Copy all scripts to the target directory. Preserve relative paths.
[[g]] Continue with lifecycle.
[[f]] Package into a jar and deploy to the repo.
This may include compilation of java helper classes, etc. and
plugin-artifact packaging, presumably via 'jar:jar' or similar.
[[3]] <<Marmalade mojo loader.>>
@ -137,30 +145,22 @@ Marmalade Support
scalable or extensible enough to accommodate future expansion into the
realms of jython, groovy, etc...
<<UPDATE:07-FEB-2005>>
We'll plan on using some sort of language specification in the mojo
descriptor to determine which mojo loader to use, then we'll populate
the PluginLoader/PluginManager with a map of known languages->loaders.
[[2]] How do we make the plugin:install process smart enough to switch
generator implementations based on some sub-type of maven-plugin?
This is closely related to [1] above.
[[3]] We should probably look into enforcing <<<org/apache/maven/plugins/$pluginId>>>
namespacing for plugin generation, to avoid the case where two plugins
are script-based, load from the context classloader, depend on one
another's APIs, and have script names that collide.
<<UPDATE:07-FEB-2005>>
<<Example:>> An aspectWerkz plugin which provides a "/compile.mmld" and
depends on an eclipseCompiler plugin, which also happens to provide a
"/compile.mmld". The AW plugin might require a java compiler to outsource
the actual java code compilation, and want to use the Eclipse compiler
APIs to do this. Maybe the eclipseCompiler plugin has additional
convenience APIs that the AW plugin wants to use...anyway, the mojo
loader for marmalade scripts is based on classpath resources, so when
it looks up "/compile.mmld" in the classloader for the plugin's realm,
will it come up with the correct script (the AW one)? This doesn't seem
to be deterministic. It's simple to avoid this, in the same way that
java source code does. Placing a naming constraint on scripts within a
plugin would allow us to enforce compatibility to some extent.
See update in [3].
[[4]] Do we want to allow mixed-bag plugin implementations?
[[3]] Do we want to allow mixed-bag plugin implementations?
These might include a mix of standard-java and marmalade mojos. It
strikes me that many marmalade-based mojos may use beans/tags that are
@ -170,3 +170,10 @@ Marmalade Support
compile it and bundle it with the plugin scripts; but what if this source
also has mojo annotations? This will have implications for [1] and [2]
above.
<<UPDATE:07-FEB-2005>>
We will plan on allowing this sort of implementation, and simply start
by applying all known generators which have a source directory set in
the POM (or later, have a <language/> section, maybe). At any rate,
helper classes will be allowed for script-based mojos.

View File

@ -58,6 +58,21 @@ public class MBoot
//"plexus/jars/plexus-container-api-1.0-alpha-1-SNAPSHOT.jar",
//"plexus/jars/plexus-utils-1.0-alpha-1-SNAPSHOT.jar"
};
String[] pluginGeneratorDeps = new String[]{
"plexus/jars/plexus-container-default-1.0-alpha-2-SNAPSHOT.jar",
"classworlds/jars/classworlds-1.1-alpha-1.jar",
"maven/jars/maven-artifact-2.0-SNAPSHOT.jar",
"maven/jars/maven-core-2.0-SNAPSHOT.jar",
"maven/jars/maven-model-2.0-SNAPSHOT.jar",
"maven/jars/maven-plugin-2.0-SNAPSHOT.jar",
"maven/jars/maven-plugin-tools-api-2.0-SNAPSHOT.jar",
"maven/jars/maven-plugin-tools-java-2.0-SNAPSHOT.jar",
"maven/jars/maven-plugin-tools-pluggy-2.0-SNAPSHOT.jar",
"maven/jars/wagon-provider-api-1.0-alpha-2-SNAPSHOT.jar",
"maven/jars/wagon-file-1.0-alpha-2-SNAPSHOT.jar",
"maven/jars/wagon-http-lightweight-1.0-alpha-2-SNAPSHOT.jar"
};
// ----------------------------------------------------------------------
// These are modello's runtime dependencies
@ -79,9 +94,13 @@ public class MBoot
{
"maven-model",
"maven-plugin",
"maven-plugin-tools",
"maven-artifact",
"maven-core",
// "maven-script/maven-script-marmalade",
"maven-plugin-tools/maven-plugin-tools-api",
"maven-plugin-tools/maven-plugin-tools-java",
"maven-plugin-tools/maven-plugin-tools-pluggy",
// "maven-plugin-tools/maven-plugin-tools-marmalade",
"maven-core-it-verifier"
};
@ -262,11 +281,8 @@ public class MBoot
System.out.println( "--------------------------------------------------------------------" );
}
cl.addURL( new File( repoLocal, "maven/jars/maven-plugin-2.0-SNAPSHOT.jar" ).toURL() );
cl.addURL( new File( repoLocal, "maven/jars/maven-plugin-tools-2.0-SNAPSHOT.jar" ).toURL() );
addPluginGeneratorDependencies();
for ( int i = 0; i < pluginBuilds.length; i++ )
{
String directory = new File( basedir, pluginBuilds[i] ).getAbsolutePath();
@ -603,17 +619,36 @@ public class MBoot
cl.addURL( f.toURL() );
}
}
private void addPluginGeneratorDependencies() throws Exception
{
for ( int i=0; i<pluginGeneratorDeps.length; i++ )
{
String dependency = pluginGeneratorDeps[i];
File f = new File( repoLocal, dependency );
if ( !f.exists() )
{
throw new FileNotFoundException( "Missing dependency: " + dependency +
( !online ? "; run again online" : "; there was a problem downloading it earlier" ) );
}
cl.addURL( f.toURL() );
}
}
private void generatePluginDescriptor( String sourceDirectory, String outputDirectory, String pom )
throws Exception
{
Class c = cl.loadClass( "org.apache.maven.plugin.generator.PluginDescriptorGenerator" );
Object generator = c.newInstance();
Method m = c.getMethod( "execute", new Class[]{String.class, String.class, String.class} );
m.invoke( generator, new Object[]{sourceDirectory, outputDirectory, pom} );
Class cls = cl.loadClass("org.apache.maven.tools.plugin.pluggy.Main");
Method m = cls.getMethod( "main", new Class[]{String[].class} );
String[] args = {
"descriptor", sourceDirectory, outputDirectory, pom, repoLocal
};
m.invoke( null, new Object[]{args} );
}
private void generateSources( String model, String mode, String dir, String modelVersion, String packageWithVersion )

View File

@ -1,361 +0,0 @@
/* Created on Aug 7, 2004 */
package org.apache.maven.plugin.loader.marmalade;
import org.apache.maven.plugin.MavenMojoDescriptor;
import org.apache.maven.plugin.MavenPluginDependency;
import org.apache.maven.plugin.MavenPluginDescriptor;
import org.apache.maven.plugin.descriptor.Dependency;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.loader.marmalade.tags.MojoTag;
import org.codehaus.classworlds.ClassRealm;
import org.codehaus.marmalade.el.ognl.OgnlExpressionEvaluator;
import org.codehaus.marmalade.metamodel.MarmaladeTaglibResolver;
import org.codehaus.marmalade.model.MarmaladeScript;
import org.codehaus.marmalade.model.MarmaladeTag;
import org.codehaus.marmalade.parsetime.CachingScriptParser;
import org.codehaus.marmalade.parsetime.DefaultParsingContext;
import org.codehaus.marmalade.parsetime.MarmaladeModelBuilderException;
import org.codehaus.marmalade.parsetime.MarmaladeParsetimeException;
import org.codehaus.marmalade.parsetime.MarmaladeParsingContext;
import org.codehaus.marmalade.parsetime.ScriptBuilder;
import org.codehaus.marmalade.parsetime.ScriptParser;
import org.codehaus.marmalade.runtime.DefaultContext;
import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
import org.codehaus.marmalade.runtime.MarmaladeExecutionException;
import org.codehaus.marmalade.util.RecordingReader;
import org.codehaus.plexus.component.discovery.AbstractComponentDiscoverer;
import org.codehaus.plexus.component.factory.ComponentInstantiationException;
import org.codehaus.plexus.component.repository.ComponentDescriptor;
import org.codehaus.plexus.component.repository.ComponentSetDescriptor;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
/**
* @author jdcasey
*/
public class MarmaladePluginDiscoverer extends AbstractComponentDiscoverer
{
private static final String FILE_PROTO = "file";
private static final String MARMALADE_MOJO_PATH_PATTERN = ".*\\.mmld";
private static final String MARMALADE_COMPONENT_FACTORY = "marmalade";
protected String getComponentDescriptorLocation( )
{
return null;
}
protected ComponentSetDescriptor createComponentDescriptors(
Reader reader, String source )
throws Exception
{
return null;
}
public List findComponents( ClassRealm classRealm )
{
URL[] candidateLocations = classRealm.getConstituents( );
List componentSetDescriptors = new LinkedList( );
for ( int i = 0; i < candidateLocations.length; i++ )
{
URL url = candidateLocations[i];
String urlProto = url.getProtocol( );
try
{
PluginDescriptor pluginDescriptor = null;
if ( FILE_PROTO.equals( urlProto ) )
{
// scan as directory...
pluginDescriptor = scanAsDirectory( url.getPath( ),
classRealm );
}
else
{
// Skip this one...not sure what to do with it.
}
if ( pluginDescriptor != null )
{
MavenPluginDescriptor descriptor = new MavenPluginDescriptor( pluginDescriptor );
// Add the dependencies
List dependencies = new ArrayList();
for ( Iterator it = pluginDescriptor.getDependencies().iterator(); it.hasNext() ; )
{
Dependency dependency = (Dependency)it.next();
dependencies.add( new MavenPluginDependency( dependency ) );
}
descriptor.setDependencies( dependencies );
List mojoDescriptors = pluginDescriptor.getMojos( );
List componentDescriptors = new LinkedList( );
for ( Iterator it = mojoDescriptors.iterator( );
it.hasNext( ); )
{
MojoDescriptor mojoDescriptor = ( MojoDescriptor ) it
.next( );
mojoDescriptor.setImplementation(url.getPath());
ComponentDescriptor mmDesc = new MavenMojoDescriptor( mojoDescriptor );
mmDesc.setComponentFactory( MARMALADE_COMPONENT_FACTORY );
componentDescriptors.add( mmDesc );
}
descriptor.setComponents( componentDescriptors );
componentSetDescriptors.add( descriptor );
}
}
catch ( Exception e )
{
// TODO Log and what...skip???
e.printStackTrace( );
}
}
return componentSetDescriptors;
}
private PluginDescriptor scanAsJar( String path, ClassRealm classRealm )
throws Exception
{
String jarPart = path;
int bangIdx = jarPart.indexOf( "!" );
if ( bangIdx > -1 )
{
jarPart = jarPart.substring( 0, bangIdx );
}
File file = new File(path);
JarInputStream jis = new JarInputStream( new FileInputStream( file ) );
List mojoDescriptors = new LinkedList( );
List dependencies = new LinkedList( );
JarEntry je = null;
while ( ( je = jis.getNextJarEntry( ) ) != null )
{
String entryName = je.getName( );
if ( entryName.matches( MARMALADE_MOJO_PATH_PATTERN ) )
{
mojoDescriptors.add( loadMojoDescriptor( entryName,
dependencies, classRealm ) );
}
}
PluginDescriptor descriptor = null;
if ( !mojoDescriptors.isEmpty( ) )
{
descriptor = new PluginDescriptor( );
descriptor.setMojos( mojoDescriptors );
descriptor.setDependencies( dependencies );
}
return descriptor;
}
private PluginDescriptor scanAsDirectory( String path, ClassRealm classRealm )
throws Exception
{
List dependencies = new LinkedList( );
File file = new File(path);
PluginDescriptor descriptor = null;
if(!file.isDirectory() && path.endsWith(".jar")) {
// try to scan it as a jar...
descriptor = scanAsJar(path, classRealm);
}
else {
List mojoDescriptors = scanDir( path, file,
new LinkedList( ), dependencies, classRealm );
if ( !mojoDescriptors.isEmpty( ) )
{
descriptor = new PluginDescriptor( );
descriptor.setMojos( mojoDescriptors );
descriptor.setDependencies( dependencies );
}
}
return descriptor;
}
private List scanDir( String basePath, File parent, List results,
List dependencies, ClassRealm classRealm )
throws Exception
{
if ( parent.isDirectory( ) )
{
String[] subPaths = parent.list( );
for ( int i = 0; i < subPaths.length; i++ )
{
File file = new File( parent, subPaths[i] );
if ( file.isDirectory( ) )
{
results = scanDir( basePath, file, results, dependencies,
classRealm );
}
else if ( file.getPath( ).matches( MARMALADE_MOJO_PATH_PATTERN ) )
{
String scriptResource = file.getAbsolutePath( ).substring( basePath
.length( ) );
results.add( loadMojoDescriptor( scriptResource,
dependencies, classRealm ) );
}
}
}
return results;
}
private MojoDescriptor loadMojoDescriptor( String entryName,
List dependencies, ClassRealm classRealm )
throws Exception
{
MarmaladeParsingContext context = buildParsingContext( entryName,
classRealm );
MarmaladeScript script = getScriptInstance( context );
MojoDescriptor desc = getDescriptor( script, dependencies );
return desc;
}
private MojoDescriptor getDescriptor( MarmaladeScript script,
List dependencies ) throws ComponentInstantiationException
{
MojoTag root = ( MojoTag ) script.getRoot( );
root.describeOnly( true );
MarmaladeExecutionContext execCtx = new DefaultContext( );
try
{
script.execute( execCtx );
}
catch ( MarmaladeExecutionException e )
{
throw new ComponentInstantiationException(
"failed to execute component script: " + script.getLocation( ),
e );
}
MojoDescriptor descriptor = root.getMojoDescriptor( );
dependencies = root.addDependencies( dependencies );
return descriptor;
}
private MarmaladeScript getScriptInstance(
MarmaladeParsingContext parsingContext )
throws Exception
{
ScriptBuilder builder = null;
try
{
builder = new ScriptParser().parse( parsingContext );
}
catch ( MarmaladeParsetimeException e )
{
throw new Exception( "failed to parse component script: "
+ parsingContext.getInputLocation( ), e );
}
catch ( MarmaladeModelBuilderException e )
{
throw new Exception( "failed to parse component script: "
+ parsingContext.getInputLocation( ), e );
}
MarmaladeScript script = null;
try
{
script = builder.build( );
}
catch ( MarmaladeModelBuilderException e )
{
throw new Exception( "failed to build component script: "
+ parsingContext.getInputLocation( ), e );
}
MarmaladeTag root = script.getRoot( );
if ( !( root instanceof MojoTag ) )
{
throw new Exception(
"marmalade script does not contain a mojo header" );
}
return script;
}
private MarmaladeParsingContext buildParsingContext( String scriptName,
ClassRealm classRealm )
throws Exception
{
InputStream scriptResource = classRealm.getResourceAsStream( scriptName );
if ( scriptResource == null )
{
throw new Exception( "can't get script from classpath: "
+ scriptName );
}
RecordingReader scriptIn = new RecordingReader( new InputStreamReader(
scriptResource ) );
MarmaladeTaglibResolver resolver = new MarmaladeTaglibResolver( MarmaladeTaglibResolver.DEFAULT_STRATEGY_CHAIN );
OgnlExpressionEvaluator el = new OgnlExpressionEvaluator( );
MarmaladeParsingContext context = new DefaultParsingContext( );
context.setDefaultExpressionEvaluator( el );
context.setInput( scriptIn );
context.setInputLocation( scriptName );
context.setTaglibResolver( resolver );
return context;
}
}

View File

@ -1,35 +0,0 @@
/* Created on Aug 9, 2004 */
package org.apache.maven.plugin.loader.marmalade;
import org.apache.maven.plugin.AbstractPlugin;
import org.apache.maven.plugin.PluginExecutionRequest;
import org.apache.maven.plugin.PluginExecutionResponse;
import org.codehaus.marmalade.model.MarmaladeScript;
import org.codehaus.marmalade.runtime.DefaultContext;
import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
/**
* @author jdcasey
*/
public class MarmaladeScriptMojo extends AbstractPlugin {
public static final String REQUEST_VARIABLE = "request";
public static final String RESPONSE_VARIABLE = "response";
private MarmaladeScript script;
public MarmaladeScriptMojo(MarmaladeScript script) {
this.script = script;
}
public void execute(PluginExecutionRequest request,
PluginExecutionResponse response) throws Exception {
MarmaladeExecutionContext context = new DefaultContext();
context.setVariable(REQUEST_VARIABLE, request);
context.setVariable(RESPONSE_VARIABLE, response);
script.execute(context);
}
}

View File

@ -1,11 +0,0 @@
/* Created on Aug 7, 2004 */
package org.apache.maven.plugin.loader.marmalade.tags;
/**
* @author jdcasey
*/
public interface DescriptionOwner {
public void setDescription(String description);
}

View File

@ -1,26 +0,0 @@
/* Created on Aug 7, 2004 */
package org.apache.maven.plugin.loader.marmalade.tags;
import org.codehaus.marmalade.el.ExpressionEvaluationException;
import org.codehaus.marmalade.model.AbstractMarmaladeTag;
import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
import org.codehaus.marmalade.runtime.MarmaladeExecutionException;
public class DescriptionTag extends AbstractMarmaladeTag
{
protected void doExecute( MarmaladeExecutionContext context )
throws MarmaladeExecutionException
{
String description = (String)getBody(context, String.class);
DescriptionOwner parent = (DescriptionOwner)requireParent(DescriptionOwner.class);
parent.setDescription(description);
}
protected boolean preserveBodyWhitespace( MarmaladeExecutionContext arg0 )
throws ExpressionEvaluationException
{
return false;
}
}

View File

@ -1,31 +0,0 @@
/* Created on Aug 7, 2004 */
package org.apache.maven.plugin.loader.marmalade.tags;
import java.util.LinkedList;
import java.util.List;
import org.apache.maven.plugin.descriptor.Dependency;
import org.codehaus.marmalade.model.AbstractMarmaladeTag;
import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
import org.codehaus.marmalade.runtime.MarmaladeExecutionException;
/**
* @author jdcasey
*/
public class MojoDependenciesTag extends AbstractMarmaladeTag {
private List dependencies = new LinkedList();
protected void doExecute(MarmaladeExecutionContext context)
throws MarmaladeExecutionException {
processChildren(context);
MojoDescriptorTag parent = (MojoDescriptorTag)requireParent(MojoDescriptorTag.class);
parent.setDependencies(dependencies);
}
public void addDependency(Dependency dependency) {
dependencies.add(dependency);
}
}

View File

@ -1,43 +0,0 @@
/* Created on Aug 7, 2004 */
package org.apache.maven.plugin.loader.marmalade.tags;
import org.apache.maven.plugin.descriptor.Dependency;
import org.codehaus.marmalade.model.AbstractMarmaladeTag;
import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
import org.codehaus.marmalade.runtime.MarmaladeExecutionException;
public class MojoDependencyTag extends AbstractMarmaladeTag
{
public static final String GROUP_ID_ATTRIBUTE = "groupId";
public static final String ARTIFACT_ID_ATTRIBUTE = "artifactId";
public static final String VERSION_ATTRIBUTE = "version";
public static final String TYPE_ATTRIBUTE = "type";
protected void doExecute( MarmaladeExecutionContext context )
throws MarmaladeExecutionException
{
String groupId = (String)requireTagAttribute(GROUP_ID_ATTRIBUTE, String.class, context);
String artifactId = (String)requireTagAttribute(ARTIFACT_ID_ATTRIBUTE, String.class, context);
String version = (String)requireTagAttribute(VERSION_ATTRIBUTE, String.class, context);
String type = (String)getAttributes().getValue(TYPE_ATTRIBUTE, String.class, context);
MojoDependenciesTag parent = (MojoDependenciesTag)requireParent(MojoDependenciesTag.class);
Dependency dep = new Dependency();
dep.setGroupId(groupId);
dep.setArtifactId(artifactId);
dep.setVersion(version);
if(type != null) {
dep.setType(type);
}
parent.addDependency(dep);
}
protected boolean alwaysProcessChildren() {
// never process children...shouldn't even have any!
return false;
}
}

View File

@ -1,98 +0,0 @@
/* Created on Aug 7, 2004 */
package org.apache.maven.plugin.loader.marmalade.tags;
import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.Parameter;
import org.codehaus.marmalade.model.AbstractMarmaladeTag;
import org.codehaus.marmalade.model.MarmaladeAttributes;
import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
import org.codehaus.marmalade.runtime.MarmaladeExecutionException;
import java.util.LinkedList;
import java.util.List;
/**
* @author jdcasey
*/
public class MojoDescriptorTag extends AbstractMarmaladeTag
implements DescriptionOwner
{
public static final String ID_ATTRIBUTE = "id";
public static final String INSTANTIATION_STRATEGY_ATTRIBUTE = "instantiation-strategy";
public static final String EXECUTION_STRATEGY_ATTRIBUTE = "execution-strategy";
public static final String GOAL_ATTRIBUTE = "goal";
private String id;
private String instantiationStrategy;
private String executionStrategy;
private String goal;
private String description;
private List prereqs = new LinkedList( );
private List dependencies = new LinkedList( );
private List parameters = new LinkedList();
protected void doExecute( MarmaladeExecutionContext context )
throws MarmaladeExecutionException
{
this.id = ( String ) requireTagAttribute( ID_ATTRIBUTE, String.class,
context );
MarmaladeAttributes attributes = getAttributes();
this.instantiationStrategy = ( String ) attributes.getValue( INSTANTIATION_STRATEGY_ATTRIBUTE,
String.class, context );
this.executionStrategy = ( String ) attributes.getValue( EXECUTION_STRATEGY_ATTRIBUTE,
String.class, context );
this.goal = (String)attributes.getValue(GOAL_ATTRIBUTE, String.class, context);
}
public List getDependencies( )
{
return dependencies;
}
public MojoDescriptor getMojoDescriptor( )
{
MojoDescriptor descriptor = new MojoDescriptor( );
descriptor.setId( id );
if(instantiationStrategy != null) {
descriptor.setInstantiationStrategy( instantiationStrategy );
}
if(executionStrategy != null) {
descriptor.setExecutionStrategy( executionStrategy );
}
if(goal != null) {
descriptor.setGoal(goal);
}
descriptor.setPrereqs(prereqs);
descriptor.setParameters(parameters);
return descriptor;
}
public void setPrereqs( List prereqs )
{
this.prereqs = prereqs;
}
public void setDependencies( List dependencies)
{
this.dependencies = dependencies;
}
public void setDescription( String description )
{
this.description = description;
}
public void setParameters(List parameters) {
this.parameters = parameters;
}
}

View File

@ -1,54 +0,0 @@
/* Created on Aug 7, 2004 */
package org.apache.maven.plugin.loader.marmalade.tags;
import org.apache.maven.plugin.descriptor.Parameter;
import org.codehaus.marmalade.model.AbstractMarmaladeTag;
import org.codehaus.marmalade.model.MarmaladeAttribute;
import org.codehaus.marmalade.model.MarmaladeAttributes;
import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
import org.codehaus.marmalade.runtime.MarmaladeExecutionException;
public class MojoParameterTag extends AbstractMarmaladeTag
implements DescriptionOwner
{
public static final String NAME_ATTRIBUTE = "name";
public static final String TYPE_ATTRIBUTE = "type";
public static final String REQUIRED_ATTRIBUTE = "required";
public static final String VALIDATOR_ATTRIBUTE = "validator";
public static final String EXPRESSION_ATTRIBUTE = "expression";
private Parameter param = new Parameter( );
protected void doExecute( MarmaladeExecutionContext context )
throws MarmaladeExecutionException
{
MarmaladeAttributes attributes = getAttributes( );
param.setName( ( String ) requireTagAttribute( NAME_ATTRIBUTE,
String.class, context ) );
param.setRequired( ( ( Boolean ) requireTagAttribute(
REQUIRED_ATTRIBUTE, Boolean.class, context ) ).booleanValue( ) );
param.setType( ( String ) requireTagAttribute( TYPE_ATTRIBUTE,
String.class, context ) );
param.setValidator( ( String ) requireTagAttribute(
VALIDATOR_ATTRIBUTE, String.class, context ) );
param.setExpression( String.valueOf(requireTagAttribute(
EXPRESSION_ATTRIBUTE, context ) ) );
processChildren( context );
if ( param.getDescription( ) == null )
{
throw new MarmaladeExecutionException(
"mojo parameters require a description" );
}
MojoParametersTag parent = ( MojoParametersTag ) requireParent( MojoParametersTag.class );
parent.addParameter( param );
}
public void setDescription( String description )
{
param.setDescription( description );
}
}

View File

@ -1,31 +0,0 @@
/* Created on Aug 7, 2004 */
package org.apache.maven.plugin.loader.marmalade.tags;
import java.util.LinkedList;
import java.util.List;
import org.apache.maven.plugin.descriptor.Parameter;
import org.codehaus.marmalade.model.AbstractMarmaladeTag;
import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
import org.codehaus.marmalade.runtime.MarmaladeExecutionException;
/**
* @author jdcasey
*/
public class MojoParametersTag extends AbstractMarmaladeTag {
private List parameters = new LinkedList();
protected void doExecute(MarmaladeExecutionContext context)
throws MarmaladeExecutionException {
processChildren(context);
MojoDescriptorTag parent = (MojoDescriptorTag)requireParent(MojoDescriptorTag.class);
parent.setParameters(parameters);
}
public void addParameter(Parameter param) {
parameters.add(param);
}
}

View File

@ -1,26 +0,0 @@
/* Created on Aug 7, 2004 */
package org.apache.maven.plugin.loader.marmalade.tags;
import org.codehaus.marmalade.el.ExpressionEvaluationException;
import org.codehaus.marmalade.model.AbstractMarmaladeTag;
import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
import org.codehaus.marmalade.runtime.MarmaladeExecutionException;
public class MojoPrereqTag extends AbstractMarmaladeTag {
private static final String NAME_ATTRIBUTE = "name";
protected boolean alwaysProcessChildren() {
// shouldn't even have children...
return false;
}
protected void doExecute(MarmaladeExecutionContext context)
throws MarmaladeExecutionException {
String prereq = (String)requireTagAttribute(NAME_ATTRIBUTE, String.class, context);
MojoPrereqsTag parent = (MojoPrereqsTag)requireParent(MojoPrereqsTag.class);
parent.addPrereq(prereq);
}
}

View File

@ -1,30 +0,0 @@
/* Created on Aug 7, 2004 */
package org.apache.maven.plugin.loader.marmalade.tags;
import java.util.LinkedList;
import java.util.List;
import org.codehaus.marmalade.model.AbstractMarmaladeTag;
import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
import org.codehaus.marmalade.runtime.MarmaladeExecutionException;
/**
* @author jdcasey
*/
public class MojoPrereqsTag extends AbstractMarmaladeTag {
private List prereqs = new LinkedList();
protected void doExecute(MarmaladeExecutionContext context)
throws MarmaladeExecutionException {
processChildren(context);
MojoDescriptorTag parent = (MojoDescriptorTag)requireParent(MojoDescriptorTag.class);
parent.setPrereqs(prereqs);
}
public void addPrereq(String prereq) {
prereqs.add(prereq);
}
}

View File

@ -1,81 +0,0 @@
/* Created on Aug 7, 2004 */
package org.apache.maven.plugin.loader.marmalade.tags;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.loader.marmalade.MarmaladeScriptMojo;
import org.codehaus.marmalade.model.AbstractMarmaladeTag;
import org.codehaus.marmalade.model.MarmaladeScript;
import org.codehaus.marmalade.model.MarmaladeTag;
import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
import org.codehaus.marmalade.runtime.MarmaladeExecutionException;
import org.codehaus.plexus.component.factory.marmalade.PlexusComponentTag;
/**
* @author jdcasey
*/
public class MojoTag extends AbstractMarmaladeTag implements PlexusComponentTag
{
private boolean describeOnly = false;
private List dependencies;
private MojoDescriptor descriptor;
private MarmaladeScriptMojo mojo;
protected boolean alwaysProcessChildren( )
{
return false;
}
protected void doExecute( MarmaladeExecutionContext context )
throws MarmaladeExecutionException
{
boolean describeOnly = describeOnly();
if(describeOnly) {
for (Iterator it = children().iterator(); it.hasNext();) {
MarmaladeTag child = (MarmaladeTag) it.next();
if(child instanceof MojoDescriptorTag) {
MojoDescriptorTag headerTag = (MojoDescriptorTag)child;
child.execute(context);
this.descriptor = headerTag.getMojoDescriptor();
this.dependencies = headerTag.getDependencies();
// we're done with the description phase.
break;
}
}
}
else {
MarmaladeScript script = new MarmaladeScript(getTagInfo().getSourceFile(), this);
this.mojo = new MarmaladeScriptMojo(script);
}
}
public MojoDescriptor getMojoDescriptor() {
return descriptor;
}
public List addDependencies(List accumulatedDependencies) {
accumulatedDependencies.addAll(dependencies);
return accumulatedDependencies;
}
public void describeOnly(boolean describeOnly) {
this.describeOnly = describeOnly;
}
public boolean describeOnly() {
return describeOnly;
}
public Object getComponent() {
return mojo;
}
}

View File

@ -1,40 +0,0 @@
/* Created on Aug 7, 2004 */
package org.apache.maven.plugin.loader.marmalade.tags;
import org.codehaus.marmalade.model.AbstractMarmaladeTagLibrary;
public class MojoTagLibrary extends AbstractMarmaladeTagLibrary {
public static final String MOJO_TAG = "mojo";
public static final String DESCRIPTOR_TAG = "descriptor";
public static final String PREREQS_TAG = "prereqs";
public static final String PREREQ_TAG = "prereq";
public static final String PARAMETERS_TAG = "parameters";
public static final String PARAMETER_TAG = "parameter";
public static final String DESCRIPTION_TAG = "description";
public static final String DEPENDENCIES_TAG = "dependencies";
public static final String DEPENDENCY_TAG = "dependency";
public MojoTagLibrary() {
registerTag(MOJO_TAG, MojoTag.class);
registerTag(DESCRIPTOR_TAG, MojoDescriptorTag.class);
registerTag(PREREQS_TAG, MojoPrereqsTag.class);
registerTag(PREREQ_TAG, MojoPrereqTag.class);
registerTag(PARAMETERS_TAG, MojoParametersTag.class);
registerTag(PARAMETER_TAG, MojoParameterTag.class);
registerTag(DESCRIPTION_TAG, DescriptionTag.class);
registerTag(DEPENDENCIES_TAG, MojoDependenciesTag.class);
registerTag(DEPENDENCY_TAG, MojoDependencyTag.class);
}
}

View File

@ -1 +0,0 @@
org.apache.maven.plugin.loader.marmalade.tags.MojoTagLibrary

View File

@ -1,157 +0,0 @@
/* Created on Aug 7, 2004 */
package org.apache.maven.plugin.loader.marmalade;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import org.apache.maven.plugin.MavenMojoDescriptor;
import org.apache.maven.plugin.MavenPluginDescriptor;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.Parameter;
import org.codehaus.classworlds.ClassRealm;
import org.codehaus.classworlds.ClassWorld;
import org.codehaus.classworlds.DefaultClassRealm;
import org.codehaus.plexus.component.repository.ComponentDependency;
import org.codehaus.plexus.component.repository.ComponentDescriptor;
import org.codehaus.plexus.component.repository.ComponentSetDescriptor;
import junit.framework.TestCase;
/**
* @author jdcasey
*/
public class MarmaladePluginDiscovererTest extends TestCase {
private static final String TEST_MOJO_SCRIPT = "<?xml version=\"1.0\"?>" +
"<mojo xmlns=\"marmalade:mojo\">" +
"<descriptor id=\"test\" goal=\"myTest\" instantiation-strategy=\"singleton\" execution-strategy=\"always\">" +
"<description>This is a test mojo script.</description>" +
"<prereqs><prereq name=\"test-prereq\"/></prereqs>" +
"<parameters>" +
"<parameter name=\"param\" type=\"String\" required=\"true\" validator=\"something\" expression=\"false\">" +
"<description>Parameter to test</description>" +
"</parameter>" +
"</parameters>" +
"<dependencies>" +
"<dependency groupId=\"marmalade\" artifactId=\"marmalade-core\" version=\"0.2\"/>" +
"</dependencies>" +
"</descriptor>" +
"<c:set xmlns:c=\"marmalade:jstl-core\" var=\"testVar\" value=\"testValue\"/>" +
"</mojo>";
public void testShouldFindPluginWithOneMojoFromClassDirectory() throws IOException {
File directory = new File("test-dir");
File scriptFile = new File(directory, "test.mmld");
try {
if (!directory.exists()) {
directory.mkdirs();
}
BufferedWriter writer = new BufferedWriter(new FileWriter(
scriptFile));
writer.write(TEST_MOJO_SCRIPT);
writer.flush();
writer.close();
ClassRealm realm = new DefaultClassRealm(new ClassWorld(), "root");
realm.addConstituent(directory.toURL());
MarmaladePluginDiscoverer discoverer = new MarmaladePluginDiscoverer();
List componentSets = discoverer.findComponents(realm);
verifyComponentSets(componentSets);
}
finally {
if(scriptFile.exists()) {
scriptFile.delete();
}
if(directory.exists()) {
directory.delete();
}
}
}
public void testShouldFindPluginWithOneMojoFromJar() throws IOException {
File jar = new File("test-plugin.jar");
try {
JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(jar));
jarOut.putNextEntry(new JarEntry("test.mmld"));
jarOut.write(TEST_MOJO_SCRIPT.getBytes());
jarOut.flush();
jarOut.closeEntry();
jarOut.close();
ClassRealm realm = new DefaultClassRealm(new ClassWorld(), "root");
realm.addConstituent(new URL("jar:" + jar.toURL().toExternalForm() + "!/"));
MarmaladePluginDiscoverer discoverer = new MarmaladePluginDiscoverer();
List componentSets = discoverer.findComponents(realm);
verifyComponentSets(componentSets);
}
finally {
if(jar.exists()) {
jar.delete();
}
}
}
private void verifyComponentSets(List componentSets) {
assertNotNull(componentSets);
assertEquals(1, componentSets.size());
ComponentSetDescriptor setDescriptor = (ComponentSetDescriptor) componentSets
.get(0);
List components = setDescriptor.getComponents();
assertNotNull(components);
assertEquals(1, components.size());
ComponentDescriptor descriptor = (ComponentDescriptor) components
.get(0);
assertEquals("marmalade", descriptor.getComponentFactory());
MavenMojoDescriptor mojoDesc = (MavenMojoDescriptor) descriptor;
MojoDescriptor mojo = mojoDesc.getMojoDescriptor();
assertEquals("test", mojo.getId());
assertEquals("myTest", mojo.getGoal());
assertEquals("singleton", mojo.getInstantiationStrategy());
assertEquals("always", mojo.getExecutionStrategy());
List prereqs = mojoDesc.getPrereqs();
assertEquals(1, prereqs.size());
assertEquals("test-prereq", prereqs.get(0));
List dependencies = setDescriptor.getDependencies();
assertEquals(1, dependencies.size());
ComponentDependency dep = (ComponentDependency)dependencies.get(0);
assertEquals("marmalade", dep.getGroupId());
assertEquals("marmalade-core", dep.getArtifactId());
assertEquals("0.2", dep.getVersion());
List parameters = mojo.getParameters();
assertEquals(1, parameters.size());
Parameter param = (Parameter)parameters.get(0);
assertEquals("param", param.getName());
assertEquals("String", param.getType());
assertEquals(true, param.isRequired());
assertEquals("something", param.getValidator());
assertEquals("false", param.getExpression());
}
}

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>maven</groupId>
<!--
| NOT inheriting from maven-plugin-tools, because that POM will have this
| as a dependency, for the convenience of implementation projects.
-->
<artifactId>maven-component</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>
<groupId>maven</groupId>
<artifactId>maven-plugin-tools-api</artifactId>
<name>Maven Plugin Tools APIs</name>
<version>2.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>modello</groupId>
<artifactId>modello</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-plugin</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-core</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>wagon-provider-api</artifactId>
<version>1.0-alpha-2-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -1,4 +1,4 @@
package org.apache.maven.plugin.generator;
package org.apache.maven.tools.plugin.extractor;
/*
* Copyright 2001-2004 The Apache Software Foundation.

View File

@ -0,0 +1,18 @@
package org.apache.maven.tools.plugin.extractor;
import org.apache.maven.project.MavenProject;
import java.util.Set;
/**
* @author jdcasey
*/
public interface MojoDescriptorExtractor
{
String ROLE = MojoDescriptorExtractor.class.getName();
Set execute(String sourceDir, MavenProject project)
throws Exception;
}

View File

@ -1,4 +1,4 @@
package org.apache.maven.plugin.generator;
package org.apache.maven.tools.plugin.generator;
/*
* Copyright 2001-2004 The Apache Software Foundation.
@ -16,40 +16,43 @@ package org.apache.maven.plugin.generator;
* limitations under the License.
*/
import org.apache.maven.plugin.MavenMojoDescriptor;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.project.MavenProject;
import org.codehaus.modello.generator.java.javasource.JClass;
import org.codehaus.modello.generator.java.javasource.JConstructor;
import org.codehaus.modello.generator.java.javasource.JMethod;
import org.codehaus.modello.generator.java.javasource.JParameter;
import org.codehaus.modello.generator.java.javasource.JSourceWriter;
import org.codehaus.modello.generator.java.javasource.JType;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.io.File;
import java.io.FileWriter;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
/**
* @todo use the descriptions in the descriptor for the javadoc pushed into
* the source code.
* @todo use the descriptions in the descriptor for the javadoc pushed into the
* source code.
*/
public class BeanGenerator
extends AbstractGenerator
implements Generator
{
protected void processPluginDescriptors( MojoDescriptor[] pluginDescriptors, String destinationDirectory, Xpp3Dom pomDom )
throws Exception
public void execute( String destinationDirectory, Set mavenMojoDescriptors, MavenProject project ) throws Exception
{
for ( int i = 0; i < pluginDescriptors.length; i++ )
for ( Iterator it = mavenMojoDescriptors.iterator(); it.hasNext(); )
{
processPluginDescriptor( pluginDescriptors[i], destinationDirectory );
MavenMojoDescriptor descriptor = (MavenMojoDescriptor) it.next();
processPluginDescriptor( descriptor, destinationDirectory );
}
}
protected void processPluginDescriptor( MojoDescriptor pluginDescriptor, String destinationDirectory )
protected void processPluginDescriptor( MavenMojoDescriptor descriptor, String destinationDirectory )
throws Exception
{
String implementation = pluginDescriptor.getImplementation();
String implementation = descriptor.getImplementation();
String className = implementation.substring( implementation.lastIndexOf( "." ) + 1 ) + "Bean";
@ -85,7 +88,8 @@ public class BeanGenerator
//
// ----------------------------------------------------------------------
List parameters = pluginDescriptor.getParameters();
MojoDescriptor mojoDescriptor = descriptor.getMojoDescriptor();
List parameters = mojoDescriptor.getParameters();
for ( int i = 0; i < parameters.size(); i++ )
{
@ -143,7 +147,8 @@ public class BeanGenerator
setter.addParameter( new JParameter( parameterType, parameter.getName() ) );
setter.getSourceCode().add( "addParameter( " + "\"" + parameter.getName() + "\", " + parameter.getName() + " );" );
setter.getSourceCode().add(
"addParameter( " + "\"" + parameter.getName() + "\", " + parameter.getName() + " );" );
return setter;
}
@ -155,10 +160,8 @@ public class BeanGenerator
return str;
}
return new StringBuffer( str.length() )
.append( Character.toTitleCase( str.charAt( 0 ) ) )
.append( str.substring( 1 ) )
.toString();
return new StringBuffer( str.length() ).append( Character.toTitleCase( str.charAt( 0 ) ) ).append(
str.substring( 1 ) ).toString();
}
protected String replace( String text, String repl, String with, int max )
@ -170,7 +173,7 @@ public class BeanGenerator
StringBuffer buf = new StringBuffer( text.length() );
int start = 0, end = 0;
while ( ( end = text.indexOf( repl, start ) ) != -1 )
while ( (end = text.indexOf( repl, start )) != -1 )
{
buf.append( text.substring( start, end ) ).append( with );
start = end + repl.length();

View File

@ -1,4 +1,8 @@
package org.apache.maven.plugin.generator;
package org.apache.maven.tools.plugin.generator;
import org.apache.maven.project.MavenProject;
import java.util.Set;
/*
* Copyright 2001-2004 The Apache Software Foundation.
@ -22,6 +26,8 @@ package org.apache.maven.plugin.generator;
*/
public interface Generator
{
void execute( String sourceDirectory, String destinationDirectory, String pom )
void execute( String destinationDirectory, Set mavenMojoDescriptors, MavenProject project)
throws Exception;
}

View File

@ -1,4 +1,4 @@
package org.apache.maven.plugin.generator;
package org.apache.maven.tools.plugin.generator;
/*
* Copyright 2001-2004 The Apache Software Foundation.
@ -16,26 +16,29 @@ package org.apache.maven.plugin.generator;
* limitations under the License.
*/
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.MavenMojoDescriptor;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.XMLWriter;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.tools.plugin.util.PluginUtils;
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
import org.codehaus.plexus.util.xml.XMLWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
/**
* @todo add example usage tag that can be shown in the doco
* @todo need to add validation directives so that systems embedding
* maven2 can get validation directives to help users in IDEs.
* @todo need to add validation directives so that systems embedding maven2 can
* get validation directives to help users in IDEs.
*/
public class PluginDescriptorGenerator
extends AbstractGenerator
implements Generator
{
protected void processPluginDescriptors( MojoDescriptor[] pluginDescriptors, String destinationDirectory, Xpp3Dom pomDom )
throws Exception
public void execute( String destinationDirectory, Set mavenMojoDescriptors, MavenProject project ) throws Exception
{
File f = new File( destinationDirectory, "plugin.xml" );
@ -50,20 +53,21 @@ public class PluginDescriptorGenerator
w.startElement( "plugin" );
element( w, "id", pluginId( pomDom ) );
element( w, "id", PluginUtils.pluginId( project ) );
element( w, "isolatedRealm", "true" );
w.startElement( "mojos" );
for ( int i = 0; i < pluginDescriptors.length; i++ )
for ( Iterator it = mavenMojoDescriptors.iterator(); it.hasNext(); )
{
processPluginDescriptor( pluginDescriptors[i], w, pomDom );
MavenMojoDescriptor descriptor = (MavenMojoDescriptor) it.next();
processPluginDescriptor( descriptor, w, project );
}
w.endElement();
writeDependencies( w, pomDom );
PluginUtils.writeDependencies( w, project );
w.endElement();
@ -72,9 +76,11 @@ public class PluginDescriptorGenerator
writer.close();
}
protected void processPluginDescriptor( MojoDescriptor mojoDescriptor, XMLWriter w, Xpp3Dom pomDom )
protected void processPluginDescriptor( MavenMojoDescriptor mavenMojoDescriptor, XMLWriter w, MavenProject project )
throws Exception
{
MojoDescriptor mojoDescriptor = mavenMojoDescriptor.getMojoDescriptor();
w.startElement( "mojo" );
// ----------------------------------------------------------------------
@ -115,15 +121,15 @@ public class PluginDescriptorGenerator
w.writeText( mojoDescriptor.getInstantiationStrategy() );
w.endElement();
// ----------------------------------------------------------------------
// Strategy for handling repeated reference to mojo in
// the calculated (decorated, resolved) execution stack
// Strategy for handling repeated reference to mojo in
// the calculated (decorated, resolved) execution stack
// ----------------------------------------------------------------------
w.startElement( "executionStrategy" );
w.writeText( mojoDescriptor.getExecutionStrategy() );
w.endElement();
// ----------------------------------------------------------------------
@ -165,7 +171,7 @@ public class PluginDescriptorGenerator
List prereqs = mojoDescriptor.getPrereqs();
if ( prereqs.size() > 0 )
if ( prereqs != null && prereqs.size() > 0 )
{
w.startElement( "prereqs" );
@ -184,69 +190,6 @@ public class PluginDescriptorGenerator
w.endElement();
}
public void writeDependencies( XMLWriter w, Xpp3Dom pomDom )
throws Exception
{
w.startElement( "dependencies" );
Xpp3Dom deps = pomDom.getChild( "dependencies" );
if ( deps != null )
{
Xpp3Dom dependencies[] = deps.getChildren( "dependency" );
for ( int i = 0; i < dependencies.length; i++ )
{
writeDependencyElement( dependencies[i], w );
}
}
w.endElement();
}
private void writeDependencyElement( Xpp3Dom dependency, XMLWriter w )
throws Exception
{
w.startElement( "dependency" );
Xpp3Dom groupId = dependency.getChild( "groupId" );
if ( groupId == null )
{
throw new Exception( "Missing dependency: 'groupId'." );
}
element( w, "groupId", groupId.getValue() );
Xpp3Dom artifactId = dependency.getChild( "artifactId" );
if ( artifactId == null )
{
throw new Exception( "Missing dependency: 'artifactId'." );
}
element( w, "artifactId", artifactId.getValue() );
Xpp3Dom type = dependency.getChild( "type" );
if ( type != null )
{
element( w, "type", type.getValue() );
}
Xpp3Dom version = dependency.getChild( "version" );
if ( version == null )
{
throw new Exception( "Missing dependency: 'version'." );
}
element( w, "version", version.getValue() );
w.endElement();
}
public void element( XMLWriter w, String name, String value )
{
w.startElement( name );

View File

@ -1,4 +1,4 @@
package org.apache.maven.plugin.generator;
package org.apache.maven.tools.plugin.generator;
/*
* Copyright 2001-2004 The Apache Software Foundation.
@ -16,37 +16,42 @@ package org.apache.maven.plugin.generator;
* limitations under the License.
*/
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.MavenMojoDescriptor;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.XMLWriter;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
import org.codehaus.plexus.util.xml.XMLWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @todo add example usage tag that can be shown in the doco
* @todo need to add validation directives so that systems embedding
* maven2 can get validation directives to help users in IDEs.
* @todo need to add validation directives so that systems embedding maven2 can
* get validation directives to help users in IDEs.
*/
public class PluginXdocGenerator
extends AbstractGenerator
implements Generator
{
protected void processPluginDescriptors( MojoDescriptor[] mojoDescriptors, String destinationDirectory, Xpp3Dom pomDom )
throws Exception
public void execute( String destinationDirectory, Set mavenMojoDescriptors, MavenProject project ) throws Exception
{
for ( int i = 0; i < mojoDescriptors.length; i++ )
for ( Iterator it = mavenMojoDescriptors.iterator(); it.hasNext(); )
{
processPluginDescriptor( mojoDescriptors[i], destinationDirectory );
MavenMojoDescriptor descriptor = (MavenMojoDescriptor) it.next();
processPluginDescriptor( descriptor, destinationDirectory );
}
}
protected void processPluginDescriptor( MojoDescriptor mojoDescriptor, String destinationDirectory )
protected void processPluginDescriptor( MavenMojoDescriptor descriptor, String destinationDirectory )
throws Exception
{
MojoDescriptor mojoDescriptor = descriptor.getMojoDescriptor();
String id = mojoDescriptor.getId();
FileWriter writer = new FileWriter( new File( destinationDirectory, id + "-plugin.xml" ) );
@ -135,8 +140,7 @@ public class PluginXdocGenerator
writer.close();
}
private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w )
throws Exception
private void writeGoalParameterTable( MojoDescriptor mojoDescriptor, XMLWriter w ) throws Exception
{
w.startElement( "p" );

View File

@ -1,4 +1,4 @@
package org.apache.maven.plugin.generator.jelly;
package org.apache.maven.tools.plugin.generator.jelly;
/*
* Copyright 2001-2004 The Apache Software Foundation.
@ -16,16 +16,20 @@ package org.apache.maven.plugin.generator.jelly;
* limitations under the License.
*/
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.MavenMojoDescriptor;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.generator.AbstractGenerator;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.tools.plugin.generator.Generator;
import org.apache.maven.tools.plugin.util.PluginUtils;
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
import org.codehaus.plexus.util.xml.XMLWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
/**
* @todo use the descriptions in the descriptor for the javadoc pushed into the source code.
@ -34,21 +38,21 @@ import java.util.List;
* will serve as the trigger to download dependencies.
*/
public class JellyHarnessGenerator
extends AbstractGenerator
implements Generator
{
protected String getClassName( MojoDescriptor pluginDescriptor )
{
return pluginDescriptor.getImplementation() + "Bean";
}
protected void processPluginDescriptors( MojoDescriptor[] mojoDescriptors, String destinationDirectory, Xpp3Dom pomDom )
public void execute( String destinationDirectory, Set mavenMojoDescriptors, MavenProject project)
throws Exception
{
FileWriter writer = new FileWriter( new File( destinationDirectory, "plugin.jelly" ) );
PrettyPrintXMLWriter w = new PrettyPrintXMLWriter( writer );
String pluginId = pluginId( pomDom );
String pluginId = PluginUtils.pluginId( project );
// ----------------------------------------------------------------------
//
@ -69,10 +73,11 @@ public class JellyHarnessGenerator
w.startElement( "d:taglib" );
w.addAttribute( "uri", pluginId );
for ( int i = 0; i < mojoDescriptors.length; i++ )
for ( Iterator it = mavenMojoDescriptors.iterator(); it.hasNext(); )
{
processPluginDescriptor( mojoDescriptors[i], w, pomDom );
MavenMojoDescriptor descriptor = (MavenMojoDescriptor) it.next();
processPluginDescriptor(descriptor, w, project);
}
w.endElement();
@ -81,9 +86,10 @@ public class JellyHarnessGenerator
//
// ----------------------------------------------------------------------
for ( int i = 0; i < mojoDescriptors.length; i++ )
for ( Iterator it = mavenMojoDescriptors.iterator(); it.hasNext(); )
{
writeGoals( mojoDescriptors[i], w );
MavenMojoDescriptor descriptor = (MavenMojoDescriptor) it.next();
writeGoals(descriptor, w);
}
// ----------------------------------------------------------------------
@ -112,7 +118,7 @@ public class JellyHarnessGenerator
w.startElement( "dependencies" );
writeDependencies( w, pomDom );
PluginUtils.writeDependencies( w, project );
w.endElement();
@ -124,10 +130,12 @@ public class JellyHarnessGenerator
}
protected void processPluginDescriptor( MojoDescriptor mojoDescriptor, XMLWriter w, Xpp3Dom pomDom )
protected void processPluginDescriptor( MavenMojoDescriptor descriptor, XMLWriter w, MavenProject project)
throws Exception
{
String pluginId = pluginId( pomDom );
MojoDescriptor mojoDescriptor = descriptor.getMojoDescriptor();
String pluginId = PluginUtils.pluginId( project );
String goalName = mojoDescriptor.getGoal();
@ -198,8 +206,10 @@ public class JellyHarnessGenerator
w.endElement();
}
private void writeGoals( MojoDescriptor mojoDescriptor, XMLWriter w )
private void writeGoals( MavenMojoDescriptor descriptor, XMLWriter w )
{
MojoDescriptor mojoDescriptor = descriptor.getMojoDescriptor();
String id = mojoDescriptor.getId();
w.startElement( "goal" );
@ -262,56 +272,6 @@ public class JellyHarnessGenerator
w.endElement();
}
protected void writeDependencies( XMLWriter w, Xpp3Dom pomDom )
{
writeDependency( w, "maven", "maven-plugin", "2.0-SNAPSHOT" );
Xpp3Dom depElement = pomDom.getChild( "dependencies" );
if ( depElement != null )
{
Xpp3Dom[] deps = depElement.getChildren( "dependency" );
for ( int i = 0; i < deps.length; i++ )
{
Xpp3Dom dep = deps[i];
String groupId = dep.getChild( "artifactId" ).getValue();
String artifactId = dep.getChild( "groupId" ).getValue();
String version = dep.getChild( "version" ).getValue();
writeDependency( w, groupId, artifactId, version );
}
}
}
protected void writeDependency( XMLWriter w, String groupId, String artifactId, String version )
{
w.startElement( "dependency" );
w.startElement( "groupId" );
w.writeText( groupId );
w.endElement();
w.startElement( "artifactId" );
w.writeText( artifactId );
w.endElement();
w.startElement( "version" );
w.writeText( version );
w.endElement();
w.endElement();
}
protected String capitalise( String str )
{
if ( str == null || str.length() == 0 )

View File

@ -0,0 +1,70 @@
package org.apache.maven.tools.plugin.scanner;
import org.apache.maven.model.Build;
import org.apache.maven.project.MavenProject;
import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
import java.io.File;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
/**
* @author jdcasey
*/
public class DefaultMojoScanner
implements MojoScanner
{
private Map mojoDescriptorExtractors;
public DefaultMojoScanner( Map extractors )
{
this.mojoDescriptorExtractors = extractors;
}
public DefaultMojoScanner()
{
}
public Set execute( MavenProject project ) throws Exception
{
Set descriptors = new HashSet();
for ( Iterator it = mojoDescriptorExtractors.entrySet().iterator(); it.hasNext(); )
{
Map.Entry entry = (Map.Entry) it.next();
String language = (String) entry.getKey();
MojoDescriptorExtractor extractor = (MojoDescriptorExtractor) entry.getValue();
String sourceDir = null;
File basedir = project.getBasedir();
Build buildSection = project.getBuild();
if ( buildSection != null )
{
sourceDir = buildSection.getSourceDirectory();
}
if ( sourceDir == null )
{
sourceDir = "src/main/java";
}
File src = new File(basedir, sourceDir);
sourceDir = src.getAbsolutePath();
Set extractorDescriptors = extractor.execute( sourceDir, project );
System.out.println("Extractor for language: " + language + " found " + extractorDescriptors.size() + " mojo descriptors.");
descriptors.addAll( extractorDescriptors );
}
return descriptors;
}
}

View File

@ -0,0 +1,17 @@
package org.apache.maven.tools.plugin.scanner;
import org.apache.maven.project.MavenProject;
import java.util.Set;
/**
* @author jdcasey
*/
public interface MojoScanner
{
String ROLE = MojoScanner.class.getName();
Set execute(MavenProject project) throws Exception;
}

View File

@ -0,0 +1,98 @@
package org.apache.maven.tools.plugin.util;
import org.apache.maven.model.Dependency;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.XMLWriter;
import java.util.Iterator;
/**
* @author jdcasey
*/
public final class PluginUtils
{
private PluginUtils()
{
}
public static String pluginId( MavenProject project )
{
// ----------------------------------------------------------------------
// We will take the id from the artifactId of the POM. The artifactId is
// always of the form maven-<pluginId>-plugin so we can extract the
// pluginId from the artifactId.
// ----------------------------------------------------------------------
String artifactId = project.getArtifactId();
int firstHyphen = artifactId.indexOf( "-" );
int lastHyphen = artifactId.lastIndexOf( "-" );
String pluginId = artifactId.substring( firstHyphen + 1, lastHyphen );
return pluginId;
}
public static String[] findSources( String basedir, String include )
{
return PluginUtils.findSources( basedir, include, null );
}
public static String[] findSources( String basedir, String include, String exclude )
{
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( basedir );
scanner.setIncludes( new String[] { include } );
if ( !StringUtils.isEmpty( exclude ) )
{
scanner.setExcludes( new String[] { exclude } );
}
scanner.scan();
return scanner.getIncludedFiles();
}
public static void writeDependencies( XMLWriter w, MavenProject project ) throws Exception
{
w.startElement( "dependencies" );
for ( Iterator it = project.getDependencies().iterator(); it.hasNext(); )
{
Dependency dep = (Dependency) it.next();
w.startElement( "dependency" );
PluginUtils.element( w, "groupId", dep.getGroupId() );
PluginUtils.element( w, "artifactId", dep.getArtifactId() );
PluginUtils.element( w, "type", dep.getType() );
PluginUtils.element( w, "version", dep.getVersion() );
w.endElement();
}
w.endElement();
}
private static void element( XMLWriter w, String name, String value )
{
w.startElement( name );
if ( value == null )
{
value = "";
}
w.writeText( value );
w.endElement();
}
}

View File

@ -0,0 +1,22 @@
<component-set>
<components>
<!--
|
| MojoScanner, used to scan all types of mojo sources to extract descriptor
| information using various MojoDescriptorExtractor's
|
-->
<component>
<role>org.apache.maven.tools.plugin.scanner.MojoScanner</role>
<implementation>org.apache.maven.tools.plugin.scanner.DefaultMojoScanner</implementation>
<requirements>
<requirement>
<role>org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor</role>
<field-name>mojoDescriptorExtractors</field-name>
</requirement>
</requirements>
</component>
</components>
</component-set>

View File

@ -1,4 +1,4 @@
package org.apache.maven.plugin.generator;
package org.apache.maven.tools.plugin.generator;
/*
* Copyright 2001-2004 The Apache Software Foundation.
@ -16,9 +16,20 @@ package org.apache.maven.plugin.generator;
* limitations under the License.
*/
import junit.framework.TestCase;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.plugin.MavenMojoDescriptor;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.project.MavenProject;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import junit.framework.TestCase;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
@ -47,8 +58,45 @@ public abstract class AbstractGeneratorTestCase
String destinationDirectory = new File( basedir, "target" ).getPath();
String pom = new File( basedir, "src/test/resources/source/pom.xml" ).getPath();
generator.execute( sourceDirectory, destinationDirectory, pom );
MojoDescriptor mojoDescriptor = new MojoDescriptor();
mojoDescriptor.setGoal("testGoal");
mojoDescriptor.setId("test");
mojoDescriptor.setImplementation("org.apache.maven.tools.plugin.generator.TestMojo");
mojoDescriptor.setRequiresDependencyResolution(true);
List params = new ArrayList();
Parameter param = new Parameter();
param.setDefaultValue("value");
param.setExpression("#project.build.directory");
param.setName("dir");
param.setRequired(true);
param.setType("String");
param.setDescription("Test parameter description");
params.add(param);
mojoDescriptor.setParameters(params);
MavenMojoDescriptor mmDesc = new MavenMojoDescriptor(mojoDescriptor);
Set descriptors = Collections.singleton(mmDesc);
Model model = new Model();
model.setArtifactId("maven-unitTesting-plugin");
Dependency dependency = new Dependency();
dependency.setGroupId("testGroup");
dependency.setArtifactId("testArtifact");
dependency.setVersion("0.0.0");
model.addDependency(dependency);
MavenProject project = new MavenProject(model);
generator.execute( destinationDirectory, descriptors, project );
validate();
}

View File

@ -0,0 +1,124 @@
package org.apache.maven.tools.plugin.generator;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.plugin.descriptor.Dependency;
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.descriptor.PluginDescriptorBuilder;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.List;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
* @version $Id: PluginDescriptorGeneratorTest.java,v 1.1.1.1 2004/08/09
* 18:43:10 jvanzyl Exp $
*/
public class PluginDescriptorGeneratorTest
extends AbstractGeneratorTestCase
{
protected void validate() throws Exception
{
PluginDescriptorBuilder pdb = new PluginDescriptorBuilder();
File pluginDescriptorFile = new File( basedir, "target/plugin.xml" );
String pd = readFile( pluginDescriptorFile );
PluginDescriptor pluginDescriptor = pdb.build( new StringReader( pd ) );
MojoDescriptor mojoDescriptor = (MojoDescriptor) pluginDescriptor.getMojos().get( 0 );
checkMojo( mojoDescriptor );
// ----------------------------------------------------------------------
// Dependencies
// ----------------------------------------------------------------------
List dependencies = pluginDescriptor.getDependencies();
checkDependency( "testGroup", "testArtifact", "0.0.0", (Dependency) dependencies.get( 0 ) );
assertEquals( 1, dependencies.size() );
Dependency dependency = (Dependency) dependencies.get( 0 );
assertEquals( "testGroup", dependency.getGroupId() );
assertEquals( "testArtifact", dependency.getArtifactId() );
assertEquals( "0.0.0", dependency.getVersion() );
}
private String readFile( File pluginDescriptorFile ) throws IOException
{
StringWriter sWriter = new StringWriter();
PrintWriter pWriter = new PrintWriter( sWriter );
BufferedReader reader = new BufferedReader( new FileReader( pluginDescriptorFile ) );
String line = null;
while ( (line = reader.readLine()) != null )
{
pWriter.println( line );
}
reader.close();
return sWriter.toString();
}
private void checkMojo( MojoDescriptor mojoDescriptor )
{
assertEquals( "test:testGoal", mojoDescriptor.getId() );
assertEquals( "org.apache.maven.tools.plugin.generator.TestMojo", mojoDescriptor.getImplementation() );
// The following should be defaults
assertEquals( "singleton", mojoDescriptor.getInstantiationStrategy() );
assertTrue( mojoDescriptor.requiresDependencyResolution() );
// check the parameter.
checkParameter( (Parameter) mojoDescriptor.getParameters().get( 0 ) );
}
private void checkParameter( Parameter parameter )
{
assertEquals( "value", parameter.getDefaultValue() );
assertEquals( "#project.build.directory", parameter.getExpression() );
assertEquals( "dir", parameter.getName() );
assertEquals( "String", parameter.getType() );
assertTrue( parameter.isRequired() );
}
private void checkDependency( String groupId, String artifactId, String version, Dependency dependency )
{
assertNotNull( dependency );
assertEquals( groupId, dependency.getGroupId() );
assertEquals( artifactId, dependency.getArtifactId() );
assertEquals( version, dependency.getVersion() );
}
}

View File

@ -1,4 +1,4 @@
package org.apache.maven.plugin.generator;
package org.apache.maven.tools.plugin.generator;
/*
* Copyright 2001-2004 The Apache Software Foundation.

View File

@ -0,0 +1,46 @@
package org.apache.maven.tools.plugin.scanner;
import org.apache.maven.model.Build;
import org.apache.maven.model.Model;
import org.apache.maven.plugin.MavenMojoDescriptor;
import org.apache.maven.project.MavenProject;
import java.io.File;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import junit.framework.TestCase;
/**
* @author jdcasey
*/
public class DefaultMojoScannerTest
extends TestCase
{
public void testShouldFindOneDescriptorFromTestExtractor() throws Exception
{
Map extractors = Collections.singletonMap("test", new TestExtractor());
MojoScanner scanner = new DefaultMojoScanner(extractors);
Build build = new Build();
build.setSourceDirectory("testdir");
Model model = new Model();
model.setBuild(build);
MavenProject project = new MavenProject(model);
project.setFile(new File("."));
Set descriptors = scanner.execute(project);
assertEquals(1, descriptors.size());
MavenMojoDescriptor mmDesc = (MavenMojoDescriptor)descriptors.iterator().next();
assertEquals("testPluginId", mmDesc.getMojoDescriptor().getId());
assertEquals("testGoal", mmDesc.getMojoDescriptor().getGoal());
}
}

View File

@ -0,0 +1,29 @@
package org.apache.maven.tools.plugin.scanner;
import org.apache.maven.plugin.MavenMojoDescriptor;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.project.MavenProject;
import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
import java.util.Collections;
import java.util.Set;
/**
* @author jdcasey
*/
public class TestExtractor
implements MojoDescriptorExtractor
{
public Set execute( String sourceDir, MavenProject project ) throws Exception
{
MojoDescriptor desc = new MojoDescriptor();
desc.setId("testPluginId");
desc.setGoal("testGoal");
MavenMojoDescriptor mmDesc = new MavenMojoDescriptor(desc);
return Collections.singleton(mmDesc);
}
}

View File

@ -0,0 +1,89 @@
package org.apache.maven.tools.plugin.util;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.xml.CompactXMLWriter;
import org.codehaus.plexus.util.xml.XMLWriter;
import java.io.StringWriter;
import junit.framework.TestCase;
/**
* @author jdcasey
*/
public class PluginUtilsTest
extends TestCase
{
public void testShouldTrimArtifactIdToFindPluginId()
{
Model model = new Model();
model.setArtifactId( "test-artifactId-plugin" );
MavenProject project = new MavenProject( model );
String pluginId = PluginUtils.pluginId( project );
System.out.println( pluginId );
}
public void testShouldWriteDependencies() throws Exception
{
Dependency dependency = new Dependency();
dependency.setArtifactId("testArtifactId");
dependency.setGroupId("testGroupId");
dependency.setType("pom");
dependency.setVersion("0.0.0");
Model model = new Model();
model.addDependency(dependency);
MavenProject project = new MavenProject(model);
StringWriter sWriter = new StringWriter();
XMLWriter writer = new CompactXMLWriter(sWriter);
PluginUtils.writeDependencies(writer, project);
String output = sWriter.toString();
String pattern = "<dependencies>" +
"<dependency>" +
"<groupId>testGroupId</groupId>" +
"<artifactId>testArtifactId</artifactId>" +
"<type>pom</type>" +
"<version>0.0.0</version>" +
"</dependency>" +
"</dependencies>";
assertEquals(pattern, output);
}
public void testShouldFindTwoScriptsWhenNoExcludesAreGiven()
{
String testScript = "test.txt";
String basedir = TestUtils.dirname(testScript);
String includes = "**/*.txt";
String[] files = PluginUtils.findSources(basedir, includes);
assertEquals(2, files.length);
}
public void testShouldFindOneScriptsWhenAnExcludeIsGiven()
{
String testScript = "test.txt";
String basedir = TestUtils.dirname(testScript);
String includes = "**/*.txt";
String excludes = "**/*Excludes.txt";
String[] files = PluginUtils.findSources(basedir, includes, excludes);
assertEquals(1, files.length);
}
}

View File

@ -0,0 +1,34 @@
package org.apache.maven.tools.plugin.util;
import java.net.URL;
import junit.framework.TestCase;
/**
* @author jdcasey
*/
public class TestUtils extends TestCase
{
public void testDirnameFunction_METATEST()
{
String classname = getClass().getName().replace('.', '/') + ".class";
String basedir = TestUtils.dirname(classname);
ClassLoader cl = Thread.currentThread().getContextClassLoader();
URL resource = cl.getResource(classname);
assertEquals(resource.getPath(), basedir + classname);
}
public static String dirname( String file )
{
ClassLoader cl = Thread.currentThread().getContextClassLoader();
URL fileResource = cl.getResource(file);
String fullPath = fileResource.getPath();
return fullPath.substring(0, fullPath.length() - file.length());
}
}

View File

@ -0,0 +1,21 @@
<component-set>
<components>
<component>
<role>org.apache.maven.tools.plugin.scanner.MojoScanner</role>
<implementation>org.apache.maven.tools.plugin.scanner.DefaultMojoScanner</implementation>
<requirements>
<requirement>
<role>org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor</role>
<field-name>mojoDescriptorExtractors</field-name>
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor</role>
<role-hint>test</role-hint>
<implementation>org.apache.maven.tools.plugin.scanner.TestExtractor</implementation>
</component>
</components>
</component-set>

View File

@ -0,0 +1 @@
This is a test.

View File

@ -0,0 +1 @@
This is a test.

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>maven</groupId>
<artifactId>maven-plugin-tools</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>
<groupId>maven</groupId>
<artifactId>maven-plugin-tools-java</artifactId>
<name>Maven Plugin Tools for Java</name>
<version>2.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>qdox</groupId>
<artifactId>qdox</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>modello</groupId>
<artifactId>modello</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-core</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-plugin</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-plugin-tools-api</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -1,4 +1,4 @@
package org.apache.maven.plugin.generator;
package org.apache.maven.tools.plugin.extractor.java;
/*
* Copyright 2001-2004 The Apache Software Foundation.
@ -16,27 +16,32 @@ package org.apache.maven.plugin.generator;
* limitations under the License.
*/
import org.apache.maven.plugin.MavenMojoDescriptor;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.tools.plugin.extractor.InvalidParameterException;
import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
import org.apache.maven.tools.plugin.util.PluginUtils;
import com.thoughtworks.qdox.JavaDocBuilder;
import com.thoughtworks.qdox.model.DocletTag;
import com.thoughtworks.qdox.model.JavaClass;
import com.thoughtworks.qdox.model.JavaSource;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.Parameter;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @todo add example usage tag that can be shown in the doco
* @todo need to add validation directives so that systems embedding
* maven2 can get validation directives to help users in IDEs.
* @todo need to add validation directives so that systems embedding maven2 can
* get validation directives to help users in IDEs.
*/
public abstract class AbstractGenerator
implements Generator
public class JavaMojoDescriptorExtractor
implements MojoDescriptorExtractor
{
public static final String MAVEN_PLUGIN_ID = "maven.plugin.id";
@ -50,7 +55,7 @@ public abstract class AbstractGenerator
public static final String GOAL = "goal";
public static final String DISPATCH = "dispatch";
public static final String DISPATCH = "dispatch";
public static final String GOAL_DESCRIPTION = "description";
@ -60,61 +65,7 @@ public abstract class AbstractGenerator
public static final String GOAL_MULTI_EXECUTION_STRATEGY = "attainAlways";
protected abstract void processPluginDescriptors( MojoDescriptor[] pluginDescriptors, String destinationDirectory, Xpp3Dom pomDom )
throws Exception;
protected Xpp3Dom readModel( String pom )
throws Exception
{
return Xpp3DomBuilder.build( new FileReader( pom ) );
}
public void execute( String sourceDirectory, String destinationDirectory, String pom )
throws Exception
{
Xpp3Dom pomDom = readModel( pom );
JavaDocBuilder builder = new JavaDocBuilder();
File sourceDirectoryFile = new File( sourceDirectory );
builder.addSourceTree( sourceDirectoryFile );
JavaSource[] javaSources = builder.getSources();
List mojoDescriptors = new ArrayList();
for ( int i = 0; i < javaSources.length; i++ )
{
DocletTag tag = getJavaClass( javaSources[i] ).getTagByName( GOAL );
if ( tag != null )
{
MojoDescriptor mojoDescriptor = createMojoDescriptor( javaSources[i], pomDom );
// ----------------------------------------------------------------------
// Validate the descriptor as best we can before allowing it
// to be processed.
// ----------------------------------------------------------------------
List parameters = mojoDescriptor.getParameters();
for ( int j = 0; j < parameters.size(); j++ )
{
validateParameter( (Parameter) parameters.get( j ), j );
}
mojoDescriptors.add( mojoDescriptor );
}
}
MojoDescriptor[] mojos = (MojoDescriptor[]) mojoDescriptors.toArray( new MojoDescriptor[mojoDescriptors.size()] );
processPluginDescriptors( mojos, destinationDirectory, pomDom );
}
protected void validateParameter( Parameter parameter, int i )
throws InvalidParameterException
protected void validateParameter( Parameter parameter, int i ) throws InvalidParameterException
{
String name = parameter.getName();
@ -154,30 +105,11 @@ public abstract class AbstractGenerator
}
}
protected String pluginId( Xpp3Dom pomDom )
{
// ----------------------------------------------------------------------
// We will take the id from the artifactId of the POM. The artifactId is
// always of the form maven-<pluginId>-plugin so we can extract the
// pluginId from the artifactId.
// ----------------------------------------------------------------------
String artifactId = pomDom.getChild( "artifactId" ).getValue();
int firstHyphen = artifactId.indexOf( "-" );
int lastHyphen = artifactId.lastIndexOf( "-" );
String pluginId = artifactId.substring( firstHyphen + 1, lastHyphen );
return pluginId;
}
// ----------------------------------------------------------------------
// Plugin descriptor creation from @tags
// ----------------------------------------------------------------------
private MojoDescriptor createMojoDescriptor( JavaSource javaSource, Xpp3Dom pomDom )
private MojoDescriptor createMojoDescriptor( JavaSource javaSource, MavenProject project )
{
MojoDescriptor mojoDescriptor = new MojoDescriptor();
@ -187,7 +119,7 @@ public abstract class AbstractGenerator
DocletTag tag;
String pluginId = pluginId( pomDom );
String pluginId = PluginUtils.pluginId( project );
mojoDescriptor.setId( pluginId );
@ -295,4 +227,50 @@ public abstract class AbstractGenerator
{
return javaSource.getClasses()[0];
}
public Set execute( String sourceDir, MavenProject project ) throws Exception
{
JavaDocBuilder builder = new JavaDocBuilder();
File sourceDirectoryFile = new File( sourceDir );
builder.addSourceTree( sourceDirectoryFile );
JavaSource[] javaSources = builder.getSources();
Set descriptors = new HashSet();
for ( int i = 0; i < javaSources.length; i++ )
{
DocletTag tag = getJavaClass( javaSources[i] ).getTagByName( GOAL );
if ( tag != null )
{
MojoDescriptor mojoDescriptor = createMojoDescriptor( javaSources[i], project );
// ----------------------------------------------------------------------
// Validate the descriptor as best we can before allowing it
// to be processed.
// ----------------------------------------------------------------------
List parameters = mojoDescriptor.getParameters();
for ( int j = 0; j < parameters.size(); j++ )
{
validateParameter( (Parameter) parameters.get( j ), j );
}
MavenMojoDescriptor mmDescriptor = new MavenMojoDescriptor(mojoDescriptor);
JavaClass javaClass = getJavaClass(javaSources[i]);
mmDescriptor.setImplementation(javaClass.getFullyQualifiedName());
descriptors.add( mmDescriptor );
}
}
return descriptors;
}
}

View File

@ -0,0 +1,17 @@
<component-set>
<components>
<!--
|
| JavaMojoDescriptorExtractor, a MojoDescriptor extractor to read
| descriptors from java sources.
|
-->
<component>
<role>org.apache.maven.tools.plugin.extractor.MojoDescriptorExtrator</role>
<role-hint>java</role-hint>
<implementation>org.apache.maven.tools.plugin.extractor.JavaMojoDescriptorExtrator</implementation>
</component>
</components>
</component-set>

View File

@ -0,0 +1,51 @@
package org.apache.maven.tools.plugin.extractor.java;
import org.apache.maven.model.Model;
import org.apache.maven.project.MavenProject;
import java.io.File;
import java.net.URL;
import java.util.Set;
import junit.framework.TestCase;
/**
* @author jdcasey
*/
public class JavaMojoDescriptorExtractorTest
extends TestCase
{
public void testShouldFindTwoMojoDescriptorsInTestSourceDirectory() throws Exception
{
JavaMojoDescriptorExtractor extractor = new JavaMojoDescriptorExtractor();
File sourceFile = fileOf("dir-flag.txt");
System.out.println("found source file: " + sourceFile);
File dir = sourceFile.getParentFile();
Model model = new Model();
model.setArtifactId("maven-unitTesting-plugin");
MavenProject project = new MavenProject(model);
Set results = extractor.execute(dir.getAbsolutePath(), project);
assertEquals(2, results.size());
}
private File fileOf(String classpathResource)
{
ClassLoader cl = Thread.currentThread().getContextClassLoader();
URL resource = cl.getResource(classpathResource);
File result = null;
if(resource != null)
{
result = new File(resource.getPath());
}
return result;
}
}

View File

@ -0,0 +1,10 @@
This file is used by ClassLoader.getResource() to find the current path to the
test resources. Uses this code:
URL resource = classloader.getResource("dir-flag.txt");
File resourceFile = new File(resource.getPath());
File testResourcesDir= resourceFile.getParentFile();
This way, the unit test can depend on a FileReader or somesuch, and still work
fine regardless of ${user.dir} as long as the classpath is right. Useful for
Eclipse...

View File

@ -1,38 +1,38 @@
package org.apache.maven.plugin.idea;
package source;
import org.apache.maven.project.MavenProject;
import org.apache.maven.plugin.AbstractPlugin;
import org.apache.maven.plugin.PluginExecutionRequest;
import org.apache.maven.plugin.PluginExecutionResponse;
/**
* @goal ideaTwo
* @goal ideaOne
*
* @description Create an IDEA project file from a Maven project.
*
* @requiresDependencyResolution
*
* @prereq foo
* @prereq bar
*
* @parameter
* name="project"
* type="MavenProject"
* type="String[]"
* required="true"
* validator="org.foo.validator"
* expression="#project"
* description="Maven project used to generate IDEA project files."
*/
public class IdeaMojoTwo
public class JavaExtractorTestOne
extends AbstractPlugin
{
protected IdeaWriter ideaWriter;
protected String var;
public IdeaPlugin()
public JavaExtractorTestOne()
{
ideaWriter = new IdeaWriter();
}
public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
throws Exception
{
MavenProject project = (MavenProject) request.getParameter( "project" );
ideaWriter.write( project );
}
}

View File

@ -1,4 +1,4 @@
package org.apache.maven.plugin.idea;
package source;
import org.apache.maven.project.MavenProject;
import org.apache.maven.plugin.AbstractPlugin;
@ -6,7 +6,7 @@ import org.apache.maven.plugin.PluginExecutionRequest;
import org.apache.maven.plugin.PluginExecutionResponse;
/**
* @goal ideaOne
* @goal ideaTwo
*
* @description Create an IDEA project file from a Maven project.
*
@ -23,21 +23,17 @@ import org.apache.maven.plugin.PluginExecutionResponse;
* expression="#project"
* description="Maven project used to generate IDEA project files."
*/
public class IdeaMojoOne
public class JavaExtractorTestTwo
extends AbstractPlugin
{
protected IdeaWriter ideaWriter;
protected String var;
public IdeaPlugin()
public JavaExtractorTestTwo()
{
ideaWriter = new IdeaWriter();
}
public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
throws Exception
{
MavenProject project = (MavenProject) request.getParameter( "project" );
ideaWriter.write( project );
}
}

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>maven</groupId>
<artifactId>maven-plugin-tools</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>
<groupId>maven</groupId>
<artifactId>maven-plugin-tools-marmalade</artifactId>
<name>Maven Plugin Tools for Marmalade</name>
<version>2.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>marmalade</groupId>
<artifactId>marmalade-core</artifactId>
<version>1.0-alpha2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-script-marmalade</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-plugin</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-plugin-tools-api</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-core</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,59 @@
package org.apache.maven.tools.plugin.extractor.marmalade;
import org.apache.maven.plugin.MavenMojoDescriptor;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.project.MavenProject;
import org.apache.maven.script.marmalade.MarmaladeMojoExecutionDirectives;
import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
import org.apache.maven.tools.plugin.util.PluginUtils;
import org.codehaus.marmalade.parsing.ScriptParser;
import org.codehaus.marmalade.util.LazyMansAccess;
import java.io.File;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
/**
* @author jdcasey
*/
public class MarmaladeMojoDescriptorExtractor
implements MojoDescriptorExtractor
{
private ScriptParser scriptParser = new ScriptParser();
public Set execute( String sourceDir, MavenProject project ) throws Exception
{
String[] files = PluginUtils.findSources( sourceDir, "**/*.mmld" );
Set descriptors = new HashSet();
File dir = new File( sourceDir );
for ( int i = 0; i < files.length; i++ )
{
String file = files[i];
Map context = new TreeMap();
context.put( MarmaladeMojoExecutionDirectives.SCRIPT_BASEPATH_INVAR, sourceDir );
File scriptFile = new File( dir, file );
context = LazyMansAccess.executeFromFile( scriptFile, context );
MojoDescriptor descriptor = (MojoDescriptor) context.get( MarmaladeMojoExecutionDirectives.METADATA_OUTVAR );
MavenMojoDescriptor mmDescriptor = new MavenMojoDescriptor( descriptor );
mmDescriptor.setComponentFactory( "marmalade" );
mmDescriptor.setImplementation( file );
descriptors.add( mmDescriptor );
}
return descriptors;
}
}

View File

@ -0,0 +1,17 @@
<component-set>
<components>
<!--
|
| MarmaladeMojoDescriptorExtractor, a MojoDescriptor extractor to read
| descriptors from marmalade-mojo's.
|
-->
<component>
<role>org.apache.maven.tools.plugin.extractor.MojoDescriptorExtrator</role>
<role-hint>marmalade</role-hint>
<implementation>org.apache.maven.tools.plugin.extractor.MarmaladeMojoDescriptorExtrator</implementation>
</component>
</components>
</component-set>

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>maven</groupId>
<artifactId>maven-plugin-tools</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>
<groupId>maven</groupId>
<artifactId>maven-plugin-tools-pluggy</artifactId>
<name>Maven Pluggy Simplistic Plugin Generator</name>
<version>2.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>qdox</groupId>
<artifactId>qdox</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>modello</groupId>
<artifactId>modello</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-core</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-plugin</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-plugin-tools-api</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-plugin-tools-java</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,107 @@
package org.apache.maven.tools.plugin.pluggy;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.project.MavenProject;
import org.apache.maven.tools.plugin.extractor.java.JavaMojoDescriptorExtractor;
import org.apache.maven.tools.plugin.generator.BeanGenerator;
import org.apache.maven.tools.plugin.generator.Generator;
import org.apache.maven.tools.plugin.generator.PluginDescriptorGenerator;
import org.apache.maven.tools.plugin.generator.PluginXdocGenerator;
import org.apache.maven.tools.plugin.generator.jelly.JellyHarnessGenerator;
import org.apache.maven.tools.plugin.scanner.DefaultMojoScanner;
import org.apache.maven.tools.plugin.scanner.MojoScanner;
import java.io.File;
import java.io.FileReader;
import java.net.URL;
import java.util.Collections;
import java.util.Set;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class Main
{
public static void main( String[] args )
throws Exception
{
if ( args.length != 5 )
{
System.err.println( "Usage: pluggy <mode> <source directory> <output directory> <pom> <local-repo>" );
System.exit( 1 );
}
// Make sense of the args.
String mode = args[0];
String sourceDirectory = args[1];
String outputDirectory = args[2];
String pom = args[3];
String localRepo = args[4];
// Massage the local-repo path into an ArtifactRepository.
File repoPath = new File(localRepo);
URL repoUrl = repoPath.toURL();
MavenXpp3Reader modelReader = new MavenXpp3Reader();
FileReader reader = new FileReader(pom);
Model model = modelReader.read(reader);
MavenProject project = new MavenProject(model);
project.setFile(new File(pom));
// Lookup the mojo scanner instance, and use it to scan for mojo's, and
// extract their descriptors.
MojoScanner scanner = new DefaultMojoScanner(Collections.singletonMap("java", new JavaMojoDescriptorExtractor()));
Set descriptors = scanner.execute(project);
// Create the generator.
Generator generator = null;
if ( mode.equals( "descriptor" ) )
{
generator = new PluginDescriptorGenerator();
}
else if ( mode.equals( "xdoc" ) )
{
generator = new PluginXdocGenerator();
}
else if ( mode.equals( "jelly" ) )
{
generator = new JellyHarnessGenerator();
}
else if ( mode.equals( "bean" ) )
{
generator = new BeanGenerator();
}
// Use the generator to process the discovered descriptors and produce
// something with them.
generator.execute( outputDirectory, descriptors, project );
}
}

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
@ -9,7 +8,7 @@
</parent>
<groupId>maven</groupId>
<artifactId>maven-plugin-tools</artifactId>
<name>Maven Plugin Tools</name>
<name>Maven Plugin Tools Base POM</name>
<version>2.0-SNAPSHOT</version>
<dependencies>
<dependency>
@ -17,6 +16,11 @@
<artifactId>maven-plugin</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-plugin-tools-api</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>qdox</groupId>
<artifactId>qdox</artifactId>
@ -28,4 +32,4 @@
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
</project>

View File

@ -1,66 +0,0 @@
package org.apache.maven.plugin.generator;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.maven.plugin.generator.jelly.JellyHarnessGenerator;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class Main
{
public static void main( String[] args )
throws Exception
{
if ( args.length != 4 )
{
System.err.println( "Usage: pluggy <mode> <source directory> <output directory> <pom>" );
System.exit( 1 );
}
String mode = args[0];
String sourceDirectory = args[1];
String outputDirectory = args[2];
String pom = args[3];
AbstractGenerator generator = null;
if ( mode.equals( "descriptor" ) )
{
generator = new PluginDescriptorGenerator();
}
else if ( mode.equals( "xdoc" ) )
{
generator = new PluginXdocGenerator();
}
else if ( mode.equals( "jelly" ) )
{
generator = new JellyHarnessGenerator();
}
else if ( mode.equals( "bean" ) )
{
generator = new BeanGenerator();
}
generator.execute( sourceDirectory, outputDirectory, pom );
}
}

View File

@ -1,121 +0,0 @@
package org.apache.maven.plugin.generator;
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.File;
import java.io.FileReader;
import java.util.List;
import org.apache.maven.plugin.descriptor.Dependency;
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.descriptor.PluginDescriptorBuilder;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class PluginDescriptorGeneratorTest
extends AbstractGeneratorTestCase
{
protected void validate()
throws Exception
{
PluginDescriptorBuilder pdb = new PluginDescriptorBuilder();
File pluginDescriptorFile = new File( basedir, "target/plugin.xml" );
PluginDescriptor pluginDescriptor = pdb.build( new FileReader( pluginDescriptorFile ) );
MojoDescriptor mojoDescriptor = (MojoDescriptor) pluginDescriptor.getMojos().get( 0 );
if ( mojoDescriptor.getId().equals( "idea:ideaOne" ) )
{
checkMojoOne( mojoDescriptor );
mojoDescriptor = (MojoDescriptor) pluginDescriptor.getMojos().get( 1 );
checkMojoTwo( mojoDescriptor );
}
else
{
checkMojoTwo( mojoDescriptor );
mojoDescriptor = (MojoDescriptor) pluginDescriptor.getMojos().get( 1 );
checkMojoOne( mojoDescriptor );
}
// ----------------------------------------------------------------------
// Parameters
// ----------------------------------------------------------------------
List parameters = mojoDescriptor.getParameters();
assertEquals( 1, parameters.size() );
Parameter pd = (Parameter) mojoDescriptor.getParameters().get( 0 );
assertEquals( "project", pd.getName() );
assertEquals( "#project", pd.getExpression() );
// ----------------------------------------------------------------------
// Dependencies
// ----------------------------------------------------------------------
List dependencies = pluginDescriptor.getDependencies();
checkDependency( "maven", "maven-core", "2.0-SNAPSHOT", (Dependency) dependencies.get( 0 ) );
assertEquals( 3, dependencies.size() );
}
private void checkMojoOne( MojoDescriptor mojoDescriptor )
{
assertEquals( "idea:ideaOne", mojoDescriptor.getId() );
assertEquals( "org.apache.maven.plugin.idea.IdeaMojoOne", mojoDescriptor.getImplementation() );
assertEquals( "singleton", mojoDescriptor.getInstantiationStrategy() );
assertTrue( mojoDescriptor.requiresDependencyResolution() );
}
private void checkMojoTwo( MojoDescriptor mojoDescriptor )
{
assertEquals( "idea:ideaTwo", mojoDescriptor.getId() );
assertEquals( "org.apache.maven.plugin.idea.IdeaMojoTwo", mojoDescriptor.getImplementation() );
assertEquals( "singleton", mojoDescriptor.getInstantiationStrategy() );
assertFalse( mojoDescriptor.requiresDependencyResolution() );
}
private void checkDependency( String groupId, String artifactId, String version, Dependency dependency )
{
assertNotNull( dependency );
assertEquals( groupId, dependency.getGroupId() );
assertEquals( artifactId, dependency.getArtifactId() );
assertEquals( version, dependency.getVersion() );
}
}

View File

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>maven</groupId>
<artifactId>maven-plugin-parent</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>
<groupId>maven</groupId>
<artifactId>maven-idea-plugin</artifactId>
<name>Maven</name>
<version>1.0-SNAPSHOT</version>
<package>org.apache.maven</package>
<dependencies>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-core</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -28,6 +28,8 @@ public class MojoDescriptor
public static final String MULTI_PASS_EXEC_STRATEGY = "always";
private static final String DEFAULT_LANGUAGE = "java";
private String implementation;
private String description;
@ -54,6 +56,8 @@ public class MojoDescriptor
private boolean requiresProject = true;
private String language = DEFAULT_LANGUAGE;
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
@ -93,6 +97,16 @@ public class MojoDescriptor
this.instantiationStrategy = instantiationStrategy;
}
public String getLanguage()
{
return language;
}
public void setLanguage( String language )
{
this.language = language;
}
public String getId()
{
return id;

View File

@ -49,7 +49,7 @@ public class PluginDescriptorBuilder
List dependencies = new ArrayList();
for ( int i = 0; i < dependencyConfigurations.length; i++ )
for( int i = 0; i < dependencyConfigurations.length; i++ )
{
PlexusConfiguration d = dependencyConfigurations[i];
@ -62,7 +62,7 @@ public class PluginDescriptorBuilder
cd.setType( d.getChild( "type" ).getValue() );
cd.setVersion( d.getChild( "version" ).getValue() );
dependencies.add( cd );
}
@ -80,6 +80,13 @@ public class PluginDescriptorBuilder
mojo.setImplementation( c.getChild( "implementation" ).getValue() );
PlexusConfiguration langConfig = c.getChild( "language" );
if( langConfig != null )
{
mojo.setLanguage( langConfig.getValue() );
}
mojo.setInstantiationStrategy( c.getChild( "instantiationStrategy" ).getValue() );
mojo.setDescription( c.getChild( "description" ).getValue() );
@ -109,7 +116,7 @@ public class PluginDescriptorBuilder
parameter.setType( d.getChild( "type" ).getValue() );
String s = c.getChild( "required" ).getValue();
String s = d.getChild( "required" ).getValue();
if ( s != null )
{

View File

@ -17,19 +17,32 @@
<dependencies>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-plugin-tools</artifactId>
<artifactId>maven-core</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-plugin-tools-api</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<!-- Included as dependencies only to get the components into the classpath. -->
<dependency>
<groupId>maven</groupId>
<artifactId>maven-plugin-tools-java</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<!-- dependency>
<groupId>maven</groupId>
<artifactId>maven-plugin-tools-marmalade</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency -->
<!-- /Included as dependencies only to get the components into the classpath. -->
<dependency>
<groupId>maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-core</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-artifact</artifactId>

View File

@ -3,6 +3,10 @@ package org.apache.maven.plugin.plugin;
import org.apache.maven.plugin.AbstractPlugin;
import org.apache.maven.plugin.PluginExecutionRequest;
import org.apache.maven.plugin.PluginExecutionResponse;
import org.apache.maven.project.MavenProject;
import org.apache.maven.tools.plugin.scanner.MojoScanner;
import java.util.Set;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
@ -11,7 +15,7 @@ import org.apache.maven.plugin.PluginExecutionResponse;
public abstract class AbstractGeneratorMojo
extends AbstractPlugin
{
protected abstract void generate( String sourceDirectory, String outputDirectory, String pom )
protected abstract void generate( String outputDirectory, Set mavenMojoDescriptors, MavenProject project )
throws Exception;
public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
@ -21,16 +25,18 @@ public abstract class AbstractGeneratorMojo
//
// ----------------------------------------------------------------------
String sourceDirectory = (String) request.getParameter( "sourceDirectory" );
String outputDirectory = (String) request.getParameter( "outputDirectory" );
String pom = (String) request.getParameter( "pom" );
MavenProject project = (MavenProject)request.getParameter( "project" );
MojoScanner scanner = (MojoScanner)request.getParameter("mojoScanner");
Set mavenMojoDescriptors = scanner.execute(project);
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
generate( sourceDirectory, outputDirectory, pom );
generate( outputDirectory, mavenMojoDescriptors, project );
}
}

View File

@ -1,6 +1,9 @@
package org.apache.maven.plugin.plugin;
import org.apache.maven.plugin.generator.BeanGenerator;
import org.apache.maven.project.MavenProject;
import org.apache.maven.tools.plugin.generator.BeanGenerator;
import java.util.Set;
/**
* @goal bean
@ -8,11 +11,18 @@ import org.apache.maven.plugin.generator.BeanGenerator;
* @description Goal for generating a plugin descriptor.
*
* @parameter
* name="sourceDirectory"
* type="String"
* name="mojoScanner"
* type="org.apache.maven.tools.plugin.scanner.MojoScanner"
* required="true"
* validator=""
* expression="#project.build.sourceDirectory"
* expression="#component.org.apache.maven.tools.plugin.scanner.MojoScanner"
* description="Scanner used to discover mojo descriptors from this project"
* @parameter
* name="project"
* type="org.apache.maven.project.MavenProject"
* required="true"
* validator=""
* expression="#project"
* description=""
* @parameter
* name="outputDirectory"
@ -21,13 +31,6 @@ import org.apache.maven.plugin.generator.BeanGenerator;
* validator=""
* expression="#project.build.directory/generated-sources"
* description=""
* @parameter
* name="pom"
* type="String"
* required="true"
* validator=""
* expression="#project.file.path"
* description=""
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
@ -35,11 +38,11 @@ import org.apache.maven.plugin.generator.BeanGenerator;
public class BeanGeneratorMojo
extends AbstractGeneratorMojo
{
protected void generate( String sourceDirectory, String outputDirectory, String pom )
protected void generate( String outputDirectory, Set mavenMojoDescriptors, MavenProject project )
throws Exception
{
BeanGenerator generator = new BeanGenerator();
generator.execute( sourceDirectory, outputDirectory, pom );
generator.execute( outputDirectory, mavenMojoDescriptors, project );
}
}

View File

@ -1,45 +0,0 @@
package org.apache.maven.plugin.plugin;
import org.apache.maven.plugin.generator.PluginDescriptorGenerator;
/**
* @goal descriptor
*
* @description Goal for generating a plugin descriptor.
*
* @parameter
* name="sourceDirectory"
* type="String"
* required="true"
* validator=""
* expression="#project.build.sourceDirectory"
* description=""
* @parameter
* name="outputDirectory"
* type="String"
* required="true"
* validator=""
* expression="#project.build.directory/classes/META-INF/maven"
* description=""
* @parameter
* name="pom"
* type="String"
* required="true"
* validator=""
* expression="#project.file.path"
* description=""
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class DescriptorGenerator
extends AbstractGeneratorMojo
{
protected void generate( String sourceDirectory, String outputDirectory, String pom )
throws Exception
{
PluginDescriptorGenerator generator = new PluginDescriptorGenerator();
generator.execute( sourceDirectory, outputDirectory, pom );
}
}

View File

@ -0,0 +1,48 @@
package org.apache.maven.plugin.plugin;
import org.apache.maven.project.MavenProject;
import org.apache.maven.tools.plugin.generator.PluginDescriptorGenerator;
import java.util.Set;
/**
* @goal descriptor
*
* @description Goal for generating a plugin descriptor.
*
* @parameter
* name="mojoScanner"
* type="org.apache.maven.tools.plugin.scanner.MojoScanner"
* required="true"
* validator=""
* expression="#component.org.apache.maven.tools.plugin.scanner.MojoScanner"
* description="Scanner used to discover mojo descriptors from this project"
* @parameter
* name="project"
* type="org.apache.maven.project.MavenProject"
* required="true"
* validator=""
* expression="#project"
* description=""
* @parameter
* name="outputDirectory"
* type="String"
* required="true"
* validator=""
* expression="#project.build.directory/classes/META-INF/maven"
* description=""
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class DescriptorGeneratorMojo
extends AbstractGeneratorMojo
{
protected void generate( String outputDirectory, Set mavenMojoDescriptors, MavenProject project )
throws Exception
{
PluginDescriptorGenerator generator = new PluginDescriptorGenerator();
generator.execute( outputDirectory, mavenMojoDescriptors, project );
}
}

View File

@ -1,6 +1,10 @@
package org.apache.maven.plugin.plugin;
import org.apache.maven.plugin.generator.jelly.JellyHarnessGenerator;
import org.apache.maven.project.MavenProject;
import org.apache.maven.tools.plugin.generator.jelly.JellyHarnessGenerator;
import java.util.Set;
/**
* @goal jelly
@ -8,26 +12,26 @@ import org.apache.maven.plugin.generator.jelly.JellyHarnessGenerator;
* @description Goal for generating a plugin descriptor.
*
* @parameter
* name="sourceDirectory"
* type="String"
* name="mojoScanner"
* type="org.apache.maven.tools.plugin.scanner.MojoScanner"
* required="true"
* validator=""
* expression="#project.build.sourceDirectory"
* description="x"
* expression="#component.org.apache.maven.tools.plugin.scanner.MojoScanner"
* description="Scanner used to discover mojo descriptors from this project"
* @parameter
* name="project"
* type="org.apache.maven.project.MavenProject"
* required="true"
* validator=""
* expression="#project"
* description=""
* @parameter
* name="outputDirectory"
* type="String"
* required="true"
* validator=""
* expression="#project.build.output"
* description="x"
* @parameter
* name="pom"
* type="String"
* required="true"
* validator=""
* expression="#project.file.path"
* description="x"
* expression="#project.build.directory/generated-sources"
* description=""
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
@ -35,11 +39,11 @@ import org.apache.maven.plugin.generator.jelly.JellyHarnessGenerator;
public class JellyGeneratorMojo
extends AbstractGeneratorMojo
{
protected void generate( String sourceDirectory, String outputDirectory, String pom )
protected void generate( String outputDirectory, Set mavenMojoDescriptors, MavenProject project )
throws Exception
{
JellyHarnessGenerator generator = new JellyHarnessGenerator();
generator.execute( sourceDirectory, outputDirectory, pom );
generator.execute( outputDirectory, mavenMojoDescriptors, project );
}
}

View File

@ -0,0 +1,33 @@
---
Multiple Language Support for the Plugin Plugin: Redesign Notes
---
John Casey
---
09-Feb-2005
---
<<THIS NEEDS REVISION AND CLEANING UP>>
*Abstract
The Plugin plugin needs to be refactored in order to support multiple mojo
implementation languages. This document will detail the steps needed to
add this functionality.
*Current Status
The plugin plugin currently calls out to a set of generators in the
maven-plugin-tools library, which in turn uses qdox to generate various things
based on annotations in the java source code.
*Refactored Design
The new design will have a generator-manager which is a component that the
plugin mojos will lookup. This component will have access to a mapping of all
generators and the language they're registered for. It'll iterate through the
mappings, and extract mojo descriptors from all relevant scripts/sources using
each language's registered generator. Results from each generator will be
centrally aggregated by the generator-manager. After all generators have run,
the generator-manager will call another class (depending on what it's meant to
produce) to take all the aggregated mojo descriptors and produce a result
(such as plugin.xml file for the project).

View File

@ -2,21 +2,16 @@
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<!-- parent>
<groupId>maven</groupId>
<artifactId>maven-component</artifactId>
<artifactId>maven-script-root</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>
</parent -->
<groupId>maven</groupId>
<artifactId>maven-marmalade-loader</artifactId>
<name>Maven Marmalade Plugin Loader</name>
<artifactId>maven-script-marmalade</artifactId>
<name>Maven Marmalade Mojo Support</name>
<version>2.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-core</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-plugin</artifactId>
@ -25,17 +20,12 @@
<dependency>
<groupId>marmalade</groupId>
<artifactId>marmalade-core</artifactId>
<version>1.0-alpha1</version>
</dependency>
<dependency>
<groupId>marmalade</groupId>
<artifactId>marmalade-el-ognl</artifactId>
<version>1.0-alpha1</version>
<version>1.0-alpha2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-marmalade-factory</artifactId>
<version>1.0-alpha1</version>
<version>1.0-alpha1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,43 @@
/* Created on Aug 9, 2004 */
package org.apache.maven.script.marmalade;
import org.apache.maven.plugin.AbstractPlugin;
import org.apache.maven.plugin.FailureResponse;
import org.apache.maven.plugin.PluginExecutionRequest;
import org.apache.maven.plugin.PluginExecutionResponse;
import org.codehaus.marmalade.model.MarmaladeScript;
import org.codehaus.marmalade.runtime.DefaultContext;
import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
import org.codehaus.marmalade.runtime.MarmaladeExecutionException;
/**
* @author jdcasey
*/
public class MarmaladeMojo extends AbstractPlugin {
private MarmaladeScript script;
public MarmaladeMojo(MarmaladeScript script) {
this.script = script;
}
public void execute(PluginExecutionRequest request,
PluginExecutionResponse response) throws Exception {
MarmaladeExecutionContext context = new DefaultContext();
context.setVariable(MarmaladeMojoExecutionDirectives.REQUEST_INVAR, request);
context.setVariable(MarmaladeMojoExecutionDirectives.RESPONSE_INVAR, response);
try
{
script.execute( context );
}
catch( MarmaladeExecutionException e )
{
FailureResponse failure = new MarmaladeMojoFailureResponse(script.getLocation(), e);
response.setExecutionFailure(true, failure);
}
}
}

View File

@ -0,0 +1,20 @@
package org.apache.maven.script.marmalade;
/**
* @author jdcasey Created on Feb 8, 2005
*/
public final class MarmaladeMojoExecutionDirectives
{
public static final String METADATA_OUTVAR = "metadata";
public static final String SCRIPT_BASEPATH_INVAR = "basePath";
public static final String REQUEST_INVAR = "request";
public static final String RESPONSE_INVAR = "response";
private MarmaladeMojoExecutionDirectives()
{
}
}

View File

@ -0,0 +1,54 @@
package org.apache.maven.script.marmalade;
import org.apache.maven.plugin.FailureResponse;
import org.codehaus.marmalade.runtime.MarmaladeExecutionException;
import java.io.PrintWriter;
import java.io.StringWriter;
/**
* @author jdcasey
*
* Created on Feb 8, 2005
*/
public class MarmaladeMojoFailureResponse extends FailureResponse
{
private final String scriptLocation;
private final MarmaladeExecutionException error;
public MarmaladeMojoFailureResponse( String scriptLocation, MarmaladeExecutionException error )
{
super(scriptLocation);
this.scriptLocation = scriptLocation;
this.error = error;
}
public String shortMessage()
{
StringBuffer buffer = new StringBuffer();
buffer.append("Script: ").append(scriptLocation).append(" failed to execute.");
buffer.append("\nError: ").append(error.getLocalizedMessage());
return buffer.toString();
}
public String longMessage()
{
StringBuffer buffer = new StringBuffer();
buffer.append("Script: ").append(scriptLocation).append(" failed to execute.");
buffer.append("\nError:\n");
StringWriter sWriter = new StringWriter();
PrintWriter pWriter = new PrintWriter(sWriter);
error.printStackTrace(pWriter);
buffer.append(sWriter.toString());
pWriter.close();
return buffer.toString();
}
}

View File

@ -0,0 +1 @@
org.apache.maven.script.marmalade.tags.MojoDefinitionTagLibrary

21
maven-script/pom.xml Normal file
View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>maven</groupId>
<artifactId>maven-component</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>
<groupId>maven</groupId>
<artifactId>maven-script-root</artifactId>
<name>Maven Script Support Root</name>
<version>2.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-plugin</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>