mirror of https://github.com/apache/maven.git
o making the maven.username parameter required.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@171238 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4ab9ef149d
commit
e801e4af69
|
@ -48,7 +48,8 @@ public abstract class AbstractReleaseMojo
|
||||||
private String urlScm;
|
private String urlScm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @parameter expression="${username}"
|
* @parameter expression="${maven.username}"
|
||||||
|
* @required
|
||||||
*/
|
*/
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
|
@ -101,13 +102,21 @@ public abstract class AbstractReleaseMojo
|
||||||
protected ScmBean getScm()
|
protected ScmBean getScm()
|
||||||
{
|
{
|
||||||
ScmBean scm = new ScmBean();
|
ScmBean scm = new ScmBean();
|
||||||
|
|
||||||
scm.setScmManager( scmManager );
|
scm.setScmManager( scmManager );
|
||||||
|
|
||||||
scm.setUrl( urlScm );
|
scm.setUrl( urlScm );
|
||||||
|
|
||||||
scm.setTag( tag );
|
scm.setTag( tag );
|
||||||
|
|
||||||
scm.setTagBase( tagBase );
|
scm.setTagBase( tagBase );
|
||||||
|
|
||||||
scm.setUsername( username );
|
scm.setUsername( username );
|
||||||
|
|
||||||
scm.setPassword( password );
|
scm.setPassword( password );
|
||||||
|
|
||||||
scm.setWorkingDirectory( workingDirectory );
|
scm.setWorkingDirectory( workingDirectory );
|
||||||
|
|
||||||
return scm;
|
return scm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class PrepareReleaseMojo
|
||||||
protected void executeTask()
|
protected void executeTask()
|
||||||
throws MojoExecutionException
|
throws MojoExecutionException
|
||||||
{
|
{
|
||||||
//checkStatus();
|
checkStatus();
|
||||||
|
|
||||||
checkDependencies();
|
checkDependencies();
|
||||||
|
|
||||||
|
@ -131,8 +131,6 @@ public class PrepareReleaseMojo
|
||||||
|
|
||||||
while ( currentProject.hasParent() )
|
while ( currentProject.hasParent() )
|
||||||
{
|
{
|
||||||
System.out.println( "currentProject = " + currentProject );
|
|
||||||
|
|
||||||
Artifact parentArtifact = currentProject.getParentArtifact();
|
Artifact parentArtifact = currentProject.getParentArtifact();
|
||||||
|
|
||||||
if ( isSnapshot( parentArtifact.getVersion() ) )
|
if ( isSnapshot( parentArtifact.getVersion() ) )
|
||||||
|
@ -203,6 +201,7 @@ public class PrepareReleaseMojo
|
||||||
throws MojoExecutionException
|
throws MojoExecutionException
|
||||||
{
|
{
|
||||||
Model model = project.getModel();
|
Model model = project.getModel();
|
||||||
|
|
||||||
if ( !isSnapshot( model.getVersion() ) )
|
if ( !isSnapshot( model.getVersion() ) )
|
||||||
{
|
{
|
||||||
throw new MojoExecutionException( "This project isn't a snapshot (" + model.getVersion() + ")." );
|
throw new MojoExecutionException( "This project isn't a snapshot (" + model.getVersion() + ")." );
|
||||||
|
@ -210,11 +209,15 @@ public class PrepareReleaseMojo
|
||||||
|
|
||||||
//Rewrite project version
|
//Rewrite project version
|
||||||
projectVersion = model.getVersion().substring( 0, model.getVersion().length() - SNAPSHOT.length() );
|
projectVersion = model.getVersion().substring( 0, model.getVersion().length() - SNAPSHOT.length() );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
getLog().info( "What is the new version? [" + projectVersion + "]" );
|
getLog().info( "What is the new version? [" + projectVersion + "]" );
|
||||||
|
|
||||||
InputHandler handler = (InputHandler) getContainer().lookup( InputHandler.ROLE );
|
InputHandler handler = (InputHandler) getContainer().lookup( InputHandler.ROLE );
|
||||||
|
|
||||||
String inputVersion = handler.readLine();
|
String inputVersion = handler.readLine();
|
||||||
|
|
||||||
if ( !StringUtils.isEmpty( inputVersion ) )
|
if ( !StringUtils.isEmpty( inputVersion ) )
|
||||||
{
|
{
|
||||||
projectVersion = inputVersion;
|
projectVersion = inputVersion;
|
||||||
|
@ -224,6 +227,7 @@ public class PrepareReleaseMojo
|
||||||
{
|
{
|
||||||
throw new MojoExecutionException( "Can't read user input.", e );
|
throw new MojoExecutionException( "Can't read user input.", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
model.setVersion( projectVersion );
|
model.setVersion( projectVersion );
|
||||||
|
|
||||||
//Rewrite parent version
|
//Rewrite parent version
|
||||||
|
@ -274,15 +278,24 @@ public class PrepareReleaseMojo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: should probably use a regex or something as most users will probably
|
||||||
|
// not want their comments removed and indenting changed. I don't think it's a big
|
||||||
|
// deal but lots of people complain.
|
||||||
|
|
||||||
//Write pom
|
//Write pom
|
||||||
MavenXpp3Writer modelWriter = new MavenXpp3Writer();
|
MavenXpp3Writer modelWriter = new MavenXpp3Writer();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PomTransformer transformer = new VersionTransformer();
|
PomTransformer transformer = new VersionTransformer();
|
||||||
|
|
||||||
transformer.setOutputFile( project.getFile() );
|
transformer.setOutputFile( project.getFile() );
|
||||||
|
|
||||||
transformer.setProject( project.getFile() );
|
transformer.setProject( project.getFile() );
|
||||||
|
|
||||||
transformer.setUpdatedModel ( model );
|
transformer.setUpdatedModel ( model );
|
||||||
|
|
||||||
transformer.transformNodes();
|
transformer.transformNodes();
|
||||||
|
|
||||||
transformer.write();
|
transformer.write();
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
|
@ -296,7 +309,11 @@ public class PrepareReleaseMojo
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
getScm().checkin( "[maven-release-plugin] prepare release " + projectVersion, "pom.xml", null );
|
ScmBean scm = getScm();
|
||||||
|
|
||||||
|
scm.setWorkingDirectory( basedir );
|
||||||
|
|
||||||
|
scm.checkin( "[maven-release-plugin] prepare release " + projectVersion, "pom.xml", null );
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
{
|
{
|
||||||
|
@ -307,14 +324,36 @@ public class PrepareReleaseMojo
|
||||||
private void tag()
|
private void tag()
|
||||||
throws MojoExecutionException
|
throws MojoExecutionException
|
||||||
{
|
{
|
||||||
|
// artifactId = plexus-action
|
||||||
|
// version = 1.0-beta-4
|
||||||
|
// tag = PLEXUS_ACTION_1_0_BETA_4
|
||||||
|
|
||||||
|
String tag = project.getArtifactId().toUpperCase() + "_" + projectVersion.toUpperCase();
|
||||||
|
|
||||||
|
tag = tag.replace( '-', '_' );
|
||||||
|
|
||||||
|
tag = tag.replace( '.', '_' );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ( getScm().getTag() == null )
|
ScmBean scm = getScm();
|
||||||
|
|
||||||
|
if ( scm.getTag() == null )
|
||||||
{
|
{
|
||||||
getLog().info( "What is the new tag name?" );
|
getLog().info( "What tag name should be used? [ " + tag + " ]" );
|
||||||
|
|
||||||
InputHandler handler = (InputHandler) getContainer().lookup( InputHandler.ROLE );
|
InputHandler handler = (InputHandler) getContainer().lookup( InputHandler.ROLE );
|
||||||
getScm().setTag( handler.readLine() );
|
|
||||||
|
String inputTag = handler.readLine();
|
||||||
|
|
||||||
|
if ( !StringUtils.isEmpty( inputTag ) )
|
||||||
|
{
|
||||||
|
tag = inputTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
scm.setTag( tag );
|
||||||
}
|
}
|
||||||
|
|
||||||
getScm().tag();
|
getScm().tag();
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
|
|
Loading…
Reference in New Issue