Skip to content

Commit

Permalink
Add support for the "--pin-externals" option in SCM branch and tag
Browse files Browse the repository at this point in the history
operations. This feature was introducted in Subversion 1.9 and is
available in maven-scm-plugin since version 1.11.1
  • Loading branch information
theit committed Dec 20, 2019
1 parent 1123e3b commit ce04d7f
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -464,4 +464,12 @@ public interface ReleaseDescriptor
void setScmRelativePathProjectDirectory( String scmRelativePathProjectDirectory );

void setScmSourceUrl( String scmUrl );

/**
* Get whether the "--pin-externals" option in svn copy commands is enabled
* which is new in Subversion 1.9.
*
* @return boolean
*/
boolean isPinExternals();
}
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ public void write( BuilderReleaseDescriptor config, File file )

properties.setProperty( "remoteTagging", Boolean.toString( config.isRemoteTagging() ) );

properties.setProperty( "pinExternals", Boolean.toString( config.isPinExternals() ) );

properties.setProperty( "pushChanges", Boolean.toString( config.isPushChanges() ) );

if ( config.getWorkItem() != null )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,12 @@ public ReleaseDescriptorBuilder addDependencyDevelopmentVersion( String dependen
return this;
}

public ReleaseDescriptorBuilder setPinExternals( boolean pinExternals )
{
releaseDescriptor.setPinExternals( pinExternals );
return this;
}

BuilderReleaseDescriptor build()
{
return releaseDescriptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ public static void copyPropertiesToReleaseDescriptor( Properties properties, Rel
String remoteTaggingStr = properties.getProperty( "remoteTagging" );
builder.setRemoteTagging( Boolean.valueOf( remoteTaggingStr ) );
}
if ( properties.containsKey( "pinExternals" ) )
{
String pinExternals = properties.getProperty( "pinExternals" );
builder.setPinExternals( Boolean.valueOf( pinExternals ) );
}
if ( properties.containsKey( "pushChanges" ) )
{
String pushChanges = properties.getProperty( "pushChanges" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro
scmBranchParameters.setMessage( releaseDescriptor.getScmCommentPrefix() + "copy for branch " + branchName );
scmBranchParameters.setRemoteBranching( releaseDescriptor.isRemoteTagging() );
scmBranchParameters.setScmRevision( releaseDescriptor.getScmReleasedPomRevision() );
scmBranchParameters.setPinExternals( releaseDescriptor.isPinExternals() );

result = provider.branch( repository, fileSet, branchName, scmBranchParameters );
}
Expand Down Expand Up @@ -143,6 +144,10 @@ public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvir
logInfo( result, " To SCM URL: " + releaseDescriptor.getScmBranchBase() );
}
logInfo( result, " with label: '" + releaseDescriptor.getScmReleaseLabel() + "'" );
if ( releaseDescriptor.isPinExternals() )
{
logInfo( result, " with pinned externals" );
}

result.setResultCode( ReleaseResult.SUCCESS );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,16 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro
new ScmTagParameters( releaseDescriptor.getScmCommentPrefix() + "copy for tag " + tagName );
scmTagParameters.setRemoteTagging( releaseDescriptor.isRemoteTagging() );
scmTagParameters.setScmRevision( releaseDescriptor.getScmReleasedPomRevision() );
scmTagParameters.setPinExternals( releaseDescriptor.isPinExternals() );
if ( getLogger().isDebugEnabled() )
{
getLogger().debug(
"ScmTagPhase :: scmTagParameters remotingTag " + releaseDescriptor.isRemoteTagging() );
getLogger().debug(
"ScmTagPhase :: scmTagParameters scmRevision " + releaseDescriptor.getScmReleasedPomRevision() );
getLogger().debug( "ScmTagPhase :: fileSet " + fileSet );
getLogger().debug(
"ScmTagPhase :: scmTagParameters pinExternals " + releaseDescriptor.isPinExternals() );
}
result = provider.tag( repository, fileSet, tagName, scmTagParameters );
}
Expand Down Expand Up @@ -168,6 +171,10 @@ public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvir
logInfo( result, "Full run would be tagging remotely " + basedirAlignedReleaseDescriptor.getScmSourceUrl()
+ " with label: '" + releaseDescriptor.getScmReleaseLabel() + "'" );
}
if ( releaseDescriptor.isPinExternals() )
{
logInfo( result, "Full run would pin externals" );
}

result.setResultCode( ReleaseResult.SUCCESS );

Expand Down
14 changes: 14 additions & 0 deletions maven-release-manager/src/main/mdo/release-descriptor.mdo
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,18 @@
</description>
</field>

<field>
<name>pinExternals</name>
<version>3.0.0+</version>
<type>boolean</type>
<defaultValue>false</defaultValue>
<description>
Enable the "--pin-externals" option in svn copy commands which is new in Subversion 1.9.
NOTE : Currently only implemented with Subversion.
(https://issues.apache.org/jira/browse/SCM-805)
</description>
</field>

<!-- Announcement Information
Announcement related info, this can be a second part of the process.
Expand Down Expand Up @@ -785,6 +797,7 @@
updateVersionsToSnapshot != that.isUpdateVersionsToSnapshot() ||
allowTimestampedSnapshots != that.isAllowTimestampedSnapshots() ||
remoteTagging != that.isRemoteTagging() ||
pinExternals != that.isPinExternals() ||
localCheckout != that.isLocalCheckout() ||
pushChanges != that.isPushChanges()
)
Expand Down Expand Up @@ -1054,6 +1067,7 @@
result = 29 * result + java.util.Objects.hashCode( defaultReleaseVersion );
result = 29 * result + java.util.Objects.hashCode( scmReleasedPomRevision );
result = 29 * result + java.util.Objects.hashCode( workItem );
result = 29 * result + java.util.Objects.hashCode( pinExternals );
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public void testSuppressCommitBeforeTagOrBranch()
builder.setGenerateReleasePoms( true );
builder.setSuppressCommitBeforeTagOrBranch( true );
builder.setRemoteTagging( false );
builder.setPinExternals( false );
mapNextVersion( builder, "groupId:artifactId" );

phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects );
Expand All @@ -135,6 +136,7 @@ public void testSuppressCommitBeforeTagOrBranchAndReomoteTagging()
builder.setGenerateReleasePoms( true );
builder.setSuppressCommitBeforeTagOrBranch( true );
builder.setRemoteTagging( true );
builder.setPinExternals( false );
mapNextVersion( builder, "groupId:artifactId" );

phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public boolean matches( Object argument )
{
ScmBranchParameters sbp = (ScmBranchParameters) argument;
return sbp.getMessage().equals( this.scmBranchParameters.getMessage() )
//&& stp.isRemoteTagging() == this.scmBranchParameters.isRemoteTagging()
;
&& sbp.isRemoteBranching() == this.scmBranchParameters.isRemoteBranching()
&& sbp.isPinExternals() == this.scmBranchParameters.isPinExternals();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public boolean matches( Object argument )
{
ScmTagParameters stp = (ScmTagParameters) argument;
return stp.getMessage().equals( this.scmTagParameters.getMessage() )
&& stp.isRemoteTagging() == this.scmTagParameters.isRemoteTagging();
&& stp.isRemoteTagging() == this.scmTagParameters.isRemoteTagging()
&& stp.isPinExternals() == this.scmTagParameters.isPinExternals();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public void testNoCommitOrRollbackRequired()
List<MavenProject> reactorProjects = createReactorProjects();

builder.setRemoteTagging( false );
builder.setPinExternals( false );
builder.setSuppressCommitBeforeTagOrBranch( true );
builder.setUpdateWorkingCopyVersions( false );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ public void testSuppressCommitWithRemoteTaggingFails()
List<MavenProject> reactorProjects = createReactorProjects();

builder.setRemoteTagging( true );
builder.setPinExternals( false );
builder.setSuppressCommitBeforeTagOrBranch( true );

ScmProvider scmProviderMock = mock( ScmProvider.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ public class BranchReleaseMojo
@Parameter( defaultValue = "@{prefix} prepare branch @{releaseLabel}", property = "scmBranchCommitComment" )
private String scmBranchCommitComment = "@{prefix} prepare branch @{releaseLabel}";

/**
* Currently only implemented with svn scm. Enable the "--pin-externals" option in svn
* copy commands which is new in Subversion 1.9.
*
* @since 3.0.0
*/
@Parameter( defaultValue = "false", property = "pinExternals" )
private boolean pinExternals;

@Override
public void execute()
throws MojoExecutionException, MojoFailureException
Expand All @@ -254,6 +263,7 @@ public void execute()
config.setProjectVersionPolicyId( projectVersionPolicyId );
config.setProjectNamingPolicyId( projectBranchNamingPolicyId );
config.setScmBranchCommitComment( scmBranchCommitComment );
config.setPinExternals( pinExternals );

if ( checkModificationExcludeList != null )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,15 @@ public class PrepareReleaseMojo
property = "scmDevelopmentCommitComment" )
private String scmDevelopmentCommitComment = "@{prefix} prepare for next development iteration";

/**
* Currently only implemented with svn scm. Enable the "--pin-externals" option in svn
* copy commands which is new in Subversion 1.9.
*
* @since 3.0.0
*/
@Parameter( defaultValue = "false", property = "pinExternals" )
private boolean pinExternals;

@Override
public void execute()
throws MojoExecutionException, MojoFailureException
Expand Down Expand Up @@ -321,6 +330,7 @@ protected void prepareRelease( boolean generateReleasePoms )
config.setProjectNamingPolicyId( projectTagNamingPolicyId );
config.setScmDevelopmentCommitComment( scmDevelopmentCommitComment );
config.setScmReleaseCommitComment( scmReleaseCommitComment );
config.setPinExternals( pinExternals );

if ( checkModificationExcludeList != null )
{
Expand Down

0 comments on commit ce04d7f

Please sign in to comment.