jvanzyl 2004/05/20 10:09:31
Modified: maven-core bootstrap-all.sh bootstrap.plugins bootstrap.sh
project.xml
maven-core/src/main/java/org/apache/maven
DefaultMavenCore.java Maven.java MavenCli.java
MavenCore.java
maven-core/src/main/java/org/apache/maven/lifecycle/phase
GoalAttainmentPhase.java
maven-core/src/main/resources/META-INF/plexus components.xml
maven-core/src/main/resources/org/apache/maven plexus.xml
maven-core/src/test/java/org/apache/maven/plugin
PluginTest.java
maven-core/src/test/resources/org/apache/maven/plugin
integrated-plugin.xml
Added: maven-core/src/main/java/org/apache/maven/plugin
AbstractPluginManager.java
DefaultPluginManager.java
MavenPluginDescriptor.java
MavenPluginDiscoverer.java
OgnlProjectValueExtractor.java PluginManager.java
Removed: maven-core/src/main/java/org/apache/maven/plugin
AbstractPlugin.java GoalDescriptor.java
IntegratedPluginGoalTestCase.java
ParameterDescriptor.java Plugin.java
PluginConfigurationException.java
PluginDescriptor.java PluginDescriptorBuilder.java
PluginExecutionRequest.java
PluginExecutionResponse.java
maven-core/src/main/java/org/apache/maven/plugin/discovery
MavenPluginDiscoverer.java
maven-core/src/main/java/org/apache/maven/plugin/manager
AbstractPluginManager.java
DefaultPluginManager.java
OgnlProjectValueExtractor.java PluginManager.java
maven-core/src/main/java/org/apache/maven/plugin/manager/executor
FieldPluginExecutor.java
IntegratedPluginExecutor.java PluginExecutor.java
SetterPluginExecutor.java
maven-core/src/test/java/org/apache/maven/plugin
FieldPlugin.java FieldPluginState.java
PluginDescriptorBuilderTest.java
PluginManagerManagerTest.java SetterPlugin.java
SetterPluginState.java
maven-core/src/test/resources/org/apache/maven/plugin
field-plugin.xml setter-plugin.xml
Log:
o a great simplification of the code
o just using maven-plugins now, adapters can easily be written to make any
other form conform.
o use of the maven-plugin build, we are adapting a PluginDescriptor into
a MavenPluginDescriptor to use the plugins. this means that the plugins
are fully decoupled and we just adapt them for use here.
Revision Changes Path
1.4 +9 -0 maven-components/maven-core/bootstrap-all.sh
Index: bootstrap-all.sh
===================================================================
RCS file: /home/cvs/maven-components/maven-core/bootstrap-all.sh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- bootstrap-all.sh 12 Apr 2004 14:44:11 -0000 1.3
+++ bootstrap-all.sh 20 May 2004 17:09:30 -0000 1.4
@@ -41,6 +41,15 @@
mboot --install
)
+# Build and install maven-plugin.
+(
+ echo "-----------------------------------------------------------------------"
+ echo " Building maven-plugin ... "
+ echo "-----------------------------------------------------------------------"
+
+ cd ../maven-plugin
+ mboot --install
+)
# Bootstrap the maven-core component which will give you a small distribution.
echo "-----------------------------------------------------------------------"
echo " Building maven-core ... "
1.6 +0 -4 maven-components/maven-core/bootstrap.plugins
Index: bootstrap.plugins
===================================================================
RCS file: /home/cvs/maven-components/maven-core/bootstrap.plugins,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- bootstrap.plugins 7 May 2004 23:46:51 -0000 1.5
+++ bootstrap.plugins 20 May 2004 17:09:30 -0000 1.6
@@ -1,9 +1,5 @@
maven-clean-plugin
maven-compiler-plugin
-maven-hello-plugin
maven-jar-plugin
maven-resources-plugin
-maven-scm-plugin
maven-surefire-plugin
-maven-xdoc-plugin
-maven-idea-plugin
1.8 +8 -1 maven-components/maven-core/bootstrap.sh
Index: bootstrap.sh
===================================================================
RCS file: /home/cvs/maven-components/maven-core/bootstrap.sh,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- bootstrap.sh 7 May 2004 18:06:49 -0000 1.7
+++ bootstrap.sh 20 May 2004 17:09:30 -0000 1.8
@@ -62,7 +62,14 @@
echo " Building ${plugin} plugin ... "
echo "-----------------------------------------------------------------------"
- mboot --dir ../maven-plugins/${plugin}
+ (
+ cd ../maven-plugins/${plugin}
+
+ echo "Generating plugin descriptor for ${plugin} ..."
+ pluggy --mode=descriptor --source=src/main/java
--destination=src/main/resources/META-INF/maven
+
+ mboot
+ )
cp ../maven-plugins/${plugin}/target/${plugin}*.jar ${DIST}/plugins/plexus
1.12 +8 -0 maven-components/maven-core/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/maven-components/maven-core/project.xml,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- project.xml 12 May 2004 23:38:40 -0000 1.11
+++ project.xml 20 May 2004 17:09:30 -0000 1.12
@@ -14,6 +14,7 @@
<package>org.apache.maven</package>
<logo>/images/maven.gif</logo>
<dependencies>
+ <!-- maven component -->
<dependency>
<groupId>maven</groupId>
<artifactId>maven-model</artifactId>
@@ -25,10 +26,17 @@
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
+ <groupId>maven</groupId>
+ <artifactId>maven-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <!-- -->
+ <dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.0-beta-2</version>
</dependency>
+ <!-- plexus -->
<dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3</artifactId>
1.6 +8 -6
maven-components/maven-core/src/main/java/org/apache/maven/DefaultMavenCore.java
Index: DefaultMavenCore.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/DefaultMavenCore.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DefaultMavenCore.java 15 May 2004 06:23:11 -0000 1.5
+++ DefaultMavenCore.java 20 May 2004 17:09:30 -0000 1.6
@@ -18,10 +18,12 @@
import org.apache.maven.lifecycle.MavenLifecycleContext;
import org.apache.maven.lifecycle.MavenLifecycleManager;
-import org.apache.maven.plugin.GoalDescriptor;
-import org.apache.maven.plugin.PluginDescriptor;
-import org.apache.maven.plugin.PluginDescriptor;
-import org.apache.maven.plugin.manager.PluginManager;
+import org.apache.maven.plugin.PluginManager;
+import org.apache.maven.plugin.MavenPluginDescriptor;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.plugin.descriptor.Goal;
+import org.apache.maven.plugin.MavenPluginDescriptor;
+import org.apache.maven.plugin.PluginManager;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
@@ -136,7 +138,7 @@
return pluginManager.getPluginDescriptors();
}
- public PluginDescriptor getPluginDescriptor( String pluginId )
+ public MavenPluginDescriptor getPluginDescriptor( String pluginId )
{
return pluginManager.getPluginDescriptor( pluginId );
}
@@ -150,7 +152,7 @@
return pluginManager.getGoalDescriptors();
}
- public GoalDescriptor getGoalDescriptor( String goalId )
+ public Goal getGoalDescriptor( String goalId )
{
return pluginManager.getGoalDescriptor( goalId );
}
1.16 +5 -5
maven-components/maven-core/src/main/java/org/apache/maven/Maven.java
Index: Maven.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/Maven.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- Maven.java 15 May 2004 06:23:11 -0000 1.15
+++ Maven.java 20 May 2004 17:09:30 -0000 1.16
@@ -16,8 +16,8 @@
* limitations under the License.
*/
-import org.apache.maven.plugin.GoalDescriptor;
-import org.apache.maven.plugin.PluginDescriptor;
+import org.apache.maven.plugin.descriptor.Goal;
+import org.apache.maven.plugin.MavenPluginDescriptor;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingException;
import org.codehaus.classworlds.ClassWorld;
@@ -107,7 +107,7 @@
return maven.getPluginDescriptors();
}
- public PluginDescriptor getPluginDescriptor( String pluginId )
+ public MavenPluginDescriptor getPluginDescriptor( String pluginId )
{
return maven.getPluginDescriptor( pluginId );
}
@@ -121,7 +121,7 @@
return maven.getGoalDescriptors();
}
- public GoalDescriptor getGoalDescriptor( String goalId )
+ public Goal getGoalDescriptor( String goalId )
{
return maven.getGoalDescriptor( goalId );
}
1.6 +4 -3
maven-components/maven-core/src/main/java/org/apache/maven/MavenCli.java
Index: MavenCli.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/MavenCli.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- MavenCli.java 16 May 2004 11:38:31 -0000 1.5
+++ MavenCli.java 20 May 2004 17:09:30 -0000 1.6
@@ -27,7 +27,7 @@
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
-import org.apache.maven.plugin.GoalDescriptor;
+import org.apache.maven.plugin.descriptor.Goal;
import org.codehaus.classworlds.ClassWorld;
@@ -97,7 +97,8 @@
while ( goals.hasNext() )
{
- GoalDescriptor goal = (GoalDescriptor)goals.next();
+ Goal goal = (Goal)goals.next();
+
System.out.println( " " + goal.getName() );
}
1.5 +5 -6
maven-components/maven-core/src/main/java/org/apache/maven/MavenCore.java
Index: MavenCore.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/MavenCore.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MavenCore.java 15 May 2004 06:23:11 -0000 1.4
+++ MavenCore.java 20 May 2004 17:09:30 -0000 1.5
@@ -16,9 +16,8 @@
* limitations under the License.
*/
-import org.apache.maven.plugin.GoalDescriptor;
-import org.apache.maven.plugin.PluginDescriptor;
-import org.apache.maven.plugin.GoalDescriptor;
+import org.apache.maven.plugin.descriptor.Goal;
+import org.apache.maven.plugin.MavenPluginDescriptor;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingException;
@@ -59,7 +58,7 @@
Map getPluginDescriptors();
- PluginDescriptor getPluginDescriptor( String pluginId );
+ MavenPluginDescriptor getPluginDescriptor( String pluginId );
// ----------------------------------------------------------------------
// Goal descriptors
@@ -67,7 +66,7 @@
Map getGoalDescriptors();
- GoalDescriptor getGoalDescriptor( String goalId );
+ Goal getGoalDescriptor( String goalId );
// ----------------------------------------------------------------------
// Maven home
1.5 +3 -2
maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/GoalAttainmentPhase.java
Index: GoalAttainmentPhase.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/GoalAttainmentPhase.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- GoalAttainmentPhase.java 8 May 2004 21:11:17 -0000 1.4
+++ GoalAttainmentPhase.java 20 May 2004 17:09:30 -0000 1.5
@@ -3,7 +3,8 @@
import org.apache.maven.lifecycle.AbstractMavenLifecyclePhase;
import org.apache.maven.lifecycle.MavenLifecycleContext;
import org.apache.maven.plugin.PluginExecutionResponse;
-import org.apache.maven.plugin.manager.PluginManager;
+import org.apache.maven.plugin.PluginManager;
+import org.apache.maven.plugin.PluginManager;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
1.1
maven-components/maven-core/src/main/java/org/apache/maven/plugin/AbstractPluginManager.java
Index: AbstractPluginManager.java
===================================================================
package org.apache.maven.plugin;
/*
* 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.util.List;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @version $Id: AbstractPluginManager.java,v 1.1 2004/05/20 17:09:30 jvanzyl Exp $
*/
public abstract class AbstractPluginManager
implements PluginManager
{
protected File pluginsDir;
protected String mavenHome;
protected String mavenLocalHome;
protected List goals;
public abstract String getId();
public List getGoals()
{
return goals;
}
protected void setupPluginsDirectories()
throws Exception
{
pluginsDir = new File( new File( mavenHome, "plugins" ), getId() );
if ( !pluginsDir.exists() )
{
pluginsDir.mkdirs();
}
}
}
1.1
maven-components/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
Index: DefaultPluginManager.java
===================================================================
package org.apache.maven.plugin;
/*
* 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.lifecycle.MavenLifecycleContext;
import org.apache.maven.plugin.descriptor.Goal;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
import org.apache.maven.project.MavenProject;
import org.apache.maven.script.GoalDecorator;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.discovery.ComponentDiscoveryEvent;
import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import org.codehaus.plexus.util.dag.CycleDetectedException;
import org.codehaus.plexus.util.dag.DAG;
import org.codehaus.plexus.util.dag.TopologicalSorter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Stack;
public class DefaultPluginManager
extends AbstractLogEnabled
implements PluginManager, ComponentDiscoveryListener, Contextualizable
{
static String MAVEN_PLUGIN = "maven-plugin";
private PlexusContainer container;
protected String mavenHome;
protected DAG dag = new DAG();
protected Map goalDescriptors;
protected Map goalToPluginMap;
protected Map pluginDescriptors;
protected PluginDescriptorBuilder pluginDescriptorBuilder;
public DefaultPluginManager()
{
goalDescriptors = new HashMap();
goalToPluginMap = new HashMap();
pluginDescriptors = new HashMap();
pluginDescriptorBuilder = new PluginDescriptorBuilder();
}
// ----------------------------------------------------------------------
// Plugin execution
// ----------------------------------------------------------------------
public PluginExecutionResponse attainGoal( MavenLifecycleContext context )
{
String goalToAttain = context.getGoal();
List goals = TopologicalSorter.sort( dag.getVertex( goalToAttain ) );
PluginExecutionResponse response = new PluginExecutionResponse();
int goalIndex = goals.indexOf( goalToAttain );
List goalList = goals.subList( 0, goalIndex + 1 );
Stack execStack = new Stack();
for ( Iterator it = goalList.iterator(); it.hasNext(); )
{
execStack.push( it.next() );
}
attainGoalStack( context, execStack, response );
return response;
}
/**
* The presumption is that a goal and all of its prerequisites are considered to
be an atomic
* whole. Therefore, execution should proceed in the manner:
* preGoals, prereqs, goal, postGoals
*
* @param goals The stack of goals to execute, in reverse-dependency
ordering. This allows
* us easier access to the pregoals before we execute the
prerequisites.
* @param response The execution response to send through the pre-goal,
post-goal, prereq, and
* actual goal executions.
*/
private void attainGoalStack( MavenLifecycleContext context, Stack goals,
PluginExecutionResponse response )
{
if ( !goals.isEmpty() )
{
String goalName = (String) goals.pop();
context.setGoal( goalName );
String goal = context.getGoal();
System.out.println( "[" + goal + "]" );
Goal goalDescriptor = getGoalDescriptor( goal );
PluginExecutionRequest request = new PluginExecutionRequest(
createParameters( goalDescriptor, context.getProject() ) );
request.addContextValue( "id", getPluginDescriptor( goal ).getId() );
request.addContextValue( "method", getGoalDescriptor( goal ).getMethod()
);
request.addContextValue( "mode", getPluginDescriptor( goal ).getMode() );
if ( context.getScript() != null )
{
List preGoals = context.getScript().getPreGoals( goal );
for ( Iterator it = preGoals.iterator(); it.hasNext(); )
{
GoalDecorator preGoal = (GoalDecorator) it.next();
preGoal.execute( request, response );
if ( response.exceptionOccurred() )
{
break;
}
}
}
if ( !response.exceptionOccurred() )
{
attainGoalStack( context, goals, response );
}
if ( !response.exceptionOccurred() )
{
attainGoal( request, response );
}
if ( !response.exceptionOccurred() )
{
if ( context.getScript() != null )
{
List postGoals = context.getScript().getPostGoals( goal );
for ( Iterator it = postGoals.iterator(); it.hasNext(); )
{
GoalDecorator postGoal = (GoalDecorator) it.next();
postGoal.execute( request, response );
if ( response.exceptionOccurred() )
{
break;
}
}
}
}
}
}
public void attainGoal( PluginExecutionRequest request, PluginExecutionResponse
response )
{
try
{
Plugin plugin = (Plugin) container.lookup( Plugin.ROLE, (String)
request.getContextValue( "id" ) );
plugin.execute( request, response );
}
catch ( ComponentLookupException e )
{
response.setException( e );
}
catch( Exception e )
{
response.setException( e );
}
}
// ----------------------------------------------------------------------
// Create parameters for plugin execution
// ----------------------------------------------------------------------
public static Map createParameters( Goal goalDescriptor, MavenProject project )
{
Map map = null;
List parameters = goalDescriptor.getParameters();
if ( parameters != null )
{
map = new HashMap();
for ( int i = 0; i < parameters.size(); i++ )
{
Parameter c = (Parameter) parameters.get( i );
String key = c.getName();
String expression = c.getExpression();
Object value = OgnlProjectValueExtractor.evaluate( expression,
project );
map.put( key, value );
}
}
return map;
}
// ----------------------------------------------------------------------
// Plugin descriptors
// ----------------------------------------------------------------------
public Map getPluginDescriptors()
{
return pluginDescriptors;
}
public MavenPluginDescriptor getPluginDescriptor( String goalName )
{
return (MavenPluginDescriptor) goalToPluginMap.get( goalName );
}
// ----------------------------------------------------------------------
// Goal descriptors
// ----------------------------------------------------------------------
public Map getGoalDescriptors()
{
return goalDescriptors;
}
public Goal getGoalDescriptor( String name )
{
return (Goal) goalDescriptors.get( name );
}
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
public void processPluginDescriptor( MavenPluginDescriptor pluginDescriptor )
throws CycleDetectedException
{
List goals = pluginDescriptor.getGoals();
for ( Iterator j = goals.iterator(); j.hasNext(); )
{
Goal goalDescriptor = (Goal) j.next();
if ( goalDescriptor.getPrereqs() != null )
{
for ( Iterator k = goalDescriptor.getPrereqs().iterator();
k.hasNext(); )
{
dag.addEdge( goalDescriptor.getName(), (String) k.next() );
}
}
else
{
dag.addVertex( goalDescriptor.getName() );
}
goalDescriptors.put( goalDescriptor.getName(), goalDescriptor );
goalToPluginMap.put( goalDescriptor.getName(), pluginDescriptor );
}
pluginDescriptors.put( pluginDescriptor.getId(), pluginDescriptor );
}
// ----------------------------------------------------------------------
// Plugin discovery
// ----------------------------------------------------------------------
public void componentDiscovered( ComponentDiscoveryEvent event )
{
if ( event.getComponentType().equals( MAVEN_PLUGIN ) )
{
// What is coming back here is a subclass of a plexus component
descriptor
// So are the use of PluginDescriptor and MavenPluginDescriptor needed?
// What is the relationship?
MavenPluginDescriptor pluginDescriptor = (MavenPluginDescriptor)
event.getComponentDescriptor();
try
{
processPluginDescriptor( pluginDescriptor );
}
catch ( CycleDetectedException e )
{
getLogger().error( "A cycle was detected in the goal graph: ", e );
}
}
}
// ----------------------------------------------------------------------
// Lifecycle
// ----------------------------------------------------------------------
public void contextualize( Context context )
throws ContextException
{
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}
}
1.1
maven-components/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginDescriptor.java
Index: MavenPluginDescriptor.java
===================================================================
package org.apache.maven.plugin;
import org.codehaus.plexus.component.repository.ComponentDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import java.util.List;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @version $Id: MavenPluginDescriptor.java,v 1.1 2004/05/20 17:09:30 jvanzyl Exp $
*/
public class MavenPluginDescriptor
extends ComponentDescriptor
{
private PluginDescriptor pluginDescriptor;
public MavenPluginDescriptor( PluginDescriptor pluginDescriptor )
{
this.pluginDescriptor = pluginDescriptor;
}
// ----------------------------------------------------------------------
// These are things we need to alter slightly for a maven component.
// ----------------------------------------------------------------------
public String getImplementation()
{
return pluginDescriptor.getImplementation();
}
public String getRole()
{
return "org.apache.maven.plugin.Plugin";
}
public String getRoleHint()
{
return getId();
}
// ----------------------------------------------------------------------
// These are things we have added to the notion of component for maven.
// ----------------------------------------------------------------------
public String getId()
{
return pluginDescriptor.getId();
}
public String getMode()
{
return pluginDescriptor.getMode();
}
public List getGoals()
{
return pluginDescriptor.getGoals();
}
}
1.1
maven-components/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginDiscoverer.java
Index: MavenPluginDiscoverer.java
===================================================================
package org.apache.maven.plugin;
/*
* 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.PluginDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
import org.codehaus.plexus.component.discovery.AbstractComponentDiscoverer;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @version $Id: MavenPluginDiscoverer.java,v 1.1 2004/05/20 17:09:30 jvanzyl Exp $
*/
public class MavenPluginDiscoverer
extends AbstractComponentDiscoverer
{
private PluginDescriptorBuilder builder;
public MavenPluginDiscoverer()
{
builder = new PluginDescriptorBuilder();
}
public String getComponentDescriptorLocation()
{
return "META-INF/maven/plugin.xml";
}
public String getComponentType()
{
return "maven-plugin";
}
public List createComponentDescriptors( Reader componentDescriptorConfiguration,
String source )
throws Exception
{
List componentDescriptors = new ArrayList();
PluginDescriptor pluginDescriptor = null;
//!! If there is a defective plugin installed should we halt everything or
// just not process that particular plugin
try
{
pluginDescriptor = builder.build( componentDescriptorConfiguration );
}
catch( Exception e )
{
throw new Exception( "Cannot process plugin descriptor: " + source, e );
}
componentDescriptors.add( new MavenPluginDescriptor( pluginDescriptor ) );
return componentDescriptors;
}
}
1.1
maven-components/maven-core/src/main/java/org/apache/maven/plugin/OgnlProjectValueExtractor.java
Index: OgnlProjectValueExtractor.java
===================================================================
package org.apache.maven.plugin;
/*
* 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 ognl.Ognl;
import ognl.OgnlException;
import org.apache.maven.project.MavenProject;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @version $Id: OgnlProjectValueExtractor.java,v 1.1 2004/05/20 17:09:30 jvanzyl
Exp $
*/
public class OgnlProjectValueExtractor
{
public static Object evaluate( String expression, MavenProject project )
{
Object value = null;
if ( expression.equals( "#project" ) )
{
value = project;
}
else if ( expression.startsWith( "#project" ) )
{
try
{
value = Ognl.getValue( expression.substring( 9 ), project );
}
catch ( OgnlException e )
{
// do nothing
}
}
else if ( expression.startsWith( "#basedir" ) )
{
value = project.getFile().getParentFile().getAbsolutePath();
}
else if ( expression.startsWith( "#" ) )
{
expression = expression.substring( 1 );
value = project.getProperty( expression );
}
// If we strike out we'll just use the expression which allows
// people to use hardcoded values if they wish.
if ( value == null )
{
value = expression;
}
return value;
}
}
1.1
maven-components/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
Index: PluginManager.java
===================================================================
package org.apache.maven.plugin;
/*
* 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.lifecycle.MavenLifecycleContext;
import org.apache.maven.plugin.PluginExecutionResponse;
import org.apache.maven.plugin.MavenPluginDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.descriptor.Goal;
import java.util.Map;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @version $Id: PluginManager.java,v 1.1 2004/05/20 17:09:31 jvanzyl Exp $
*/
public interface PluginManager
{
String ROLE = PluginManager.class.getName();
// ----------------------------------------------------------------------
// Plugin execution
// ----------------------------------------------------------------------
PluginExecutionResponse attainGoal( MavenLifecycleContext context );
// ----------------------------------------------------------------------
// Plugin processing
// ----------------------------------------------------------------------
void processPluginDescriptor( MavenPluginDescriptor pluginDescriptor )
throws Exception;
// ----------------------------------------------------------------------
// Plugin descriptors
// ----------------------------------------------------------------------
Map getPluginDescriptors();
MavenPluginDescriptor getPluginDescriptor( String pluginId );
// ----------------------------------------------------------------------
// Goal descriptors
// ----------------------------------------------------------------------
Map getGoalDescriptors();
Goal getGoalDescriptor( String goalId );
}
1.5 +1 -1
maven-components/maven-core/src/main/resources/META-INF/plexus/components.xml
Index: components.xml
===================================================================
RCS file:
/home/cvs/maven-components/maven-core/src/main/resources/META-INF/plexus/components.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- components.xml 8 May 2004 21:11:17 -0000 1.4
+++ components.xml 20 May 2004 17:09:31 -0000 1.5
@@ -5,7 +5,7 @@
<implementation>org.apache.maven.DefaultMavenCore</implementation>
<requirements>
<requirement>
- <role>org.apache.maven.plugin.manager.PluginManager</role>
+ <role>org.apache.maven.plugin.PluginManager</role>
</requirement>
<requirement>
<role>org.apache.maven.project.MavenProjectBuilder</role>
1.13 +10 -10
maven-components/maven-core/src/main/resources/org/apache/maven/plexus.xml
Index: plexus.xml
===================================================================
RCS file:
/home/cvs/maven-components/maven-core/src/main/resources/org/apache/maven/plexus.xml,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- plexus.xml 8 May 2004 21:11:17 -0000 1.12
+++ plexus.xml 20 May 2004 17:09:31 -0000 1.13
@@ -2,11 +2,11 @@
<component-discoverer-manager
implementation="org.codehaus.plexus.component.discovery.DefaultComponentDiscovererManager">
<listeners>
<listener>
- <role>org.apache.maven.plugin.manager.PluginManager</role>
+ <role>org.apache.maven.plugin.PluginManager</role>
</listener>
</listeners>
<component-discoverers>
- <component-discoverer
implementation="org.apache.maven.plugin.discovery.MavenPluginDiscoverer"/>
+ <component-discoverer
implementation="org.apache.maven.plugin.MavenPluginDiscoverer"/>
</component-discoverers>
</component-discoverer-manager>
<resources>
@@ -14,26 +14,26 @@
</resources>
<components>
<component>
- <role>org.apache.maven.plugin.manager.PluginManager</role>
-
<implementation>org.apache.maven.plugin.manager.DefaultPluginManager</implementation>
+ <role>org.apache.maven.plugin.PluginManager</role>
+ <implementation>org.apache.maven.plugin.DefaultPluginManager</implementation>
<configuration>
<maven-home>${maven.home}</maven-home>
</configuration>
</component>
<component>
- <role>org.apache.maven.plugin.manager.executor.PluginExecutor</role>
+ <role>org.apache.maven.plugin.executor.PluginExecutor</role>
<role-hint>field</role-hint>
-
<implementation>org.apache.maven.plugin.manager.executor.FieldPluginExecutor</implementation>
+ <implementation>org.apache.maven.plugin.FieldPluginExecutor</implementation>
</component>
<component>
- <role>org.apache.maven.plugin.manager.executor.PluginExecutor</role>
+ <role>org.apache.maven.plugin.PluginExecutor</role>
<role-hint>setter</role-hint>
-
<implementation>org.apache.maven.plugin.manager.executor.SetterPluginExecutor</implementation>
+ <implementation>org.apache.maven.plugin.SetterPluginExecutor</implementation>
</component>
<component>
- <role>org.apache.maven.plugin.manager.executor.PluginExecutor</role>
+ <role>org.apache.maven.plugin.PluginExecutor</role>
<role-hint>integrated</role-hint>
-
<implementation>org.apache.maven.plugin.manager.executor.IntegratedPluginExecutor</implementation>
+
<implementation>org.apache.maven.plugin.IntegratedPluginExecutor</implementation>
</component>
</components>
</configuration>
1.9 +7 -52
maven-components/maven-core/src/test/java/org/apache/maven/plugin/PluginTest.java
Index: PluginTest.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/plugin/PluginTest.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- PluginTest.java 15 May 2004 06:23:11 -0000 1.8
+++ PluginTest.java 20 May 2004 17:09:31 -0000 1.9
@@ -18,9 +18,10 @@
import org.apache.maven.MavenCore;
import org.apache.maven.MavenPlexusComponentTestBase;
-import org.apache.maven.plugin.PluginDescriptor;
-import org.apache.maven.plugin.PluginDescriptorBuilder;
-import org.apache.maven.plugin.manager.PluginManager;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
+import org.apache.maven.plugin.PluginManager;
+import org.apache.maven.plugin.MavenPluginDescriptor;
import java.io.File;
import java.io.InputStream;
@@ -60,9 +61,9 @@
PluginDescriptor pd = builder.build( new InputStreamReader( is ) );
- getContainer().addComponentDescriptor( pd );
+ getContainer().addComponentDescriptor( new MavenPluginDescriptor( pd ) );
- pluginMM.processPluginDescriptor( pd );
+ pluginMM.processPluginDescriptor( new MavenPluginDescriptor( pd ) );
}
public void testIntegratedPlugin()
@@ -83,51 +84,5 @@
assertEquals( "maven-core", integratedPlugin.getArtifactId() );
assertEquals( "bar", integratedPlugin.getFoo() );
- }
-
- public void testSetterPlugin()
- throws Exception
- {
- registerPlugin( "setter-plugin.xml" );
-
- MavenCore maven = (MavenCore) lookup( MavenCore.ROLE );
-
- maven.execute( new File( System.getProperty( "user.dir"), "project.xml" ),
"setter-execute" );
-
- // Now the goal has been attain, but because the instantiation strategy is
per-lookup
- // We can't get the plugin object that executed. So we've made a little
class called
- // PluginFieldState which has some static fields that are set by the
FieldPlugin
- // executing.
-
- assertTrue( SetterPluginState.executed );
-
- assertEquals( "Maven", SetterPluginState.name );
-
- assertEquals( "maven-core", SetterPluginState.artifactId );
-
- assertEquals( "bar", SetterPluginState.foo );
- }
-
- public void testFieldPlugin()
- throws Exception
- {
- registerPlugin( "field-plugin.xml" );
-
- MavenCore maven = (MavenCore) lookup( MavenCore.ROLE );
-
- maven.execute( new File( System.getProperty( "user.dir"), "project.xml" ),
"field-execute" );
-
- // Now the goal has been attain, but because the instantiation strategy is
per-lookup
- // We can't get the plugin object that executed. So we've made a little
class called
- // PluginFieldState which has some static fields that are set by the
FieldPlugin
- // executing.
-
- assertTrue( FieldPluginState.executed );
-
- assertEquals( "Maven", FieldPluginState.name );
-
- assertEquals( "maven-core", FieldPluginState.artifactId );
-
- assertEquals( "bar", FieldPluginState.foo );
}
}
1.4 +1 -1
maven-components/maven-core/src/test/resources/org/apache/maven/plugin/integrated-plugin.xml
Index: integrated-plugin.xml
===================================================================
RCS file:
/home/cvs/maven-components/maven-core/src/test/resources/org/apache/maven/plugin/integrated-plugin.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- integrated-plugin.xml 22 Mar 2004 18:05:39 -0000 1.3
+++ integrated-plugin.xml 20 May 2004 17:09:31 -0000 1.4
@@ -1,7 +1,7 @@
<plugin>
<id>integrated-plugin</id>
<implementation>org.apache.maven.plugin.IntegratedPlugin</implementation>
- <instantiation-strategy>singleton</instantiation-strategy>
+ <instantiationStrategy>singleton</instantiationStrategy>
<mode>integrated</mode>
<goals>
<goal>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]