mirror of https://github.com/apache/maven.git
o Working on getting it0015 (marmalade-mojo support) working...nearly there, it0015 is still disabled.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163415 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
00a55be3cb
commit
db65155072
|
@ -38,10 +38,18 @@ it0010: Since the artifact resolution does not use the project builder, we must
|
|||
maven-component, which is the parent of maven-plugin, which is an
|
||||
explicit dependency of this test.
|
||||
|
||||
it0011: Test specification of dependency versions via <dependencyDefaults/>.
|
||||
it0011: Test specification of dependency versions via <dependencyManagement/>.
|
||||
|
||||
it0012: Test simple POM interpolation
|
||||
|
||||
it0013: Test plugin-plugin, which tests maven-plugin-tools-api and
|
||||
maven-plugin-tools-java. This will generate a plugin descriptor from
|
||||
java-based mojo sources, install the plugin, and then use it.
|
||||
|
||||
it0015: Test marmalade-driven mojo support. This will compile supporting java
|
||||
classes (mmld tag & taglib), generate plugin descriptor from mmld script,
|
||||
install the plugin, and finally use the new plugin.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- generated sources
|
||||
|
|
|
@ -12,3 +12,5 @@ it0010
|
|||
it0011
|
||||
it0012
|
||||
it0013
|
||||
#it0014
|
||||
#it0015
|
||||
|
|
|
@ -1 +1 @@
|
|||
target/classes/out.txt
|
||||
target/out.txt
|
||||
|
|
|
@ -1,13 +1,28 @@
|
|||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-it0014-plugin</artifactId>
|
||||
<artifactId>maven-it0015-plugin</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<type>plugin</type>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-plugin</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>marmalade</groupId>
|
||||
<artifactId>marmalade-core</artifactId>
|
||||
<version>1.0-alpha2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<resources>
|
||||
<resource><directory>src/main/resources</directory></resource>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes><include>**/*.mmld</include></includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -1 +1 @@
|
|||
rm target/classes/out.txt
|
||||
rm target/out.txt
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<mojo xmlns="marmalade:mojo" xmlns:marmalade-control="marmalade-control">
|
||||
<metadata marmalade-control:el="none">
|
||||
<id>it0015</id>
|
||||
<goal>it0015</goal>
|
||||
<description>Output a file with specified contents to [outDir]</description>
|
||||
<parameters>
|
||||
<parameter>
|
||||
<name>outDir</name>
|
||||
<expression>#project.build.directory</expression>
|
||||
<default>target</default>
|
||||
<description>Output directory for files.</description>
|
||||
</parameter>
|
||||
</parameters>
|
||||
</metadata>
|
||||
<execute>
|
||||
<writeFile xmlns="marmalade:it0015" path="${outDir}/out.txt">This is a test.</writeFile>
|
||||
</execute>
|
||||
</mojo>
|
|
@ -0,0 +1 @@
|
|||
org.apache.maven.it0015.tags.IT0015TagLibrary
|
|
@ -57,6 +57,26 @@
|
|||
<artifactId>wagon-http-lightweight</artifactId>
|
||||
<version>1.0-alpha-2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- Added to support marmalade-mojos.
|
||||
| Currently plexus container cannot accommodate multiple plexus.xml files,
|
||||
| so we have to include marmalade support here. Will remove when plexus
|
||||
| container is fixed (post-alpha-1 m2 release). -->
|
||||
<dependency>
|
||||
<groupId>plexus</groupId>
|
||||
<artifactId>plexus-marmalade-factory</artifactId>
|
||||
<version>1.0-alpha-2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>marmalade</groupId>
|
||||
<artifactId>marmalade-core</artifactId>
|
||||
<version>1.0-alpha2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xpp3</groupId>
|
||||
<artifactId>xpp3</artifactId>
|
||||
<version>1.1.3.3</version>
|
||||
</dependency>
|
||||
<!-- End marmalade support deps. -->
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<site>
|
||||
|
|
|
@ -9,6 +9,13 @@
|
|||
<component-discoverer implementation="org.apache.maven.plugin.MavenPluginDiscoverer"/>
|
||||
</component-discoverers>
|
||||
</component-discoverer-manager>
|
||||
<component-factory-manager implementation="org.codehaus.plexus.component.factory.DefaultComponentFactoryManager">
|
||||
<component-factories>
|
||||
<component-factory implementation="org.codehaus.plexus.component.factory.marmalade.MarmaladeClasspathComponentFactory">
|
||||
<id>marmalade</id>
|
||||
</component-factory>
|
||||
</component-factories>
|
||||
</component-factory-manager>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.apache.maven.plugin.PluginManager</role>
|
||||
|
|
|
@ -51,7 +51,7 @@ public class MBoot
|
|||
|
||||
String[] plexusDeps = new String[] {
|
||||
"classworlds/jars/classworlds-1.1-SNAPSHOT.jar",
|
||||
"plexus/jars/plexus-container-default-1.0-alpha-2-SNAPSHOT.jar", };
|
||||
"plexus/jars/plexus-container-default-1.0-alpha-2-SNAPSHOT.jar" };
|
||||
|
||||
String[] pluginGeneratorDeps = new String[] {
|
||||
"plexus/jars/plexus-container-default-1.0-alpha-2-SNAPSHOT.jar",
|
||||
|
@ -62,12 +62,6 @@ public class MBoot
|
|||
"maven/jars/maven-plugin-tools-java-2.0-SNAPSHOT.jar",
|
||||
"maven/jars/maven-plugin-tools-pluggy-2.0-SNAPSHOT.jar" };
|
||||
|
||||
String[] mojoSupportDeps = new String[] {
|
||||
"marmalade/jars/marmalade-core-1.0-alpha2-SNAPSHOT.jar",
|
||||
"xpp3/jars/xpp3-1.1.3.3.jar",
|
||||
"plexus/jars/plexus-marmalade-factory-1.0-alpha-2-SNAPSHOT.jar",
|
||||
"maven/jars/maven-script-marmalade-2.0-SNAPSHOT.jar", };
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// These are modello's runtime dependencies
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -367,14 +361,6 @@ public class MBoot
|
|||
FileUtils.copyFileToDirectory( repoLocal + "/" + getArtifactPath( d, "/" ), lib );
|
||||
}
|
||||
|
||||
// Copy in deps used for non-java mojo support.
|
||||
/* Causing issues
|
||||
for ( int i = 0; i < mojoSupportDeps.length; i++ )
|
||||
{
|
||||
FileUtils.copyFileToDirectory( repoLocal + "/" + mojoSupportDeps[i], lib );
|
||||
}
|
||||
*/
|
||||
|
||||
// Copy maven itself
|
||||
|
||||
FileUtils.copyFileToDirectory( repoLocal + "/maven/jars/maven-core-2.0-SNAPSHOT.jar", lib );
|
||||
|
|
|
@ -107,6 +107,16 @@ public class PluginDescriptorGenerator
|
|||
|
||||
w.writeText( mojoDescriptor.getImplementation() );
|
||||
|
||||
w.endElement();
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
w.startElement( "language" );
|
||||
|
||||
w.writeText( mojoDescriptor.getLanguage() );
|
||||
|
||||
w.endElement();
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
|
@ -45,7 +45,7 @@ public class MarmaladeMojo
|
|||
public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) throws Exception
|
||||
{
|
||||
|
||||
MarmaladeExecutionContext context = new DefaultContext();
|
||||
MarmaladeExecutionContext context = new DefaultContext( request.getParameters() );
|
||||
|
||||
context.setVariable( MarmaladeMojoExecutionDirectives.REQUEST_INVAR, request );
|
||||
context.setVariable( MarmaladeMojoExecutionDirectives.RESPONSE_INVAR, response );
|
||||
|
@ -64,6 +64,7 @@ public class MarmaladeMojo
|
|||
for ( Iterator it = externalizedVars.entrySet().iterator(); it.hasNext(); )
|
||||
{
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
|
||||
request.addContextValue( entry.getKey(), entry.getValue() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,17 +71,44 @@ public class MetadataTag
|
|||
MojoDescriptor descriptor = new MojoDescriptor();
|
||||
|
||||
descriptor.setLanguage( "marmalade" );
|
||||
descriptor.setId( id );
|
||||
descriptor.setGoal( goal );
|
||||
descriptor.setDescription( description );
|
||||
descriptor.setExecutionStrategy( executionStrategy );
|
||||
descriptor.setInstantiationStrategy( instantiationStrategy );
|
||||
|
||||
if ( notEmpty( id ) )
|
||||
{
|
||||
descriptor.setId( id );
|
||||
}
|
||||
|
||||
if ( notEmpty( goal ) )
|
||||
{
|
||||
descriptor.setGoal( goal );
|
||||
}
|
||||
|
||||
if ( notEmpty( description ) )
|
||||
{
|
||||
descriptor.setDescription( description );
|
||||
}
|
||||
|
||||
if ( notEmpty( executionStrategy ) )
|
||||
{
|
||||
descriptor.setExecutionStrategy( executionStrategy );
|
||||
}
|
||||
|
||||
if ( notEmpty( instantiationStrategy ) )
|
||||
{
|
||||
descriptor.setInstantiationStrategy( instantiationStrategy );
|
||||
}
|
||||
|
||||
descriptor.setParameters( parameters );
|
||||
descriptor.setRequiresDependencyResolution( requiresDependencyResolution );
|
||||
descriptor.setRequiresProject( requiresProject );
|
||||
|
||||
String basePath = (String) context.getVariable( MarmaladeMojoExecutionDirectives.SCRIPT_BASEPATH_INVAR,
|
||||
getExpressionEvaluator() );
|
||||
|
||||
if(basePath.endsWith("/"))
|
||||
{
|
||||
basePath = basePath.substring(0, basePath.length()-2);
|
||||
}
|
||||
|
||||
String implementationPath = getTagInfo().getSourceFile().substring( basePath.length() );
|
||||
|
||||
descriptor.setImplementation( implementationPath );
|
||||
|
@ -89,6 +116,11 @@ public class MetadataTag
|
|||
return descriptor;
|
||||
}
|
||||
|
||||
private boolean notEmpty( String test )
|
||||
{
|
||||
return test != null && test.trim().length() > 0;
|
||||
}
|
||||
|
||||
public void setId( String id )
|
||||
{
|
||||
this.id = id;
|
||||
|
|
|
@ -36,7 +36,7 @@ public class MarmaladeMojoTest
|
|||
extends TestCase
|
||||
{
|
||||
|
||||
private static final String TEST_SCRIPT = "<set xmlns=\"marmalade:core\" var=\"testvar\" value=\"testval\" extern=\"true\"/>";
|
||||
private static final String TEST_SCRIPT = "<set xmlns=\"marmalade:core\" var=\"testvar\" value=\"${param}/testval\" extern=\"true\"/>";
|
||||
|
||||
public void testShouldProduceOutputWithRequest_Dot_ToStringInline() throws Exception
|
||||
{
|
||||
|
@ -51,12 +51,15 @@ public class MarmaladeMojoTest
|
|||
MarmaladeMojo mojo = new MarmaladeMojo( script );
|
||||
|
||||
PluginExecutionRequest request = new PluginExecutionRequest( Collections.EMPTY_MAP );
|
||||
request.setParameters(Collections.singletonMap("param", "paramValue"));
|
||||
|
||||
PluginExecutionResponse response = new PluginExecutionResponse();
|
||||
|
||||
mojo.execute( request, response );
|
||||
|
||||
Object result = request.getContextValue( "testvar" );
|
||||
System.out.println( "Result of script execution: " + result );
|
||||
|
||||
assertEquals("paramValue/testval", result);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue