Author: brett
Date: Mon Jun 20 07:42:56 2005
New Revision: 191476
URL: http://svn.apache.org/viewcvs?rev=191476&view=rev
Log:
PR: MNG-471
implemented cloned lifecycle, project and tests. update mojos accordingly
Added:
maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItForkerMojo.java
(with props)
maven/components/trunk/maven-core-it-plugin/src/main/resources/
maven/components/trunk/maven-core-it-plugin/src/main/resources/META-INF/
maven/components/trunk/maven-core-it-plugin/src/main/resources/META-INF/maven/
maven/components/trunk/maven-core-it-plugin/src/main/resources/META-INF/maven/lifecycle.xml
(with props)
maven/components/trunk/maven-core-it/it0027/ (with props)
maven/components/trunk/maven-core-it/it0027/expected-results.txt (with
props)
maven/components/trunk/maven-core-it/it0027/goals.txt (with props)
maven/components/trunk/maven-core-it/it0027/pom.xml (with props)
Modified:
maven/components/trunk/maven-core-it-plugin/pom.xml
maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
maven/components/trunk/maven-core-it/README.txt
maven/components/trunk/maven-core-it/integration-tests.txt
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java
maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseWriter.java
maven/components/trunk/maven-plugins/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaMojo.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
maven/components/trunk/maven-site/src/site/apt/lifecycle.apt
Modified: maven/components/trunk/maven-core-it-plugin/pom.xml
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it-plugin/pom.xml?rev=191476&r1=191475&r2=191476&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it-plugin/pom.xml (original)
+++ maven/components/trunk/maven-core-it-plugin/pom.xml Mon Jun 20 07:42:56 2005
@@ -10,4 +10,11 @@
<name>Maven Core Integration Test Plugin</name>
<version>1.0-SNAPSHOT</version>
<inceptionYear>2001</inceptionYear>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
</model>
Added:
maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItForkerMojo.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItForkerMojo.java?rev=191476&view=auto
==============================================================================
---
maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItForkerMojo.java
(added)
+++
maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItForkerMojo.java
Mon Jun 20 07:42:56 2005
@@ -0,0 +1,54 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * 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.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * @goal fork
+ *
+ * @execute phase="generate-sources" lifecycle="foo"
+ */
+public class CoreItForkerMojo
+ extends AbstractMojo
+{
+ /**
+ * @parameter expression="${project}"
+ */
+ private MavenProject project;
+
+ /**
+ * @parameter expression="${executedProject}"
+ */
+ private MavenProject executedProject;
+
+ public void execute()
+ throws MojoExecutionException
+ {
+ if ( !executedProject.getBuild().getFinalName().equals( "coreitified"
) )
+ {
+ throw new MojoExecutionException( "Unexpected result, final name
of executed project is " + executedProject.getBuild().getFinalName() );
+ }
+
+ if ( project.getBuild().getFinalName().equals( "coreitified" ) )
+ {
+ throw new MojoExecutionException( "forked project was polluted" );
+ }
+ }
+}
Propchange:
maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItForkerMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItForkerMojo.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified:
maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java?rev=191476&r1=191475&r2=191476&view=diff
==============================================================================
---
maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
(original)
+++
maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
Mon Jun 20 07:42:56 2005
@@ -18,6 +18,7 @@
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
import java.io.IOException;
import java.io.File;
@@ -35,6 +36,11 @@
extends AbstractMojo
{
/**
+ * @parameter expression="${project}"
+ */
+ private MavenProject project;
+
+ /**
* @parameter expression="${project.build.directory}"
* @required
*/
@@ -86,6 +92,8 @@
{
touch( new File( outputDirectory ), goalItem );
}
+
+ project.getBuild().setFinalName( "coreitified" );
}
private static void touch( File dir, String file )
Added:
maven/components/trunk/maven-core-it-plugin/src/main/resources/META-INF/maven/lifecycle.xml
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it-plugin/src/main/resources/META-INF/maven/lifecycle.xml?rev=191476&view=auto
==============================================================================
---
maven/components/trunk/maven-core-it-plugin/src/main/resources/META-INF/maven/lifecycle.xml
(added)
+++
maven/components/trunk/maven-core-it-plugin/src/main/resources/META-INF/maven/lifecycle.xml
Mon Jun 20 07:42:56 2005
@@ -0,0 +1,28 @@
+<lifecycles>
+ <lifecycle>
+ <id>foo</id>
+ <phases>
+ <phase>
+ <id>generate-sources</id>
+ <executions>
+ <execution>
+ <configuration>
+
<outputDirectory>${project.build.directory}/forked</outputDirectory>
+ </configuration>
+ <goals>
+ <goal>touch</goal>
+ </goals>
+ </execution>
+ <execution>
+ <configuration>
+
<outputDirectory>${project.build.directory}/forked2</outputDirectory>
+ </configuration>
+ <goals>
+ <goal>touch</goal>
+ </goals>
+ </execution>
+ </executions>
+ </phase>
+ </phases>
+ </lifecycle>
+</lifecycles>
Propchange:
maven/components/trunk/maven-core-it-plugin/src/main/resources/META-INF/maven/lifecycle.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/components/trunk/maven-core-it-plugin/src/main/resources/META-INF/maven/lifecycle.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/components/trunk/maven-core-it/README.txt
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/README.txt?rev=191476&r1=191475&r2=191476&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/README.txt (original)
+++ maven/components/trunk/maven-core-it/README.txt Mon Jun 20 07:42:56 2005
@@ -83,6 +83,7 @@
it0026: Test merging of global- and user-level settings.xml files.
+it0027: Test @execute with a custom lifecycle, including configuration
-------------------------------------------------------------------------------
- generated sources
Modified: maven/components/trunk/maven-core-it/integration-tests.txt
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/integration-tests.txt?rev=191476&r1=191475&r2=191476&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/integration-tests.txt (original)
+++ maven/components/trunk/maven-core-it/integration-tests.txt Mon Jun 20
07:42:56 2005
@@ -1,27 +1,28 @@
-it0000
-it0001
-it0002
-it0003
-it0004
-it0005
-it0006
-it0007
-it0008
-it0009
-it0010
-it0011
-it0012
-it0013
-it0014
-it0015
-it0016
-it0017
-it0018
-it0019
-it0020
-it0021
-it0022
-it0023
-it0024
-it0025
+it0027
it0026
+it0025
+it0024
+it0023
+it0022
+it0021
+it0020
+it0019
+it0018
+it0017
+it0016
+it0015
+it0014
+it0013
+it0012
+it0011
+it0010
+it0009
+it0008
+it0007
+it0006
+it0005
+it0004
+it0003
+it0002
+it0001
+it0000
Propchange: maven/components/trunk/maven-core-it/it0027/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jun 20 07:42:56 2005
@@ -0,0 +1,2 @@
+target
+log.txt
Added: maven/components/trunk/maven-core-it/it0027/expected-results.txt
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0027/expected-results.txt?rev=191476&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0027/expected-results.txt (added)
+++ maven/components/trunk/maven-core-it/it0027/expected-results.txt Mon Jun 20
07:42:56 2005
@@ -0,0 +1,2 @@
+target/forked/touch.txt
+target/forked2/touch.txt
Propchange: maven/components/trunk/maven-core-it/it0027/expected-results.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core-it/it0027/expected-results.txt
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/trunk/maven-core-it/it0027/goals.txt
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0027/goals.txt?rev=191476&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0027/goals.txt (added)
+++ maven/components/trunk/maven-core-it/it0027/goals.txt Mon Jun 20 07:42:56
2005
@@ -0,0 +1 @@
+core-it:fork
Propchange: maven/components/trunk/maven-core-it/it0027/goals.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core-it/it0027/goals.txt
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/trunk/maven-core-it/it0027/pom.xml
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0027/pom.xml?rev=191476&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0027/pom.xml (added)
+++ maven/components/trunk/maven-core-it/it0027/pom.xml Mon Jun 20 07:42:56 2005
@@ -0,0 +1,16 @@
+<model>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core-it0027</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-core-it-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </plugin>
+ </plugins>
+ </build>
+</model>
Propchange: maven/components/trunk/maven-core-it/it0027/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core-it/it0027/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=191476&r1=191475&r2=191476&view=diff
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
Mon Jun 20 07:42:56 2005
@@ -32,13 +32,19 @@
import org.apache.maven.plugin.PluginNotFoundException;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.plugin.lifecycle.Execution;
+import org.apache.maven.plugin.lifecycle.Lifecycle;
+import org.apache.maven.plugin.lifecycle.Phase;
import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.injection.ModelDefaultsInjector;
import org.apache.maven.settings.Settings;
import
org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -152,11 +158,10 @@
MojoExecution mojoExecution = (MojoExecution) i.next();
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
- String executePhase = mojoDescriptor.getExecutePhase();
- if ( executePhase != null )
+ if ( mojoDescriptor.getExecutePhase() != null )
{
- forkLifecycle( executePhase,
mojoDescriptor.getExecuteLifecycle(), session, project );
+ forkLifecycle( mojoDescriptor, session, project );
}
try
@@ -170,20 +175,57 @@
}
}
- private void forkLifecycle( String task, String executeLifecycle,
MavenSession session,
- MavenProject project )
+ private void forkLifecycle( MojoDescriptor mojoDescriptor, MavenSession
session, MavenProject project )
throws LifecycleExecutionException, MojoExecutionException,
ArtifactResolutionException
{
+ String task = mojoDescriptor.getExecutePhase();
+
// Create new lifecycle
Map lifecycleMappings = constructLifecycleMappings( session, task,
project );
+ String executeLifecycle = mojoDescriptor.getExecuteLifecycle();
if ( executeLifecycle != null )
{
- // TODO: overlay new lifecycle
+ Lifecycle lifecycleOverlay;
+ try
+ {
+ lifecycleOverlay =
mojoDescriptor.getPluginDescriptor().getLifecycleMapping( executeLifecycle );
+ }
+ catch ( IOException e )
+ {
+ throw new LifecycleExecutionException( "Unable to read
lifecycle mapping file", e );
+ }
+ catch ( XmlPullParserException e )
+ {
+ throw new LifecycleExecutionException( "Unable to parse
lifecycle mapping file", e );
+ }
+
+ if ( lifecycleOverlay == null )
+ {
+ throw new LifecycleExecutionException( "Lifecycle '" +
executeLifecycle + "' not found in plugin" );
+ }
+
+ for ( Iterator i = lifecycleOverlay.getPhases().iterator();
i.hasNext(); )
+ {
+ Phase phase = (Phase) i.next();
+ for ( Iterator j = phase.getExecutions().iterator();
j.hasNext(); )
+ {
+ Execution e = (Execution) j.next();
+
+ for ( Iterator k = e.getGoals().iterator(); k.hasNext(); )
+ {
+ String goal = (String) k.next();
+ MojoDescriptor desc =
mojoDescriptor.getPluginDescriptor().getMojo( goal );
+ MojoExecution mojoExecution = new MojoExecution( desc,
(Xpp3Dom) e.getConfiguration() );
+ addToLifecycleMappings( lifecycleMappings,
phase.getId(), mojoExecution, session.getSettings() );
+ }
+ }
+ }
}
- // TODO: clone project
- executeGoalWithLifecycle( task, session, lifecycleMappings, project );
+ MavenProject executionProject = new MavenProject( project );
+ executeGoalWithLifecycle( task, session, lifecycleMappings,
executionProject );
+ project.setExecutionProject( executionProject );
}
private Map constructLifecycleMappings( MavenSession session, String
selectedPhase, MavenProject project )
@@ -325,7 +367,6 @@
*/
private void bindGoalMapToLifecycle( PluginDescriptor pluginDescriptor,
Map goalMap, Map phaseMap,
Settings settings )
- throws LifecycleExecutionException
{
for ( Iterator i = pluginDescriptor.getMojos().iterator();
i.hasNext(); )
{
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=191476&r1=191475&r2=191476&view=diff
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
Mon Jun 20 07:42:56 2005
@@ -288,13 +288,15 @@
files.add( artifact.getFile() );
}
- container.createChildContainer( pluginKey, files,
Collections.EMPTY_MAP,
- Collections.singletonList( this )
);
+ PlexusContainer child = container.createChildContainer( pluginKey,
files, Collections.EMPTY_MAP,
+
Collections.singletonList( this ) );
- // this plugin's descriptor should have been discovered by now, so
we should be able to circle
- // around and set the artifacts.
+ // this plugin's descriptor should have been discovered in the
child creation, so we should be able to
+ // circle around and set the artifacts and class realm
PluginDescriptor addedPlugin = (PluginDescriptor)
pluginDescriptors.get( pluginKey );
+ addedPlugin.setClassRealm( child.getContainerRealm() );
+
ArtifactFilter distroProvidedFilter = new InversionArtifactFilter(
artifactFilter );
ArtifactResolutionResult distroProvidedResult =
artifactResolver.resolveTransitively( Collections
@@ -402,6 +404,10 @@
Xpp3Dom dom = project.getGoalConfiguration( groupId, artifactId,
executionId, goalId );
Xpp3Dom reportDom = project.getReportConfiguration( groupId,
artifactId, executionId );
dom = Xpp3Dom.mergeXpp3Dom( dom, reportDom );
+ if ( mojoExecution.getConfiguration() != null )
+ {
+ dom = Xpp3Dom.mergeXpp3Dom( dom,
mojoExecution.getConfiguration() );
+ }
plugin = getConfiguredMojo( pluginContainer, mojoDescriptor,
session, dom, project );
}
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java?rev=191476&r1=191475&r2=191476&view=diff
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java
Mon Jun 20 07:42:56 2005
@@ -17,6 +17,7 @@
*/
import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
/**
* Describes a single mojo invocation.
@@ -30,16 +31,27 @@
private final MojoDescriptor mojoDescriptor;
+ private final Xpp3Dom configuration;
+
public MojoExecution( MojoDescriptor mojoDescriptor )
{
this.mojoDescriptor = mojoDescriptor;
this.executionId = null;
+ this.configuration = null;
}
public MojoExecution( MojoDescriptor mojoDescriptor, String executionId )
{
this.mojoDescriptor = mojoDescriptor;
this.executionId = executionId;
+ this.configuration = null;
+ }
+
+ public MojoExecution( MojoDescriptor mojoDescriptor, Xpp3Dom configuration
)
+ {
+ this.mojoDescriptor = mojoDescriptor;
+ this.configuration = configuration;
+ this.executionId = null;
}
public String getExecutionId()
@@ -50,5 +62,10 @@
public MojoDescriptor getMojoDescriptor()
{
return mojoDescriptor;
+ }
+
+ public Xpp3Dom getConfiguration()
+ {
+ return configuration;
}
}
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java?rev=191476&r1=191475&r2=191476&view=diff
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
Mon Jun 20 07:42:56 2005
@@ -20,6 +20,7 @@
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.path.PathTranslator;
+import org.apache.maven.model.Model;
import
org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import
org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
import org.codehaus.plexus.logging.Logger;
@@ -96,6 +97,10 @@
else if ( expression.equals( "project" ) )
{
value = project;
+ }
+ else if ( expression.equals( "executedProject" ) )
+ {
+ value = project.getExecutionProject();
}
else if ( expression.startsWith( "project" ) )
{
Modified:
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java?rev=191476&r1=191475&r2=191476&view=diff
==============================================================================
---
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
(original)
+++
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
Mon Jun 20 07:42:56 2005
@@ -17,9 +17,21 @@
*/
import org.codehaus.plexus.component.repository.ComponentSetDescriptor;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.codehaus.classworlds.ClassRealm;
+import org.apache.maven.plugin.lifecycle.LifecycleConfiguration;
+import org.apache.maven.plugin.lifecycle.Lifecycle;
+import org.apache.maven.plugin.lifecycle.io.xpp3.LifecycleMappingsXpp3Reader;
import java.util.List;
import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.FileNotFoundException;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
@@ -44,6 +56,10 @@
private List artifacts;
+ private Map lifecycleMappings;
+
+ private ClassRealm classRealm;
+
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
@@ -237,5 +253,47 @@
}
}
return mojoDescriptor;
+ }
+
+ public Lifecycle getLifecycleMapping( String lifecycle )
+ throws IOException, XmlPullParserException
+ {
+ if ( lifecycleMappings == null )
+ {
+ LifecycleMappingsXpp3Reader reader = new
LifecycleMappingsXpp3Reader();
+ InputStreamReader r = null;
+ LifecycleConfiguration config;
+
+ try
+ {
+ InputStream resourceAsStream = classRealm.getResourceAsStream(
"/META-INF/maven/lifecycle.xml" );
+ if ( resourceAsStream == null )
+ {
+ throw new FileNotFoundException( "Unable to find
/META-INF/maven/lifecycle.xml in the plugin" );
+ }
+ r = new InputStreamReader( resourceAsStream );
+ config = reader.read( r );
+ }
+ finally
+ {
+ IOUtil.close( r );
+ }
+
+ Map map = new HashMap();
+
+ for ( Iterator i = config.getLifecycles().iterator(); i.hasNext();
)
+ {
+ Lifecycle l = (Lifecycle) i.next();
+ map.put( l.getId(), l );
+ }
+
+ lifecycleMappings = map;
+ }
+ return (Lifecycle) lifecycleMappings.get( lifecycle );
+ }
+
+ public void setClassRealm( ClassRealm classRealm )
+ {
+ this.classRealm = classRealm;
}
}
Modified:
maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java?rev=191476&r1=191475&r2=191476&view=diff
==============================================================================
---
maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java
(original)
+++
maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java
Mon Jun 20 07:42:56 2005
@@ -28,7 +28,7 @@
*
* @goal eclipse
* @requiresDependencyResolution test
- * @executePhase generate-sources
+ * @execute phase="generate-sources"
*
* @author <a href="mailto:[EMAIL PROTECTED]">Trygve Laugstøl</a>
* @version $Id$
@@ -47,6 +47,14 @@
private MavenProject project;
/**
+ * The project whose project files to create.
+ *
+ * @parameter expression="${executedProject}"
+ * @required
+ */
+ private MavenProject executedProject;
+
+ /**
* @parameter expression="${localRepository}"
* @required
* @readonly
@@ -86,7 +94,7 @@
{
eclipseWriter.setLocalRepositoryFile( new File (
localRepository.getBasedir() ) );
- eclipseWriter.write( project );
+ eclipseWriter.write( project, executedProject );
}
catch ( EclipsePluginException e )
{
Modified:
maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseWriter.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseWriter.java?rev=191476&r1=191475&r2=191476&view=diff
==============================================================================
---
maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseWriter.java
(original)
+++
maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseWriter.java
Mon Jun 20 07:42:56 2005
@@ -46,7 +46,7 @@
this.localRepository = localRepository;
}
- public void write( MavenProject project )
+ public void write( MavenProject project, MavenProject executedProject )
throws EclipsePluginException
{
File basedir = project.getFile().getParentFile();
@@ -61,7 +61,7 @@
writeEclipseProject( basedir, project, map );
- writeEclipseClasspath( basedir, project, map );
+ writeEclipseClasspath( basedir, project, executedProject, map );
System.out.println( "Wrote Eclipse project for " +
project.getArtifactId() + " to " + basedir.getAbsolutePath() );
}
@@ -155,7 +155,7 @@
// .classpath
// ----------------------------------------------------------------------
- protected void writeEclipseClasspath( File basedir, MavenProject project,
Map map )
+ protected void writeEclipseClasspath( File basedir, MavenProject project,
MavenProject executedProject, Map map )
throws EclipsePluginException
{
FileWriter w;
@@ -178,7 +178,7 @@
//
----------------------------------------------------------------------
addSourceRoots( writer, project.getBasedir(),
- project.getCompileSourceRoots(),
+ executedProject.getCompileSourceRoots(),
null );
addResources( writer, project.getBasedir(),
@@ -190,7 +190,7 @@
//
----------------------------------------------------------------------
addSourceRoots( writer, project.getBasedir(),
- project.getTestCompileSourceRoots(),
+ executedProject.getTestCompileSourceRoots(),
project.getBuild().getTestOutputDirectory() );
addResources( writer, project.getBasedir(),
Modified:
maven/components/trunk/maven-plugins/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaMojo.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaMojo.java?rev=191476&r1=191475&r2=191476&view=diff
==============================================================================
---
maven/components/trunk/maven-plugins/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaMojo.java
(original)
+++
maven/components/trunk/maven-plugins/maven-idea-plugin/src/main/java/org/apache/maven/plugin/idea/IdeaMojo.java
Mon Jun 20 07:42:56 2005
@@ -37,10 +37,11 @@
import java.util.Iterator;
/**
+ * Goal for generating IDEA files from a POM.
+ *
* @goal idea
- * @executePhase generate-sources
+ * @execute phase="generate-sources"
* @requiresDependencyResolution test
- * @description Goal for generating IDEA files from a POM
* @todo use dom4j or something. Xpp3Dom can't cope properly with entities and
so on
*/
public class IdeaMojo
@@ -53,6 +54,13 @@
*/
private MavenProject project;
+ /**
+ * @parameter expression="${executedProject}"
+ * @required
+ * @readonly
+ */
+ private MavenProject executedProject;
+
public void execute()
throws MojoExecutionException
{
@@ -203,12 +211,12 @@
removeOldElements( content, "sourceFolder" );
- for ( Iterator i = project.getCompileSourceRoots().iterator();
i.hasNext(); )
+ for ( Iterator i =
executedProject.getCompileSourceRoots().iterator(); i.hasNext(); )
{
String directory = (String) i.next();
addSourceFolder( content, directory, false );
}
- for ( Iterator i = project.getTestCompileSourceRoots().iterator();
i.hasNext(); )
+ for ( Iterator i =
executedProject.getTestCompileSourceRoots().iterator(); i.hasNext(); )
{
String directory = (String) i.next();
addSourceFolder( content, directory, true );
Modified:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java?rev=191476&r1=191475&r2=191476&view=diff
==============================================================================
---
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
(original)
+++
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
Mon Jun 20 07:42:56 2005
@@ -89,11 +89,53 @@
private List attachedArtifacts;
+ private MavenProject executionProject;
+
+ private List compileSourceRoots = new ArrayList();
+
+ private List testCompileSourceRoots = new ArrayList();
+
+ private List scriptSourceRoots = new ArrayList();
+
+ private List pluginArtifactRepositories;
+
+ private ArtifactRepository distMgmtArtifactRepository;
+
+ private List activeProfiles = new ArrayList();
+
public MavenProject( Model model )
{
this.model = model;
}
+ public MavenProject( MavenProject project )
+ {
+ // disown the parent
+
+ // copy fields
+ this.file = project.file;
+
+ // don't need a deep copy, they don't get modified or added/removed
to/from - but make them unmodifiable to be sure!
+ this.artifacts = Collections.unmodifiableSet( project.artifacts );
+ this.pluginArtifacts = Collections.unmodifiableSet(
project.pluginArtifacts );
+ this.remoteArtifactRepositories = Collections.unmodifiableList(
project.remoteArtifactRepositories );
+ this.pluginArtifactRepositories = Collections.unmodifiableList(
project.pluginArtifactRepositories );
+ this.attachedArtifacts = Collections.unmodifiableList(
project.getAttachedArtifacts() );
+ this.collectedProjects = Collections.unmodifiableList(
project.collectedProjects );
+ this.activeProfiles = Collections.unmodifiableList(
project.activeProfiles );
+
+ // no need for execution project
+
+ // clone source roots
+ this.compileSourceRoots = new ArrayList( project.compileSourceRoots );
+ this.testCompileSourceRoots = new ArrayList(
project.testCompileSourceRoots );
+ this.scriptSourceRoots = new ArrayList( project.scriptSourceRoots );
+
+ this.profileProperties = new Properties( project.profileProperties );
+
+ this.model = ModelUtils.cloneModel( project.model );
+ }
+
// ----------------------------------------------------------------------
// Accessors
// ----------------------------------------------------------------------
@@ -170,18 +212,6 @@
// Test and compile sourceroots.
// ----------------------------------------------------------------------
- private List compileSourceRoots = new ArrayList();
-
- private List testCompileSourceRoots = new ArrayList();
-
- private List scriptSourceRoots = new ArrayList();
-
- private List pluginArtifactRepositories;
-
- private ArtifactRepository distMgmtArtifactRepository;
-
- private List activeProfiles = new ArrayList();
-
public void addCompileSourceRoot( String path )
{
if ( path != null )
@@ -992,5 +1022,15 @@
}
return dom;
+ }
+
+ public MavenProject getExecutionProject()
+ {
+ return executionProject;
+ }
+
+ public void setExecutionProject( MavenProject executionProject )
+ {
+ this.executionProject = executionProject;
}
}
Modified:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java?rev=191476&r1=191475&r2=191476&view=diff
==============================================================================
---
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
(original)
+++
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
Mon Jun 20 07:42:56 2005
@@ -1,17 +1,5 @@
package org.apache.maven.project;
-import org.apache.maven.model.Goal;
-import org.apache.maven.model.Plugin;
-import org.apache.maven.model.PluginContainer;
-import org.apache.maven.model.PluginExecution;
-import org.codehaus.plexus.util.xml.Xpp3Dom;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
@@ -28,6 +16,21 @@
* limitations under the License.
*/
+import org.apache.maven.model.Goal;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.model.PluginContainer;
+import org.apache.maven.model.PluginExecution;
+import org.apache.maven.model.Model;
+import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
+import org.apache.maven.project.inheritance.DefaultModelInheritanceAssembler;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
public final class ModelUtils
{
public static void mergePluginLists( PluginContainer childContainer,
PluginContainer parentContainer,
@@ -256,5 +259,15 @@
childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration,
parentConfiguration );
child.setConfiguration( childConfiguration );
+ }
+
+ static Model cloneModel( Model model )
+ {
+ // TODO: would be nice for the modello:java code to generate this as a
copy constructor
+ Model newModel = new Model();
+ ModelInheritanceAssembler assembler = new
DefaultModelInheritanceAssembler();
+ assembler.assembleModelInheritance( newModel, model );
+ newModel.setVersion( model.getVersion() );
+ return newModel;
}
}
Modified: maven/components/trunk/maven-site/src/site/apt/lifecycle.apt
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-site/src/site/apt/lifecycle.apt?rev=191476&r1=191475&r2=191476&view=diff
==============================================================================
--- maven/components/trunk/maven-site/src/site/apt/lifecycle.apt (original)
+++ maven/components/trunk/maven-site/src/site/apt/lifecycle.apt Mon Jun 20
07:42:56 2005
@@ -345,7 +345,7 @@
<debug>true</debug>
</configuration>
<goals>
- <goal>clover:compiler</goal>
+ <goal>compiler</goal>
</goals>
</execution>
</executions>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]