Skip to content

Commit 43199fd

Browse files
committed
[MRELEASE-1089] Reduce the default tag format to the project version only
This closes #122
1 parent 8cc2f45 commit 43199fd

File tree

8 files changed

+28
-25
lines changed

8 files changed

+28
-25
lines changed

maven-release-manager/src/main/java/org/apache/maven/shared/release/policies/DefaultNamingPolicy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ public class DefaultNamingPolicy implements NamingPolicy
4141
public NamingPolicyResult getName( NamingPolicyRequest request )
4242
throws PolicyException
4343
{
44-
return new NamingPolicyResult().setName( request.getArtifactId() + "-" + request.getVersion() );
44+
return new NamingPolicyResult().setName( request.getVersion() );
4545
}
4646
}

maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/InputVariablesPhaseTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ public void testInputVariablesInteractive()
7676
{
7777
// prepare
7878
Prompter mockPrompter = mock( Prompter.class );
79-
when( mockPrompter.prompt( isA( String.class ), eq( "artifactId-1.0" ) ) ).thenReturn( "tag-value",
80-
"simulated-tag-value" );
79+
when( mockPrompter.prompt( isA( String.class ), eq( "1.0" ) ) ).thenReturn( "tag-value",
80+
"simulated-tag-value" );
8181
phase = new InputVariablesPhase( mockPrompter, scmRepositoryConfigurator, namingPolicies );
8282

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

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

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

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

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

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

179179
// never use prompter
180180
verifyNoMoreInteractions( mockPrompter );
@@ -318,7 +318,7 @@ public void testSvnTag()
318318
phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects );
319319

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

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

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

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

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

360360
// prepare
361361
builder = new ReleaseDescriptorBuilder();

maven-release-manager/src/test/java/org/apache/maven/shared/release/policies/DefaultNamingPolicyTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public class DefaultNamingPolicyTest
3131
@Test
3232
public void testName() throws Exception
3333
{
34-
assertEquals( "ARTIFACTID-VERSION",
34+
assertEquals( "VERSION",
3535
policy.getName( newNamingPolicyRequest( "ARTIFACTID", "VERSION" ) ).getName() );
36-
assertEquals( "ARTIFACTID-1.0-SNAPSHOT",
36+
assertEquals( "1.0-SNAPSHOT",
3737
policy.getName( newNamingPolicyRequest( "ARTIFACTID", "1.0-SNAPSHOT" ) ).getName() );
3838
}
3939

maven-release-plugin/src/it/projects/prepare/MRELEASE-128/verify.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ assert 1 == pomXml.getText().count("<developerConnection>scm:svn:http://\${scm.h
2525

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

3131
File pomXmlNext = new File( basedir, 'pom.xml.next' )
3232
assert pomXmlNext.exists()
@@ -36,4 +36,4 @@ assert 1 == pomXmlNext.getText().count("<developerConnection>scm:svn:http://\${s
3636
File pomXmlReleaseBackup = new File( basedir, 'pom.xml.releaseBackup' )
3737
assert pomXmlReleaseBackup.exists()
3838
assert 1 == pomXmlReleaseBackup.getText().count("<connection>scm:svn:http://\${scm.host}/svn/\${project.artifactId}/trunk/</connection>")
39-
assert 1 == pomXmlReleaseBackup.getText().count("<developerConnection>scm:svn:http://\${scm.host}/svn/\${project.artifactId}/trunk/</developerConnection>")
39+
assert 1 == pomXmlReleaseBackup.getText().count("<developerConnection>scm:svn:http://\${scm.host}/svn/\${project.artifactId}/trunk/</developerConnection>")

maven-release-plugin/src/it/projects/prepare/flat-multi-module/parent-project/pom.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<name>parent-project</name>
2727
<url>http://maven.apache.org</url>
2828
<scm>
29-
<connection>scm:svn:file://localhost/${project.file.parentFile.parentFile}/target/svnroot/flat-multi-module/trunk/parent-project</connection>
29+
<connection>scm:svn:file://localhost/${project.file.parentFile.parentFile}/target/svnroot/flat-multi-module/trunk/parent-project</connection>
3030
<developerConnection>scm:svn:file://localhost/${project.file.parentFile.parentFile}/target/svnroot/flat-multi-module/trunk/parent-project</developerConnection>
3131
</scm>
3232

@@ -42,6 +42,9 @@
4242
<groupId>org.apache.maven.plugins</groupId>
4343
<artifactId>maven-release-plugin</artifactId>
4444
<version>@project.version@</version>
45+
<configuration>
46+
<tagNameFormat>@{project.artifactId}-@{project.version}</tagNameFormat>
47+
</configuration>
4548
</plugin>
4649
</plugins>
4750
</pluginManagement>

maven-release-plugin/src/it/projects/prepare/regular-multi-module/verify.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ try
3737
String contents = data.toString();
3838

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

4242
if( contents.indexOf( expected1 ) != -1 && contents.indexOf( expected2 ) != -1 )
4343
{

maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractScmReleaseMojo.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public abstract class AbstractScmReleaseMojo
7070
*
7171
* @since 2.2.0
7272
*/
73-
@Parameter( defaultValue = "@{project.artifactId}-@{project.version}", property = "tagNameFormat" )
73+
@Parameter( defaultValue = "@{project.version}", property = "tagNameFormat" )
7474
private String tagNameFormat;
7575

7676
/**
@@ -113,7 +113,7 @@ public abstract class AbstractScmReleaseMojo
113113
private String workItem;
114114

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

160160
descriptor.setPushChanges( pushChanges );
161161
descriptor.setWorkItem( workItem );
162-
162+
163163
if ( project.getScm() != null )
164164
{
165165
if ( project.getScm().getDeveloperConnection() != null )
@@ -171,24 +171,24 @@ else if ( project.getScm().getConnection() != null )
171171
descriptor.setScmSourceUrl( project.getScm().getConnection() );
172172
}
173173
}
174-
174+
175175
// As long as Scm.getId() does not exist, read it as a property
176176
descriptor.setScmId( project.getProperties().getProperty( "project.scm.id" ) );
177-
177+
178178
for ( MavenProject reactorProject : session.getProjects() )
179179
{
180180
if ( reactorProject.getScm() != null )
181181
{
182182
String projectId =
183183
ArtifactUtils.versionlessKey( reactorProject.getGroupId(), reactorProject.getArtifactId() );
184-
184+
185185
descriptor.addOriginalScmInfo( projectId, buildScm( reactorProject ) );
186186
}
187187
}
188188

189189
return descriptor;
190190
}
191-
191+
192192
/**
193193
* <p>buildScm.</p>
194194
*

maven-release-plugin/src/site/apt/examples/prepare-release.apt.vm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ mvn release:prepare-with-pom
9595

9696
* Overriding the default tag name format
9797

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

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

142142
[]
143143

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

0 commit comments

Comments
 (0)