mirror of https://github.com/apache/maven.git
convert #component expressions to <requirements/>
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163942 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f0e391dba7
commit
378cc229a3
|
@ -392,14 +392,18 @@ public class DefaultPluginManager
|
||||||
configuration = new XmlPlexusConfiguration( dom );
|
configuration = new XmlPlexusConfiguration( dom );
|
||||||
}
|
}
|
||||||
|
|
||||||
Map map = getPluginConfigurationFromExpressions( mojoDescriptor, configuration, session );
|
|
||||||
|
|
||||||
if ( newMojoTechnique )
|
if ( newMojoTechnique )
|
||||||
{
|
{
|
||||||
|
Map map = getPluginConfigurationFromExpressions( mojoDescriptor, configuration, session );
|
||||||
|
|
||||||
populatePluginFields( plugin, configuration, map );
|
populatePluginFields( plugin, configuration, map );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
getLogger().warn( "WARNING: The mojo " + mojoDescriptor.getId() + " is using the OLD API" );
|
||||||
|
|
||||||
|
Map map = getPluginConfigurationFromExpressions( mojoDescriptor, configuration, session );
|
||||||
|
|
||||||
request = createPluginRequest( configuration, map );
|
request = createPluginRequest( configuration, map );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,12 +688,11 @@ public class DefaultPluginManager
|
||||||
public void initialize()
|
public void initialize()
|
||||||
{
|
{
|
||||||
// TODO: configure this from bootstrap or scan lib
|
// TODO: configure this from bootstrap or scan lib
|
||||||
artifactFilter = new ExclusionSetFilter( new String[]{"maven-core", "maven-artifact", "maven-model",
|
artifactFilter =
|
||||||
"maven-settings", "maven-monitor", "maven-plugin-api",
|
new ExclusionSetFilter(
|
||||||
"maven-plugin-descriptor", "plexus-container-default",
|
new String[]{"maven-core", "maven-artifact", "maven-model", "maven-settings", "maven-monitor",
|
||||||
"plexus-artifact-container", "wagon-provider-api",
|
"maven-plugin-api", "maven-plugin-descriptor", "plexus-container-default",
|
||||||
"classworlds",
|
"plexus-artifact-container", "wagon-provider-api", "classworlds", "maven-plugin" /* Just re-added until all plugins are switched over...*/} );
|
||||||
"maven-plugin" /* Just re-added until all plugins are switched over...*/} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
|
@ -51,11 +51,6 @@ public class MavenMojoDescriptor
|
||||||
return mojoDescriptor.getImplementation();
|
return mojoDescriptor.getImplementation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getPrereqs()
|
|
||||||
{
|
|
||||||
return mojoDescriptor.getPrereqs();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getComponentFactory()
|
public String getComponentFactory()
|
||||||
{
|
{
|
||||||
return mojoDescriptor.getLanguage();
|
return mojoDescriptor.getLanguage();
|
||||||
|
@ -75,4 +70,9 @@ public class MavenMojoDescriptor
|
||||||
{
|
{
|
||||||
return DefaultPluginManager.MAVEN_PLUGIN;
|
return DefaultPluginManager.MAVEN_PLUGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List getRequirements()
|
||||||
|
{
|
||||||
|
return mojoDescriptor.getRequirements();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,9 @@ public class PluginParameterExpressionEvaluator
|
||||||
}
|
}
|
||||||
if ( expression.startsWith( "#component" ) )
|
if ( expression.startsWith( "#component" ) )
|
||||||
{
|
{
|
||||||
|
context.getLog().warn( "WARNING: plugin is using deprecated expression " + expression );
|
||||||
|
|
||||||
|
// TODO: deprecated... and can remove the lookup method in context afterwards
|
||||||
String role = expression.substring( 11 );
|
String role = expression.substring( 11 );
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -16,11 +16,19 @@ package org.apache.maven.plugin.descriptor;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.codehaus.plexus.component.repository.ComponentRequirement;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The bean containing the mojo descriptor.
|
||||||
|
*
|
||||||
|
* @todo is there a need for the delegation of MavenMojoDescriptor to this? Why not just extend ComponentDescriptor here?
|
||||||
|
*/
|
||||||
public class MojoDescriptor
|
public class MojoDescriptor
|
||||||
implements Cloneable
|
implements Cloneable
|
||||||
{
|
{
|
||||||
|
@ -48,12 +56,12 @@ public class MojoDescriptor
|
||||||
|
|
||||||
private String phase;
|
private String phase;
|
||||||
|
|
||||||
|
private List requirements;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
private List prereqs;
|
|
||||||
|
|
||||||
private String requiresDependencyResolution = null;
|
private String requiresDependencyResolution = null;
|
||||||
|
|
||||||
private boolean requiresProject = true;
|
private boolean requiresProject = true;
|
||||||
|
@ -64,11 +72,6 @@ public class MojoDescriptor
|
||||||
//
|
//
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public String getRole()
|
|
||||||
{
|
|
||||||
return "org.apache.maven.plugin.Plugin";
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getImplementation()
|
public String getImplementation()
|
||||||
{
|
{
|
||||||
return implementation;
|
return implementation;
|
||||||
|
@ -169,28 +172,24 @@ public class MojoDescriptor
|
||||||
this.requiresProject = requiresProject;
|
this.requiresProject = requiresProject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean requiresProject()
|
public boolean isRequiresProject()
|
||||||
{
|
{
|
||||||
return requiresProject;
|
return requiresProject;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
public void setRequirements( List requirements )
|
||||||
// Prereqs
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
public List getPrereqs()
|
|
||||||
{
|
{
|
||||||
return prereqs;
|
this.requirements = requirements;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrereqs( List prereqs )
|
public List getRequirements()
|
||||||
{
|
{
|
||||||
this.prereqs = prereqs;
|
if ( requirements == null )
|
||||||
|
{
|
||||||
|
requirements = new ArrayList();
|
||||||
|
}
|
||||||
|
return requirements;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
public String getPhase()
|
public String getPhase()
|
||||||
{
|
{
|
||||||
|
@ -226,4 +225,9 @@ public class MojoDescriptor
|
||||||
{
|
{
|
||||||
this.executionStrategy = executionStrategy;
|
this.executionStrategy = executionStrategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addRequirement( ComponentRequirement cr )
|
||||||
|
{
|
||||||
|
getRequirements().add( cr );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.apache.maven.plugin.descriptor;
|
package org.apache.maven.plugin.descriptor;
|
||||||
|
|
||||||
|
import org.codehaus.plexus.component.repository.ComponentRequirement;
|
||||||
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
||||||
import org.codehaus.plexus.configuration.PlexusConfigurationException;
|
import org.codehaus.plexus.configuration.PlexusConfigurationException;
|
||||||
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
|
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
|
||||||
|
@ -155,23 +156,29 @@ public class PluginDescriptorBuilder
|
||||||
|
|
||||||
mojo.setParameters( parameters );
|
mojo.setParameters( parameters );
|
||||||
|
|
||||||
|
// TODO: this should not need to be handed off...
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Prereqs
|
// Requirements
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
PlexusConfiguration[] prereqConfigurations = c.getChild( "prereqs" ).getChildren( "prereq" );
|
PlexusConfiguration[] requirements = c.getChild( "requirements" ).getChildren( "requirement" );
|
||||||
|
|
||||||
List prereqs = new ArrayList();
|
for ( int i = 0; i < requirements.length; i++ )
|
||||||
|
|
||||||
for ( int i = 0; i < prereqConfigurations.length; i++ )
|
|
||||||
{
|
{
|
||||||
PlexusConfiguration d = prereqConfigurations[i];
|
PlexusConfiguration requirement = requirements[i];
|
||||||
|
|
||||||
prereqs.add( d.getValue() );
|
ComponentRequirement cr = new ComponentRequirement();
|
||||||
|
|
||||||
|
cr.setRole( requirement.getChild( "role" ).getValue() );
|
||||||
|
|
||||||
|
cr.setRoleHint( requirement.getChild( "role-hint" ).getValue() );
|
||||||
|
|
||||||
|
cr.setFieldName( requirement.getChild( "field-name" ).getValue() );
|
||||||
|
|
||||||
|
mojo.addRequirement( cr );
|
||||||
}
|
}
|
||||||
|
|
||||||
mojo.setPrereqs( prereqs );
|
|
||||||
|
|
||||||
return mojo;
|
return mojo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ import org.codehaus.plexus.util.xml.XMLWriter;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -159,6 +161,7 @@ public class PluginDescriptorGenerator
|
||||||
|
|
||||||
w.startElement( "parameters" );
|
w.startElement( "parameters" );
|
||||||
|
|
||||||
|
Collection requirements = new ArrayList();
|
||||||
for ( int j = 0; j < parameters.size(); j++ )
|
for ( int j = 0; j < parameters.size(); j++ )
|
||||||
{
|
{
|
||||||
Parameter parameter = (Parameter) parameters.get( j );
|
Parameter parameter = (Parameter) parameters.get( j );
|
||||||
|
@ -169,11 +172,18 @@ public class PluginDescriptorGenerator
|
||||||
|
|
||||||
element( w, "type", parameter.getType() );
|
element( w, "type", parameter.getType() );
|
||||||
|
|
||||||
element( w, "required", Boolean.toString( parameter.isRequired() ) );
|
|
||||||
|
|
||||||
element( w, "validator", parameter.getValidator() );
|
element( w, "validator", parameter.getValidator() );
|
||||||
|
|
||||||
|
if ( parameter.getExpression().startsWith( "#component" ) )
|
||||||
|
{
|
||||||
|
requirements.add( parameter );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
element( w, "required", Boolean.toString( parameter.isRequired() ) );
|
||||||
|
|
||||||
element( w, "expression", parameter.getExpression() );
|
element( w, "expression", parameter.getExpression() );
|
||||||
|
}
|
||||||
|
|
||||||
element( w, "description", parameter.getDescription() );
|
element( w, "description", parameter.getDescription() );
|
||||||
|
|
||||||
|
@ -185,20 +195,24 @@ public class PluginDescriptorGenerator
|
||||||
w.endElement();
|
w.endElement();
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Prereqs
|
// Requirements
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
// TODO: remove
|
if ( !requirements.isEmpty() )
|
||||||
|
|
||||||
List prereqs = mojoDescriptor.getPrereqs();
|
|
||||||
|
|
||||||
if ( prereqs != null && prereqs.size() > 0 )
|
|
||||||
{
|
{
|
||||||
w.startElement( "prereqs" );
|
w.startElement( "requirements" );
|
||||||
|
|
||||||
for ( int j = 0; j < prereqs.size(); j++ )
|
for ( Iterator i = requirements.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
element( w, "prereq", (String) prereqs.get( j ) );
|
Parameter requirement = (Parameter) i.next();
|
||||||
|
|
||||||
|
w.startElement( "requirement" );
|
||||||
|
|
||||||
|
element( w, "role", requirement.getExpression().substring( 11 ) );
|
||||||
|
|
||||||
|
element( w, "field-name", requirement.getName() );
|
||||||
|
|
||||||
|
w.endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
w.endElement();
|
w.endElement();
|
||||||
|
|
|
@ -214,27 +214,6 @@ public class JellyHarnessGenerator
|
||||||
|
|
||||||
w.addAttribute( "name", id + ":" + mojoDescriptor.getGoal() );
|
w.addAttribute( "name", id + ":" + mojoDescriptor.getGoal() );
|
||||||
|
|
||||||
List goalPrereqs = mojoDescriptor.getPrereqs();
|
|
||||||
|
|
||||||
if ( goalPrereqs.size() > 0 )
|
|
||||||
{
|
|
||||||
StringBuffer prereqs = new StringBuffer();
|
|
||||||
|
|
||||||
for ( int j = 0; j < goalPrereqs.size(); j++ )
|
|
||||||
{
|
|
||||||
String prereq = (String) goalPrereqs.get( j );
|
|
||||||
|
|
||||||
prereqs.append( prereq );
|
|
||||||
|
|
||||||
if ( j < goalPrereqs.size() - 1 )
|
|
||||||
{
|
|
||||||
prereqs.append( "," );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
w.addAttribute( "prereqs", prereqs.toString() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( mojoDescriptor.getDescription() != null )
|
if ( mojoDescriptor.getDescription() != null )
|
||||||
{
|
{
|
||||||
w.addAttribute( "description", mojoDescriptor.getDescription() );
|
w.addAttribute( "description", mojoDescriptor.getDescription() );
|
||||||
|
|
|
@ -103,6 +103,8 @@ public class MetadataTag
|
||||||
descriptor.setRequiresDependencyResolution( requiresDependencyResolution );
|
descriptor.setRequiresDependencyResolution( requiresDependencyResolution );
|
||||||
descriptor.setRequiresProject( requiresProject );
|
descriptor.setRequiresProject( requiresProject );
|
||||||
|
|
||||||
|
// TODO: component requirements
|
||||||
|
|
||||||
String basePath = (String) context.getVariable( MarmaladeMojoExecutionDirectives.SCRIPT_BASEPATH_INVAR,
|
String basePath = (String) context.getVariable( MarmaladeMojoExecutionDirectives.SCRIPT_BASEPATH_INVAR,
|
||||||
getExpressionEvaluator() );
|
getExpressionEvaluator() );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue