Resolving: MNG-878, MNG-921

o Verified that plugins are added to the list in the model when invoked from the command line (878)
o Reformatted ModelUtils after the profiles-cloning addition
o Added cache-flush for the plugin map in MavenProject
o Moved dependencies for subproject/subproject2 into the parent-project POM, inside a profile
o Added activation property for this new profile into the test.sh script
o Added explicit activation inside of release:perform's m2 invocation for all profile-ids active in the release-plugin's execution.
o Added code to remove the dynamic parts of the POM from the release-pom.xml...it's not meant to be a dynamic version of a POM.



git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@290336 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-09-20 02:59:44 +00:00
parent 74de0709de
commit ec8d262f16
8 changed files with 295 additions and 270 deletions

View File

@ -53,9 +53,8 @@
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.codehaus.modello</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>modello-maven-plugin</artifactId>
<version>2.0-beta-1</version>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
@ -64,9 +63,40 @@
<plugins> <plugins>
<plugin> <plugin>
<artifactId>maven-project-info-reports-plugin</artifactId> <artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.0-alpha-1</version> <version>2.0-beta-1</version>
</plugin> </plugin>
</plugins> </plugins>
</reporting> </reporting>
<profiles>
<profile>
<id>env-test</id>
<activation>
<property>
<name>env</name>
<value>test</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0-beta-1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact-manager</artifactId>
<version>2.0-beta-1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<directory>alt-target</directory>
</build>
</profile>
</profiles>
</project> </project>

View File

@ -8,19 +8,4 @@
<artifactId>project-sub1</artifactId> <artifactId>project-sub1</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0-beta-1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact-manager</artifactId>
<version>2.0-beta-1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project> </project>

View File

@ -14,30 +14,6 @@
<artifactId>project-sub1</artifactId> <artifactId>project-sub1</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0-beta-1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact-manager</artifactId>
<version>2.0-beta-1</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<profiles>
<profile>
<id>env-test</id>
<activation>
<property>
<name>env</name>
<value>test</value>
</property>
</activation>
</profile>
</profiles>
</project> </project>

View File

@ -18,11 +18,7 @@ cd project.checkout
rm -Rf target rm -Rf target
#. ~/shell-switches/m2-debug-on m2 -e release:prepare -Denv=test
#echo "Enabling debugging options. Please attach the debugger."
export MAVEN_OPTS= m2 -e release:perform -Denv=test
m2 -e release:prepare
m2 -e release:perform

View File

@ -16,9 +16,11 @@ package org.apache.maven.plugins.release;
* limitations under the License. * limitations under the License.
*/ */
import org.apache.maven.model.Profile;
import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.release.helpers.ReleaseProgressTracker; import org.apache.maven.plugins.release.helpers.ReleaseProgressTracker;
import org.apache.maven.plugins.release.helpers.ScmHelper; import org.apache.maven.plugins.release.helpers.ScmHelper;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.cli.CommandLineException; import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline; import org.codehaus.plexus.util.cli.Commandline;
@ -26,6 +28,8 @@ import org.codehaus.plexus.util.cli.DefaultConsumer;
import org.codehaus.plexus.util.cli.StreamConsumer; import org.codehaus.plexus.util.cli.StreamConsumer;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator;
import java.util.List;
/** /**
* Perform a release from SCM * Perform a release from SCM
@ -56,6 +60,13 @@ public class PerformReleaseMojo
*/ */
protected String workingDirectory; protected String workingDirectory;
/**
* @parameter expression="${project}"
* @required
* @readonly
*/
protected MavenProject project;
private ReleaseProgressTracker releaseProgress; private ReleaseProgressTracker releaseProgress;
protected void executeTask() protected void executeTask()
@ -104,6 +115,26 @@ public class PerformReleaseMojo
cl.createArgument().setLine( "--batch-mode" ); cl.createArgument().setLine( "--batch-mode" );
List profiles = project.getActiveProfiles();
if ( profiles != null && !profiles.isEmpty() )
{
StringBuffer buffer = new StringBuffer();
buffer.append( "-P " );
for ( Iterator it = profiles.iterator(); it.hasNext(); )
{
Profile profile = (Profile) it.next();
buffer.append( profile.getId() ).append( "," );
}
buffer.setLength( buffer.length() - 1 );
cl.createArgument().setLine( buffer.toString() );
}
StreamConsumer consumer = new DefaultConsumer(); StreamConsumer consumer = new DefaultConsumer();
try try

View File

@ -836,6 +836,12 @@ public class PrepareReleaseMojo
Model releaseModel = releaseProject.getModel(); Model releaseModel = releaseProject.getModel();
fixNullValueInModel( releaseModel, project.getModel() ); fixNullValueInModel( releaseModel, project.getModel() );
// the release POM should reflect bits of these which were injected at build time...
// we don't need these polluting the POM.
releaseModel.setProfiles( Collections.EMPTY_LIST );
releaseModel.setDependencyManagement( null );
releaseModel.getBuild().setPluginManagement( null );
String projectVersion = releaseModel.getVersion(); String projectVersion = releaseModel.getVersion();
if ( ArtifactUtils.isSnapshot( projectVersion ) ) if ( ArtifactUtils.isSnapshot( projectVersion ) )
{ {

View File

@ -1129,6 +1129,7 @@ public class MavenProject
if ( !build.getPluginsAsMap().containsKey( plugin.getKey() ) ) if ( !build.getPluginsAsMap().containsKey( plugin.getKey() ) )
{ {
build.addPlugin( plugin ); build.addPlugin( plugin );
build.flushPluginMap();
} }
} }

View File

@ -19,7 +19,6 @@ package org.apache.maven.project;
import org.apache.maven.model.Activation; import org.apache.maven.model.Activation;
import org.apache.maven.model.ActivationFile; import org.apache.maven.model.ActivationFile;
import org.apache.maven.model.ActivationProperty; import org.apache.maven.model.ActivationProperty;
import org.apache.maven.model.Build;
import org.apache.maven.model.BuildBase; import org.apache.maven.model.BuildBase;
import org.apache.maven.model.Dependency; import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.DependencyManagement;
@ -78,8 +77,8 @@ public final class ModelUtils
String parentInherited = parentPlugin.getInherited(); String parentInherited = parentPlugin.getInherited();
if ( !handleAsInheritance || parentInherited == null || if ( !handleAsInheritance || parentInherited == null
Boolean.valueOf( parentInherited ).booleanValue() ) || Boolean.valueOf( parentInherited ).booleanValue() )
{ {
Plugin assembledPlugin = parentPlugin; Plugin assembledPlugin = parentPlugin;
@ -140,8 +139,8 @@ public final class ModelUtils
String parentInherited = parentPlugin.getInherited(); String parentInherited = parentPlugin.getInherited();
if ( !handleAsInheritance || parentInherited == null || if ( !handleAsInheritance || parentInherited == null
Boolean.valueOf( parentInherited ).booleanValue() ) || Boolean.valueOf( parentInherited ).booleanValue() )
{ {
ReportPlugin assembledPlugin = parentPlugin; ReportPlugin assembledPlugin = parentPlugin;
@ -528,7 +527,8 @@ public final class ModelUtils
newProfile.setDependencyManagement( newDM ); newProfile.setDependencyManagement( newDM );
} }
newProfile.setDistributionManagement( cloneProfileDistributionManagement( profile.getDistributionManagement() ) ); newProfile.setDistributionManagement( cloneProfileDistributionManagement( profile
.getDistributionManagement() ) );
List modules = profile.getModules(); List modules = profile.getModules();