mirror of https://github.com/apache/maven.git
Added marmalade support back in...it's currently still using the libraries-shovelled-into-core method, but it now uses the new mojo mechanism that uses plexus ComponentConfigurators...had to make the lookup for configurators dynamic for the DefaultPluginManager, too.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@168064 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1755900b98
commit
690bc67fb9
|
@ -64,12 +64,12 @@
|
|||
<artifactId>plexus-i18n</artifactId>
|
||||
<version>1.0-beta-3</version>
|
||||
</dependency>
|
||||
<!-- dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-script-marmalade</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>plexus</groupId>
|
||||
<artifactId>plexus-container-default</artifactId>
|
||||
|
|
|
@ -84,8 +84,6 @@ public class DefaultPluginManager
|
|||
|
||||
protected PathTranslator pathTranslator;
|
||||
|
||||
protected ComponentConfigurator configurator;
|
||||
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
public DefaultPluginManager()
|
||||
|
@ -362,7 +360,7 @@ public class DefaultPluginManager
|
|||
|
||||
try
|
||||
{
|
||||
plugin = (Mojo) container.lookup( Mojo.ROLE, goalName );
|
||||
plugin = (Mojo) container.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint() );
|
||||
|
||||
plugin.setLog( session.getLog() );
|
||||
|
||||
|
@ -405,7 +403,7 @@ public class DefaultPluginManager
|
|||
Map map = getPluginConfigurationFromExpressions( plugin, mojoDescriptor, mergedConfiguration,
|
||||
expressionEvaluator );
|
||||
|
||||
populatePluginFields( plugin, pomConfiguration, expressionEvaluator );
|
||||
populatePluginFields( plugin, mojoDescriptor, mergedConfiguration, expressionEvaluator );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -594,18 +592,51 @@ public class DefaultPluginManager
|
|||
return new MojoExecutionRequest( map );
|
||||
}
|
||||
|
||||
private void populatePluginFields( Mojo plugin, PlexusConfiguration configuration,
|
||||
ExpressionEvaluator expressionEvaluator )
|
||||
private void populatePluginFields( Mojo plugin, MojoDescriptor mojoDescriptor, PlexusConfiguration configuration,
|
||||
ExpressionEvaluator expressionEvaluator )
|
||||
throws PluginConfigurationException
|
||||
{
|
||||
ComponentConfigurator configurator = null;
|
||||
|
||||
try
|
||||
{
|
||||
String configuratorId = mojoDescriptor.getComponentConfigurator();
|
||||
|
||||
if ( StringUtils.isNotEmpty( configuratorId ) )
|
||||
{
|
||||
configurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE, configuratorId );
|
||||
}
|
||||
else
|
||||
{
|
||||
configurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE );
|
||||
}
|
||||
|
||||
configurator.configureComponent( plugin, configuration, expressionEvaluator );
|
||||
|
||||
}
|
||||
catch ( ComponentConfigurationException e )
|
||||
{
|
||||
throw new PluginConfigurationException( "Unable to parse the created DOM for plugin configuration", e );
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
throw new PluginConfigurationException(
|
||||
"Unable to retrieve component configurator for plugin configuration",
|
||||
e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ( configurator != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
container.release( configurator );
|
||||
}
|
||||
catch ( ComponentLifecycleException e )
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Field findPluginField( Class clazz, String key )
|
||||
|
@ -791,7 +822,9 @@ public class DefaultPluginManager
|
|||
"maven-settings", "maven-monitor", "maven-plugin-api",
|
||||
"maven-plugin-descriptor", "plexus-container-default",
|
||||
"maven-project", "plexus-container-artifact", "maven-reporting-api", "doxia-core",
|
||||
"wagon-provider-api", "classworlds", "maven-plugin"} );
|
||||
"wagon-provider-api", "classworlds", "maven-plugin",
|
||||
"plexus-marmalade-factory", "maven-script-marmalade",
|
||||
"marmalade-core"} );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
<requirement>
|
||||
<role>org.apache.maven.project.path.PathTranslator</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.codehaus.plexus.component.configurator.ComponentConfigurator</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
</requirement>
|
||||
|
|
|
@ -36,12 +36,12 @@ import java.util.TreeMap;
|
|||
public class MBoot
|
||||
{
|
||||
String[] builds = new String[]{"maven-model", "maven-settings", "maven-monitor", "maven-plugin-api",
|
||||
"maven-plugin-descriptor", "maven-artifact", /*"maven-script/maven-script-marmalade",*/
|
||||
"maven-plugin-descriptor", "maven-artifact", "maven-script/maven-script-marmalade",
|
||||
"maven-project", "maven-core", "maven-archiver", "maven-reporting/maven-reporting-api",
|
||||
"maven-reporting/maven-reporting-manager", "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"};
|
||||
"maven-plugin-tools/maven-plugin-tools-marmalade", "maven-core-it-verifier"};
|
||||
|
||||
String[] pluginBuilds = new String[]{"maven-plugins/maven-clean-plugin", "maven-plugins/maven-compiler-plugin",
|
||||
"maven-plugins/maven-install-plugin", "maven-plugins/maven-jar-plugin",
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<dependency>
|
||||
<groupId>plexus</groupId>
|
||||
<artifactId>plexus-container-default</artifactId>
|
||||
<version>1.0-alpha-2</version>
|
||||
<version>1.0-alpha-3-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -257,7 +257,7 @@ public class MojoDescriptor
|
|||
|
||||
public String getRoleHint()
|
||||
{
|
||||
return getId();
|
||||
return getId() + ":" + getGoal();
|
||||
}
|
||||
|
||||
public String getComponentType()
|
||||
|
|
|
@ -12,7 +12,6 @@ import java.io.Reader;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
|
@ -104,6 +103,13 @@ public class PluginDescriptorBuilder
|
|||
mojo.setLanguage( langConfig.getValue() );
|
||||
}
|
||||
|
||||
PlexusConfiguration configuratorConfig = c.getChild( "configurator" );
|
||||
|
||||
if ( configuratorConfig != null )
|
||||
{
|
||||
mojo.setComponentConfigurator( configuratorConfig.getValue() );
|
||||
}
|
||||
|
||||
String phase = c.getChild( "phase" ).getValue();
|
||||
|
||||
if ( phase != null )
|
||||
|
@ -144,7 +150,7 @@ public class PluginDescriptorBuilder
|
|||
Parameter parameter = new Parameter();
|
||||
|
||||
parameter.setName( d.getChild( "name" ).getValue() );
|
||||
|
||||
|
||||
parameter.setAlias( d.getChild( "alias" ).getValue() );
|
||||
|
||||
parameter.setType( d.getChild( "type" ).getValue() );
|
||||
|
@ -152,17 +158,17 @@ public class PluginDescriptorBuilder
|
|||
String required = d.getChild( "required" ).getValue();
|
||||
|
||||
parameter.setRequired( "true".equals( required ) );
|
||||
|
||||
PlexusConfiguration editableConfig = d.getChild("editable");
|
||||
|
||||
|
||||
PlexusConfiguration editableConfig = d.getChild( "editable" );
|
||||
|
||||
// we need the null check for pre-build legacy plugins...
|
||||
if(editableConfig != null)
|
||||
if ( editableConfig != null )
|
||||
{
|
||||
String editable = d.getChild("editable").getValue();
|
||||
|
||||
String editable = d.getChild( "editable" ).getValue();
|
||||
|
||||
parameter.setEditable( editable == null || "true".equals( editable ) );
|
||||
}
|
||||
|
||||
|
||||
parameter.setValidator( d.getChild( "validator" ).getValue() );
|
||||
|
||||
parameter.setDescription( d.getChild( "description" ).getValue() );
|
||||
|
@ -187,9 +193,9 @@ public class PluginDescriptorBuilder
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
mojo.setMojoConfiguration( c.getChild( "configuration" ) );
|
||||
|
||||
|
||||
// TODO: Go back to this when we get the container ready to configure mojos...
|
||||
// mojo.setConfiguration( c.getChild( "configuration" ) );
|
||||
// mojo.setConfiguration( c.getChild( "configuration" ) );
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Requirements
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.apache.maven.tools.plugin.extractor;
|
||||
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.util.DirectoryScanner;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -15,6 +16,7 @@ import java.util.TreeMap;
|
|||
* @author jdcasey
|
||||
*/
|
||||
public abstract class AbstractScriptedMojoDescriptorExtractor
|
||||
extends AbstractLogEnabled
|
||||
implements MojoDescriptorExtractor
|
||||
{
|
||||
public Set execute( MavenProject project )
|
||||
|
@ -42,7 +44,9 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
Set sources = new HashSet();
|
||||
|
||||
String resourceDir = (String) it.next();
|
||||
File dir = new File( resourceDir );
|
||||
File dir = new File( resourceDir ).getAbsoluteFile();
|
||||
|
||||
resourceDir = dir.getPath();
|
||||
|
||||
if ( dir.exists() )
|
||||
{
|
||||
|
@ -57,7 +61,7 @@ public abstract class AbstractScriptedMojoDescriptorExtractor
|
|||
for ( int i = 0; i < relativePaths.length; i++ )
|
||||
{
|
||||
String relativePath = relativePaths[i];
|
||||
File scriptFile = new File( dir, relativePath );
|
||||
File scriptFile = new File( dir, relativePath ).getAbsoluteFile();
|
||||
|
||||
if ( scriptFile.isFile() && relativePath.endsWith( scriptFileExtension ) )
|
||||
{
|
||||
|
|
|
@ -155,6 +155,19 @@ public class PluginDescriptorGenerator
|
|||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
if ( mojoDescriptor.getComponentConfigurator() != null )
|
||||
{
|
||||
w.startElement( "configurator" );
|
||||
|
||||
w.writeText( mojoDescriptor.getComponentConfigurator() );
|
||||
|
||||
w.endElement();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
w.startElement( "instantiationStrategy" );
|
||||
|
||||
w.writeText( mojoDescriptor.getInstantiationStrategy() );
|
||||
|
@ -186,7 +199,7 @@ public class PluginDescriptorGenerator
|
|||
Parameter parameter = (Parameter) parameters.get( j );
|
||||
|
||||
String expression = parameter.getExpression();
|
||||
|
||||
|
||||
if ( StringUtils.isNotEmpty( expression )
|
||||
&& ( expression.startsWith( "${component." ) || expression.startsWith( "#component." ) ) )
|
||||
{
|
||||
|
|
|
@ -301,7 +301,7 @@ public class JavaMojoDescriptorExtractor
|
|||
pd.setRequired( parameter.getNamedParameter( REQUIRED ).equals( "true" ) ? true : false );
|
||||
|
||||
pd.setDeprecated( parameter.getNamedParameter( DEPRECATED ) );
|
||||
|
||||
|
||||
pd.setDefaultValue( parameter.getNamedParameter( "default" ) );
|
||||
}
|
||||
else
|
||||
|
@ -315,7 +315,7 @@ public class JavaMojoDescriptorExtractor
|
|||
pd.setRequired( field.getTagByName( REQUIRED ) != null );
|
||||
|
||||
pd.setEditable( field.getTagByName( READONLY ) == null );
|
||||
|
||||
|
||||
DocletTag deprecationTag = field.getTagByName( DEPRECATED );
|
||||
if ( deprecationTag != null )
|
||||
{
|
||||
|
@ -400,7 +400,9 @@ public class JavaMojoDescriptorExtractor
|
|||
|
||||
for ( int i = 0; i < javaSources.length; i++ )
|
||||
{
|
||||
DocletTag tag = getJavaClass( javaSources[i] ).getTagByName( GOAL );
|
||||
JavaClass javaClass = getJavaClass( javaSources[i] );
|
||||
|
||||
DocletTag tag = javaClass.getTagByName( GOAL );
|
||||
|
||||
if ( tag != null )
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ public class JavaExtractorTestOne
|
|||
{
|
||||
/**
|
||||
* Maven project used to generate IDEA project files.
|
||||
* @parameter expression="#project"
|
||||
* @parameter
|
||||
* @required
|
||||
*/
|
||||
protected String[] project;
|
||||
|
|
|
@ -12,7 +12,7 @@ public class JavaExtractorTestTwo
|
|||
|
||||
/**
|
||||
* Maven project used to generate IDEA project files.
|
||||
* @parameter expression="#project"
|
||||
* @parameter
|
||||
* @required
|
||||
*/
|
||||
private String[] project;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<dependency>
|
||||
<groupId>marmalade</groupId>
|
||||
<artifactId>marmalade-core</artifactId>
|
||||
<version>1.0-alpha-2</version>
|
||||
<version>1.0-alpha-3-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
|
|
|
@ -20,19 +20,15 @@ import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
|||
import org.apache.maven.script.marmalade.MarmaladeMojoExecutionDirectives;
|
||||
import org.apache.maven.script.marmalade.tags.MojoTag;
|
||||
import org.apache.maven.tools.plugin.extractor.AbstractScriptedMojoDescriptorExtractor;
|
||||
import org.codehaus.marmalade.metamodel.ScriptBuilder;
|
||||
import org.codehaus.marmalade.launch.MarmaladeLauncher;
|
||||
import org.codehaus.marmalade.model.MarmaladeScript;
|
||||
import org.codehaus.marmalade.model.MarmaladeTag;
|
||||
import org.codehaus.marmalade.parsing.DefaultParsingContext;
|
||||
import org.codehaus.marmalade.parsing.MarmaladeParsingContext;
|
||||
import org.codehaus.marmalade.parsing.ScriptParser;
|
||||
import org.codehaus.marmalade.runtime.DefaultContext;
|
||||
import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
import org.codehaus.plexus.component.factory.marmalade.PlexusIntegratedLog;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
@ -72,7 +68,20 @@ public class MarmaladeMojoDescriptorExtractor
|
|||
{
|
||||
File scriptFile = (File) it.next();
|
||||
|
||||
MarmaladeScript script = parse( scriptFile );
|
||||
MarmaladeLauncher launcher = new MarmaladeLauncher().withInputFile( scriptFile );
|
||||
|
||||
Logger logger = getLogger();
|
||||
|
||||
if ( logger != null )
|
||||
{
|
||||
PlexusIntegratedLog log = new PlexusIntegratedLog();
|
||||
|
||||
log.enableLogging( logger );
|
||||
|
||||
launcher = launcher.withLog( log );
|
||||
}
|
||||
|
||||
MarmaladeScript script = launcher.getMarmaladeScript();
|
||||
|
||||
MarmaladeTag rootTag = script.getRoot();
|
||||
if ( rootTag instanceof MojoTag )
|
||||
|
@ -86,15 +95,15 @@ public class MarmaladeMojoDescriptorExtractor
|
|||
|
||||
contextMap = context.getExternalizedVariables();
|
||||
|
||||
MojoDescriptor descriptor = (MojoDescriptor) contextMap.get(
|
||||
MarmaladeMojoExecutionDirectives.METADATA_OUTVAR );
|
||||
MojoDescriptor descriptor = (MojoDescriptor) contextMap
|
||||
.get( MarmaladeMojoExecutionDirectives.METADATA_OUTVAR );
|
||||
|
||||
descriptors.add( descriptor );
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println( "This script is not a mojo. Its root tag is {element: " +
|
||||
rootTag.getTagInfo().getElement() + ", class: " + rootTag.getClass().getName() + "}" );
|
||||
System.out.println( "This script is not a mojo. Its root tag is {element: "
|
||||
+ rootTag.getTagInfo().getElement() + ", class: " + rootTag.getClass().getName() + "}" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,32 +116,4 @@ public class MarmaladeMojoDescriptorExtractor
|
|||
}
|
||||
}
|
||||
|
||||
private MarmaladeScript parse( File scriptFile )
|
||||
throws Exception
|
||||
{
|
||||
BufferedReader reader = null;
|
||||
|
||||
try
|
||||
{
|
||||
reader = new BufferedReader( new FileReader( scriptFile ) );
|
||||
|
||||
MarmaladeParsingContext parsingContext = new DefaultParsingContext();
|
||||
|
||||
parsingContext.setInputLocation( scriptFile.getPath() );
|
||||
parsingContext.setInput( reader );
|
||||
|
||||
ScriptParser parser = new ScriptParser();
|
||||
|
||||
ScriptBuilder builder = parser.parse( parsingContext );
|
||||
|
||||
MarmaladeScript script = builder.build();
|
||||
|
||||
return script;
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close( reader );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -22,11 +22,11 @@
|
|||
<version>2.0-SNAPSHOT</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-tools-marmalade</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency -->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</model>
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
<dependency>
|
||||
<groupId>marmalade</groupId>
|
||||
<artifactId>marmalade-core</artifactId>
|
||||
<version>1.0-alpha-2</version>
|
||||
<version>1.0-alpha-3-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>plexus</groupId>
|
||||
<artifactId>plexus-marmalade-factory</artifactId>
|
||||
<version>1.0-alpha-2</version>
|
||||
<version>1.0-alpha-3-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</model>
|
||||
|
|
|
@ -16,79 +16,99 @@ package org.apache.maven.script.marmalade;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.plugin.AbstractPlugin;
|
||||
import org.apache.maven.plugin.PluginExecutionRequest;
|
||||
import org.apache.maven.plugin.PluginExecutionResponse;
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.codehaus.marmalade.model.MarmaladeScript;
|
||||
import org.codehaus.marmalade.runtime.DefaultContext;
|
||||
import org.codehaus.marmalade.runtime.MarmaladeExecutionContext;
|
||||
import org.codehaus.marmalade.runtime.MarmaladeExecutionException;
|
||||
import org.codehaus.plexus.component.MapOrientedComponent;
|
||||
import org.codehaus.plexus.component.repository.ComponentRequirement;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* @author jdcasey
|
||||
*/
|
||||
public class MarmaladeMojo
|
||||
extends AbstractPlugin
|
||||
extends AbstractMojo
|
||||
implements MapOrientedComponent
|
||||
{
|
||||
|
||||
private MarmaladeScript script;
|
||||
|
||||
private Map contextMap = new TreeMap();
|
||||
|
||||
public MarmaladeMojo( MarmaladeScript script )
|
||||
{
|
||||
this.script = script;
|
||||
}
|
||||
|
||||
public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
|
||||
throws Exception
|
||||
public void execute()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
MarmaladeExecutionContext context = new DefaultContext( contextMap );
|
||||
|
||||
MarmaladeExecutionContext context = new DefaultContext( request.getParameters() );
|
||||
|
||||
context.setVariable( MarmaladeMojoExecutionDirectives.REQUEST_INVAR, request );
|
||||
context.setVariable( MarmaladeMojoExecutionDirectives.RESPONSE_INVAR, response );
|
||||
|
||||
StringWriter sOutWriter = new StringWriter();
|
||||
PrintWriter outWriter = new PrintWriter(sOutWriter);
|
||||
|
||||
context.setOutWriter(outWriter);
|
||||
|
||||
PrintWriter outWriter = new PrintWriter( sOutWriter );
|
||||
|
||||
context.setOutWriter( outWriter );
|
||||
|
||||
StringWriter sErrWriter = new StringWriter();
|
||||
PrintWriter errWriter = new PrintWriter(sErrWriter);
|
||||
|
||||
context.setErrWriter(errWriter);
|
||||
|
||||
PrintWriter errWriter = new PrintWriter( sErrWriter );
|
||||
|
||||
context.setErrWriter( errWriter );
|
||||
|
||||
try
|
||||
{
|
||||
script.execute( context );
|
||||
}
|
||||
catch ( MarmaladeExecutionException e )
|
||||
{
|
||||
throw e;
|
||||
throw new MojoExecutionException( "[ERROR] While executing mojo script.\n Error: " + e.getLocalizedMessage(), e );
|
||||
}
|
||||
|
||||
|
||||
StringBuffer output = sOutWriter.getBuffer();
|
||||
if(output.length() > 0)
|
||||
if ( output.length() > 0 )
|
||||
{
|
||||
getLog().info(output);
|
||||
getLog().info( output );
|
||||
}
|
||||
|
||||
|
||||
StringBuffer error = sErrWriter.getBuffer();
|
||||
if(error.length() > 0)
|
||||
if ( error.length() > 0 )
|
||||
{
|
||||
getLog().error(error);
|
||||
getLog().error( error );
|
||||
}
|
||||
|
||||
// TODO: need to be able to pass back results
|
||||
// Map externalizedVars = context.getExternalizedVariables();
|
||||
// for ( Iterator it = externalizedVars.entrySet().iterator(); it.hasNext(); )
|
||||
// {
|
||||
// Map.Entry entry = (Map.Entry) it.next();
|
||||
//
|
||||
// request.addContextValue( entry.getKey(), entry.getValue() );
|
||||
// }
|
||||
// Map externalizedVars = context.getExternalizedVariables();
|
||||
// for ( Iterator it = externalizedVars.entrySet().iterator(); it.hasNext(); )
|
||||
// {
|
||||
// Map.Entry entry = (Map.Entry) it.next();
|
||||
//
|
||||
// request.addContextValue( entry.getKey(), entry.getValue() );
|
||||
// }
|
||||
}
|
||||
|
||||
public void addComponentRequirement( ComponentRequirement requirementDescriptor, Object requirementValue )
|
||||
{
|
||||
String key = requirementDescriptor.getFieldName();
|
||||
|
||||
if ( StringUtils.isEmpty( key ) )
|
||||
{
|
||||
key = requirementDescriptor.getRole();
|
||||
}
|
||||
|
||||
contextMap.put( key, requirementValue );
|
||||
}
|
||||
|
||||
public void setComponentConfiguration( Map componentConfiguration )
|
||||
{
|
||||
contextMap.putAll( componentConfiguration );
|
||||
}
|
||||
|
||||
}
|
|
@ -73,6 +73,8 @@ public class MetadataTag
|
|||
MojoDescriptor descriptor = new MojoDescriptor();
|
||||
|
||||
descriptor.setLanguage( "marmalade" );
|
||||
descriptor.setComponentComposer( "map-oriented" );
|
||||
descriptor.setComponentConfigurator( "map-oriented" );
|
||||
|
||||
if ( notEmpty( id ) )
|
||||
{
|
||||
|
@ -103,8 +105,6 @@ public class MetadataTag
|
|||
descriptor.setRequiresDependencyResolution( requiresDependencyResolution );
|
||||
descriptor.setRequiresProject( requiresProject );
|
||||
|
||||
// TODO: component requirements
|
||||
|
||||
String basePath = (String) context.getVariable( MarmaladeMojoExecutionDirectives.SCRIPT_BASEPATH_INVAR,
|
||||
getExpressionEvaluator() );
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@ package org.apache.maven.script.marmalade;
|
|||
*/
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.maven.plugin.PluginExecutionRequest;
|
||||
import org.apache.maven.plugin.PluginExecutionResponse;
|
||||
import org.codehaus.marmalade.metamodel.ScriptBuilder;
|
||||
import org.codehaus.marmalade.model.MarmaladeScript;
|
||||
import org.codehaus.marmalade.parsing.DefaultParsingContext;
|
||||
|
@ -50,12 +48,9 @@ public class MarmaladeMojoTest
|
|||
|
||||
MarmaladeMojo mojo = new MarmaladeMojo( script );
|
||||
|
||||
PluginExecutionRequest request = new PluginExecutionRequest( Collections.EMPTY_MAP );
|
||||
request.setParameters( Collections.singletonMap( "param", "paramValue" ) );
|
||||
mojo.setComponentConfiguration( Collections.singletonMap( "param", "paramValue" ) );
|
||||
|
||||
PluginExecutionResponse response = new PluginExecutionResponse();
|
||||
|
||||
mojo.execute( request, response );
|
||||
mojo.execute();
|
||||
|
||||
// TODO: need to be able to pass back results
|
||||
// Object result = request.getContextValue( "testvar" );
|
||||
|
|
Loading…
Reference in New Issue