Skip to content

Commit 0615a4c

Browse files
kwinmichael-o
authored andcommitted
[MRELEASE-1072] Reuse original tag for next development version in case translator does not support resolution
This closes #86
1 parent 951aba3 commit 0615a4c

File tree

4 files changed

+103
-1
lines changed

4 files changed

+103
-1
lines changed

maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhase.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,19 @@ protected void transformScm( MavenProject project, Model modelTarget, ReleaseDes
8080
scmRoot.setConnection( scm.getConnection() );
8181
scmRoot.setDeveloperConnection( scm.getDeveloperConnection() );
8282
scmRoot.setUrl( scm.getUrl() );
83-
scmRoot.setTag( translator.resolveTag( scm.getTag() ) );
83+
String tag = translator.resolveTag( scm.getTag() );
84+
// reuse unresolved tag from original in case ScmTranslator does not support tags
85+
if ( tag == null )
86+
{
87+
tag = scm.getTag();
88+
// never give out default value as there is no way to distinguish it from an the
89+
// explicitly set tag with the same value
90+
if ( "HEAD".equals( tag ) )
91+
{
92+
tag = null;
93+
}
94+
}
95+
scmRoot.setTag( tag );
8496
}
8597
else
8698
{

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,26 @@ public void testRewriteBasicPomWithGitFromTag()
292292
assertTrue( comparePomFiles( reactorProjects ) );
293293
}
294294

295+
@Test
296+
public void testRewriteBasicPomWithSvnFromTag()
297+
throws Exception
298+
{
299+
List<MavenProject> reactorProjects = createReactorProjects( "basic-pom-with-svn-from-tag" );
300+
ReleaseDescriptorBuilder builder = createDescriptorFromProjects( reactorProjects, "basic-pom-with-svn-from-tag" );
301+
mapNextVersion( builder, "groupId:artifactId" );
302+
303+
Scm scm = new Scm();
304+
scm.setConnection( "scm:svn:file://localhost/svnroot/trunk/" );
305+
scm.setDeveloperConnection( "scm:svn:file://localhost/svnroot/trunk/" );
306+
scm.setUrl( "http://localhost/svn" );
307+
scm.setTag( "trunk" );
308+
builder.addOriginalScmInfo( "groupId:artifactId", scm );
309+
310+
phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects );
311+
312+
assertTrue( comparePomFiles( reactorProjects ) );
313+
}
314+
295315
@Test
296316
public void testRewriteBasicPomWithInheritedScm()
297317
throws Exception
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
~ Copyright 2022 The Apache Software Foundation.
5+
~
6+
~ Licensed under the Apache License, Version 2.0 (the "License");
7+
~ you may not use this file except in compliance with the License.
8+
~ You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
-->
18+
19+
<project>
20+
<modelVersion>4.0.0</modelVersion>
21+
<groupId>groupId</groupId>
22+
<artifactId>artifactId</artifactId>
23+
<version>1.1-SNAPSHOT</version>
24+
25+
<prerequisites>
26+
<maven>3.2.5</maven>
27+
</prerequisites>
28+
29+
<scm>
30+
<connection>scm:svn:file://localhost/svnroot/trunk/</connection>
31+
<developerConnection>scm:svn:file://localhost/svnroot/trunk/</developerConnection>
32+
<url>http://localhost/svn</url>
33+
<tag>trunk</tag>
34+
</scm>
35+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
~ Copyright 2022 The Apache Software Foundation.
5+
~
6+
~ Licensed under the Apache License, Version 2.0 (the "License");
7+
~ you may not use this file except in compliance with the License.
8+
~ You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
-->
18+
19+
<project>
20+
<modelVersion>4.0.0</modelVersion>
21+
<groupId>groupId</groupId>
22+
<artifactId>artifactId</artifactId>
23+
<version>1.0</version>
24+
25+
<prerequisites>
26+
<maven>3.2.5</maven>
27+
</prerequisites>
28+
29+
<scm>
30+
<connection>scm:svn:file://localhost/svnroot/trunk/</connection>
31+
<developerConnection>scm:svn:file://localhost/svnroot/trunk/</developerConnection>
32+
<url>http://localhost/svn</url>
33+
<tag>trunk</tag>
34+
</scm>
35+
</project>

0 commit comments

Comments
 (0)