mirror of https://github.com/apache/maven.git
PR: MNG-1101
Fixed dependency-exclusion propagation to the release-pom.xml, and changed the pom-file handling for release:perform to allow non-standard POM filenames, and to prompt in the case where the POM being used is the release-pom.xml. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@329946 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f3a9a7f258
commit
3889f9ac96
|
@ -13,6 +13,12 @@
|
|||
<groupId>org.apache.maven.it2002</groupId>
|
||||
<artifactId>project-sub1</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-artifact-manager</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
|
|
|
@ -22,13 +22,14 @@ cd target/project.checkout
|
|||
|
||||
cat pom.xml | sed "s#\${project.file.parentFile.parentFile}#$dir#g" >tmp
|
||||
mv tmp pom.xml
|
||||
|
||||
svn ci -m 'update scm' pom.xml
|
||||
|
||||
rm -Rf target
|
||||
|
||||
m2 -e release:prepare -Denv=test -B -Dtag=test-tag
|
||||
mvn -DgenerateReleasePoms=true -e release:prepare -Denv=test -B -Dtag=test-tag
|
||||
ret=$?; if [ $ret != 0 ]; then exit $ret; fi
|
||||
|
||||
m2 -e release:perform -Denv=test
|
||||
mvn -DreleasePom=release-pom.xml -e release:perform -Denv=test
|
||||
ret=$?; if [ $ret != 0 ]; then exit $ret; fi
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.apache.maven.plugin.MojoExecutionException;
|
|||
import org.apache.maven.plugins.release.helpers.ReleaseProgressTracker;
|
||||
import org.apache.maven.plugins.release.helpers.ScmHelper;
|
||||
import org.apache.maven.scm.manager.ScmManager;
|
||||
import org.codehaus.plexus.components.interactivity.InputHandler;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jdcasey@apache.org">John Casey</a>
|
||||
|
@ -35,10 +36,20 @@ public abstract class AbstractReleaseMojo
|
|||
*/
|
||||
private ScmManager scmManager;
|
||||
|
||||
/**
|
||||
* @component
|
||||
*/
|
||||
private InputHandler inputHandler;
|
||||
|
||||
private ScmHelper scmHelper;
|
||||
|
||||
protected abstract ReleaseProgressTracker getReleaseProgress()
|
||||
throws MojoExecutionException;
|
||||
|
||||
protected InputHandler getInputHandler()
|
||||
{
|
||||
return inputHandler;
|
||||
}
|
||||
|
||||
protected ScmHelper getScm( String directory )
|
||||
throws MojoExecutionException
|
||||
|
|
|
@ -16,11 +16,13 @@ package org.apache.maven.plugins.release;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.Maven;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugins.release.helpers.ReleaseProgressTracker;
|
||||
import org.apache.maven.plugins.release.helpers.ScmHelper;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.codehaus.plexus.util.cli.CommandLineException;
|
||||
import org.codehaus.plexus.util.cli.CommandLineUtils;
|
||||
import org.codehaus.plexus.util.cli.Commandline;
|
||||
|
@ -74,6 +76,11 @@ public class PerformReleaseMojo
|
|||
* @readonly
|
||||
*/
|
||||
private boolean interactive;
|
||||
|
||||
/**
|
||||
* @parameter expression="${releasePom}"
|
||||
*/
|
||||
private String releasePom;
|
||||
|
||||
private ReleaseProgressTracker releaseProgress;
|
||||
|
||||
|
@ -126,6 +133,50 @@ public class PerformReleaseMojo
|
|||
cl.createArgument().setLine( "--batch-mode" );
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( releasePom ) )
|
||||
{
|
||||
File pomFile = project.getFile();
|
||||
|
||||
releasePom = pomFile.getName();
|
||||
}
|
||||
|
||||
if ( releasePom.equals( Maven.RELEASE_POMv4 ) && interactive )
|
||||
{
|
||||
StringBuffer warning = new StringBuffer();
|
||||
warning.append( "\n*******************************************************************************\n" );
|
||||
warning.append( "\nYou have chosen to use the fully resolved release-POM to deploy this project." );
|
||||
warning.append( "\n" );
|
||||
warning.append( "\nNOTE: Deploying artifacts using the fully resolved release-POM " );
|
||||
warning.append( "\nwill result in loss of any version ranges specified for your");
|
||||
warning.append( "\nproject's dependencies." );
|
||||
warning.append( "\n" );
|
||||
warning.append( "\nAre you sure you want to do this?" );
|
||||
warning.append( "\n" );
|
||||
warning.append( "\n*******************************************************************************\n" );
|
||||
|
||||
getLog().warn( warning );
|
||||
|
||||
getLog().info( "Enter the POM filename to use for deployment: [" + releasePom + "] " );
|
||||
|
||||
try
|
||||
{
|
||||
String input = getInputHandler().readLine();
|
||||
|
||||
if ( !StringUtils.isEmpty( input ) )
|
||||
{
|
||||
releasePom = input;
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new MojoExecutionException( "An error has occurred while reading the pom file location.", e );
|
||||
}
|
||||
}
|
||||
|
||||
getLog().info( "Releasing project based on POM: " + releasePom + " in working directory: " + workingDirectory );
|
||||
|
||||
cl.createArgument().setLine( "-f " + releasePom );
|
||||
|
||||
List profiles = project.getActiveProfiles();
|
||||
|
||||
if ( profiles != null && !profiles.isEmpty() )
|
||||
|
|
|
@ -48,7 +48,6 @@ import org.apache.maven.project.path.PathTranslator;
|
|||
import org.apache.maven.scm.ScmException;
|
||||
import org.apache.maven.scm.ScmFile;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.codehaus.plexus.components.interactivity.InputHandler;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
|
@ -58,6 +57,7 @@ import java.io.IOException;
|
|||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -66,7 +66,10 @@ import java.util.Properties;
|
|||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Prepare for a release in SCM
|
||||
* Prepare for a release in SCM.
|
||||
* <br/>
|
||||
* NOTE: This will cause the 'install' phase to be executed...if we cannot
|
||||
* at least install the project, we shouldn't start the release process.
|
||||
*
|
||||
* @author <a href="mailto:jdcasey@apache.org">John Casey</a>
|
||||
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
|
||||
|
@ -74,6 +77,7 @@ import java.util.Set;
|
|||
* @version $Id$
|
||||
* @aggregator
|
||||
* @goal prepare
|
||||
* @execute phase="install"
|
||||
* @requiresDependencyResolution test
|
||||
* @todo check how this works with version ranges
|
||||
*/
|
||||
|
@ -108,11 +112,6 @@ public class PrepareReleaseMojo
|
|||
*/
|
||||
private PluginVersionManager pluginVersionManager;
|
||||
|
||||
/**
|
||||
* @component
|
||||
*/
|
||||
private InputHandler inputHandler;
|
||||
|
||||
/**
|
||||
* @parameter expression="${localRepository}"
|
||||
* @required
|
||||
|
@ -167,7 +166,7 @@ public class PrepareReleaseMojo
|
|||
private boolean resume;
|
||||
|
||||
/**
|
||||
* @parameter default-value="false"
|
||||
* @parameter default-value="false" expression="${generateReleasePoms}"
|
||||
*/
|
||||
private boolean generateReleasePoms;
|
||||
|
||||
|
@ -477,7 +476,7 @@ public class PrepareReleaseMojo
|
|||
{
|
||||
if ( versionResolver == null )
|
||||
{
|
||||
versionResolver = new ProjectVersionResolver( getLog(), inputHandler, interactive );
|
||||
versionResolver = new ProjectVersionResolver( getLog(), getInputHandler(), interactive );
|
||||
}
|
||||
|
||||
return versionResolver;
|
||||
|
@ -894,15 +893,30 @@ public class PrepareReleaseMojo
|
|||
releaseModel.setParent( null );
|
||||
|
||||
Set artifacts = releaseProject.getArtifacts();
|
||||
|
||||
|
||||
if ( artifacts != null )
|
||||
{
|
||||
//Rewrite dependencies section
|
||||
List newdeps = new ArrayList();
|
||||
|
||||
Map oldDeps = new HashMap();
|
||||
|
||||
List deps = releaseProject.getDependencies();
|
||||
if ( deps != null )
|
||||
{
|
||||
for ( Iterator depIterator = deps.iterator(); depIterator.hasNext(); )
|
||||
{
|
||||
Dependency dep = (Dependency) depIterator.next();
|
||||
|
||||
oldDeps.put( ArtifactUtils.artifactId( dep.getGroupId(), dep.getArtifactId(), dep.getType(), dep.getVersion() ), dep );
|
||||
}
|
||||
}
|
||||
|
||||
for ( Iterator i = releaseProject.getArtifacts().iterator(); i.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) i.next();
|
||||
|
||||
String key = artifact.getId();
|
||||
|
||||
Dependency newdep = new Dependency();
|
||||
|
||||
|
@ -926,6 +940,15 @@ public class PrepareReleaseMojo
|
|||
newdep.setType( artifact.getType() );
|
||||
newdep.setScope( artifact.getScope() );
|
||||
newdep.setClassifier( artifact.getClassifier() );
|
||||
|
||||
Dependency old = (Dependency) oldDeps.get( key );
|
||||
|
||||
if ( old != null )
|
||||
{
|
||||
newdep.setSystemPath( old.getSystemPath() );
|
||||
newdep.setExclusions( old.getExclusions() );
|
||||
newdep.setOptional( old.isOptional() );
|
||||
}
|
||||
|
||||
newdeps.add( newdep );
|
||||
}
|
||||
|
@ -1350,7 +1373,7 @@ public class PrepareReleaseMojo
|
|||
{
|
||||
getLog().info( "What tag name should be used? " );
|
||||
|
||||
String inputTag = inputHandler.readLine();
|
||||
String inputTag = getInputHandler().readLine();
|
||||
|
||||
if ( !StringUtils.isEmpty( inputTag ) )
|
||||
{
|
||||
|
@ -1364,7 +1387,7 @@ public class PrepareReleaseMojo
|
|||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new MojoExecutionException( "An error is occurred in the tag process.", e );
|
||||
throw new MojoExecutionException( "An error has occurred in the tag process.", e );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue