Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRELEASE-1089] Reduce the default tag format to the project version only #122

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public class DefaultNamingPolicy implements NamingPolicy
public NamingPolicyResult getName( NamingPolicyRequest request )
throws PolicyException
{
return new NamingPolicyResult().setName( request.getArtifactId() + "-" + request.getVersion() );
return new NamingPolicyResult().setName( request.getVersion() );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public void testInputVariablesInteractive()
{
// prepare
Prompter mockPrompter = mock( Prompter.class );
when( mockPrompter.prompt( isA( String.class ), eq( "artifactId-1.0" ) ) ).thenReturn( "tag-value",
"simulated-tag-value" );
when( mockPrompter.prompt( isA( String.class ), eq( "1.0" ) ) ).thenReturn( "tag-value",
"simulated-tag-value" );
phase = new InputVariablesPhase( mockPrompter, scmRepositoryConfigurator, namingPolicies );

List<MavenProject> reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) );
Expand All @@ -103,7 +103,7 @@ public void testInputVariablesInteractive()
// verify
assertEquals( "Check tag", "simulated-tag-value", ReleaseUtils.buildReleaseDescriptor( builder ).getScmReleaseLabel() );

verify( mockPrompter, times( 2 ) ).prompt( isA( String.class ), eq( "artifactId-1.0" ) );
verify( mockPrompter, times( 2 ) ).prompt( isA( String.class ), eq( "1.0" ) );
verifyNoMoreInteractions( mockPrompter );
}

Expand Down Expand Up @@ -162,7 +162,7 @@ public void testInputVariablesNonInteractive()
phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects );

// verify
assertEquals( "Check tag", "artifactId-1.0", ReleaseUtils.buildReleaseDescriptor( builder ).getScmReleaseLabel() );
assertEquals( "Check tag", "1.0", ReleaseUtils.buildReleaseDescriptor( builder ).getScmReleaseLabel() );

// prepare
builder = new ReleaseDescriptorBuilder();
Expand All @@ -174,7 +174,7 @@ public void testInputVariablesNonInteractive()
phase.simulate( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects );

// verify
assertEquals( "Check tag", "artifactId-1.0", ReleaseUtils.buildReleaseDescriptor( builder ).getScmReleaseLabel() );
assertEquals( "Check tag", "1.0", ReleaseUtils.buildReleaseDescriptor( builder ).getScmReleaseLabel() );

// never use prompter
verifyNoMoreInteractions( mockPrompter );
Expand Down Expand Up @@ -318,7 +318,7 @@ public void testSvnTag()
phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects );

// verify
assertEquals( "Check tag", "artifactId-1.0", ReleaseUtils.buildReleaseDescriptor( builder ).getScmReleaseLabel() );
assertEquals( "Check tag", "1.0", ReleaseUtils.buildReleaseDescriptor( builder ).getScmReleaseLabel() );

// prepare
builder = new ReleaseDescriptorBuilder();
Expand All @@ -330,7 +330,7 @@ public void testSvnTag()
phase.simulate( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects );

// verify
assertEquals( "Check tag", "artifactId-1.0", ReleaseUtils.buildReleaseDescriptor( builder ).getScmReleaseLabel() );
assertEquals( "Check tag", "1.0", ReleaseUtils.buildReleaseDescriptor( builder ).getScmReleaseLabel() );

// never use prompter
verifyNoMoreInteractions( mockPrompter );
Expand All @@ -355,7 +355,7 @@ public void testCustomTagFormat()
phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects );

// verify
assertEquals( "Check tag", "artifactId-1.0", ReleaseUtils.buildReleaseDescriptor( builder ).getScmReleaseLabel() );
assertEquals( "Check tag", "1.0", ReleaseUtils.buildReleaseDescriptor( builder ).getScmReleaseLabel() );

// prepare
builder = new ReleaseDescriptorBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public class DefaultNamingPolicyTest
@Test
public void testName() throws Exception
{
assertEquals( "ARTIFACTID-VERSION",
assertEquals( "VERSION",
policy.getName( newNamingPolicyRequest( "ARTIFACTID", "VERSION" ) ).getName() );
assertEquals( "ARTIFACTID-1.0-SNAPSHOT",
assertEquals( "1.0-SNAPSHOT",
policy.getName( newNamingPolicyRequest( "ARTIFACTID", "1.0-SNAPSHOT" ) ).getName() );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ assert 1 == pomXml.getText().count("<developerConnection>scm:svn:http://\${scm.h

File pomXmlTag = new File( basedir, 'pom.xml.tag' )
assert pomXmlTag.exists()
assert 1 == pomXmlTag.getText().count("<connection>scm:svn:http://\${scm.host}/svn/\${project.artifactId}/tags/mrelease-128-1.0</connection>")
assert 1 == pomXmlTag.getText().count("<developerConnection>scm:svn:http://\${scm.host}/svn/\${project.artifactId}/tags/mrelease-128-1.0</developerConnection>")
assert 1 == pomXmlTag.getText().count("<connection>scm:svn:http://\${scm.host}/svn/\${project.artifactId}/tags/1.0</connection>")
assert 1 == pomXmlTag.getText().count("<developerConnection>scm:svn:http://\${scm.host}/svn/\${project.artifactId}/tags/1.0</developerConnection>")

File pomXmlNext = new File( basedir, 'pom.xml.next' )
assert pomXmlNext.exists()
Expand All @@ -36,4 +36,4 @@ assert 1 == pomXmlNext.getText().count("<developerConnection>scm:svn:http://\${s
File pomXmlReleaseBackup = new File( basedir, 'pom.xml.releaseBackup' )
assert pomXmlReleaseBackup.exists()
assert 1 == pomXmlReleaseBackup.getText().count("<connection>scm:svn:http://\${scm.host}/svn/\${project.artifactId}/trunk/</connection>")
assert 1 == pomXmlReleaseBackup.getText().count("<developerConnection>scm:svn:http://\${scm.host}/svn/\${project.artifactId}/trunk/</developerConnection>")
assert 1 == pomXmlReleaseBackup.getText().count("<developerConnection>scm:svn:http://\${scm.host}/svn/\${project.artifactId}/trunk/</developerConnection>")
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<name>parent-project</name>
<url>http://maven.apache.org</url>
<scm>
<connection>scm:svn:file://localhost/${project.file.parentFile.parentFile}/target/svnroot/flat-multi-module/trunk/parent-project</connection>
<connection>scm:svn:file://localhost/${project.file.parentFile.parentFile}/target/svnroot/flat-multi-module/trunk/parent-project</connection>
<developerConnection>scm:svn:file://localhost/${project.file.parentFile.parentFile}/target/svnroot/flat-multi-module/trunk/parent-project</developerConnection>
</scm>

Expand All @@ -42,6 +42,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<tagNameFormat>@{project.artifactId}-@{project.version}</tagNameFormat>
</configuration>
</plugin>
</plugins>
</pluginManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ try
String contents = data.toString();

String expected1 = "Full run would tag working copy '" + basedir + "'";
String expected2 = " with label 'regular-multi-module-project-1.0'";
String expected2 = " with label '1.0'";

if( contents.indexOf( expected1 ) != -1 && contents.indexOf( expected2 ) != -1 )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public abstract class AbstractScmReleaseMojo
*
* @since 2.2.0
*/
@Parameter( defaultValue = "@{project.artifactId}-@{project.version}", property = "tagNameFormat" )
@Parameter( defaultValue = "@{project.version}", property = "tagNameFormat" )
private String tagNameFormat;

/**
Expand Down Expand Up @@ -113,7 +113,7 @@ public abstract class AbstractScmReleaseMojo
private String workItem;

/**
* Add a new or overwrite the default implementation per provider.
* Add a new or overwrite the default implementation per provider.
* The key is the scm prefix and the value is the role hint of the
* {@link org.apache.maven.scm.provider.ScmProvider}.
*
Expand Down Expand Up @@ -159,7 +159,7 @@ protected ReleaseDescriptorBuilder createReleaseDescriptor()

descriptor.setPushChanges( pushChanges );
descriptor.setWorkItem( workItem );

if ( project.getScm() != null )
{
if ( project.getScm().getDeveloperConnection() != null )
Expand All @@ -171,24 +171,24 @@ else if ( project.getScm().getConnection() != null )
descriptor.setScmSourceUrl( project.getScm().getConnection() );
}
}

// As long as Scm.getId() does not exist, read it as a property
descriptor.setScmId( project.getProperties().getProperty( "project.scm.id" ) );

for ( MavenProject reactorProject : session.getProjects() )
{
if ( reactorProject.getScm() != null )
{
String projectId =
ArtifactUtils.versionlessKey( reactorProject.getGroupId(), reactorProject.getArtifactId() );

descriptor.addOriginalScmInfo( projectId, buildScm( reactorProject ) );
}
}

return descriptor;
}

/**
* <p>buildScm.</p>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ mvn release:prepare-with-pom

* Overriding the default tag name format

By default, if you do not specify a tag name, a default tag name of <<<artifactId>>>-<<<version>>> will be
By default, if you do not specify a tag name, a default tag name of <<<version>>> will be
suggested (and if running non-interactively used).

You can specify the exact tag name to use from the command line by passing the <<<tag>>> property, but if you
Expand Down Expand Up @@ -141,4 +141,4 @@ mvn release:prepare-with-pom

[]

The <<<project.>>> prefix is optional and may be omitted.
The <<<project.>>> prefix is optional and may be omitted.