This is an automated email from the ASF dual-hosted git repository. michaelo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-release.git
commit 0615a4c3b2138116a255fc2b57fcf83d76d49e68 Author: Konrad Windszus <[email protected]> AuthorDate: Sat Nov 6 11:53:16 2021 +0100 [MRELEASE-1072] Reuse original tag for next development version in case translator does not support resolution This closes #86 --- .../phase/RewritePomsForDevelopmentPhase.java | 14 ++++++++- .../phase/RewritePomsForDevelopmentPhaseTest.java | 20 +++++++++++++ .../basic-pom-with-svn-from-tag/expected-pom.xml | 35 ++++++++++++++++++++++ .../basic-pom-with-svn-from-tag/pom.xml | 35 ++++++++++++++++++++++ 4 files changed, 103 insertions(+), 1 deletion(-) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhase.java index b9914c72..a1888900 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhase.java @@ -80,7 +80,19 @@ public class RewritePomsForDevelopmentPhase scmRoot.setConnection( scm.getConnection() ); scmRoot.setDeveloperConnection( scm.getDeveloperConnection() ); scmRoot.setUrl( scm.getUrl() ); - scmRoot.setTag( translator.resolveTag( scm.getTag() ) ); + String tag = translator.resolveTag( scm.getTag() ); + // reuse unresolved tag from original in case ScmTranslator does not support tags + if ( tag == null ) + { + tag = scm.getTag(); + // never give out default value as there is no way to distinguish it from an the + // explicitly set tag with the same value + if ( "HEAD".equals( tag ) ) + { + tag = null; + } + } + scmRoot.setTag( tag ); } else { diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhaseTest.java index 476cf042..c96f583f 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhaseTest.java @@ -292,6 +292,26 @@ public class RewritePomsForDevelopmentPhaseTest assertTrue( comparePomFiles( reactorProjects ) ); } + @Test + public void testRewriteBasicPomWithSvnFromTag() + throws Exception + { + List<MavenProject> reactorProjects = createReactorProjects( "basic-pom-with-svn-from-tag" ); + ReleaseDescriptorBuilder builder = createDescriptorFromProjects( reactorProjects, "basic-pom-with-svn-from-tag" ); + mapNextVersion( builder, "groupId:artifactId" ); + + Scm scm = new Scm(); + scm.setConnection( "scm:svn:file://localhost/svnroot/trunk/" ); + scm.setDeveloperConnection( "scm:svn:file://localhost/svnroot/trunk/" ); + scm.setUrl( "http://localhost/svn" ); + scm.setTag( "trunk" ); + builder.addOriginalScmInfo( "groupId:artifactId", scm ); + + phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); + + assertTrue( comparePomFiles( reactorProjects ) ); + } + @Test public void testRewriteBasicPomWithInheritedScm() throws Exception diff --git a/maven-release-manager/src/test/resources/projects/rewrite-for-development/basic-pom-with-svn-from-tag/expected-pom.xml b/maven-release-manager/src/test/resources/projects/rewrite-for-development/basic-pom-with-svn-from-tag/expected-pom.xml new file mode 100644 index 00000000..712373e5 --- /dev/null +++ b/maven-release-manager/src/test/resources/projects/rewrite-for-development/basic-pom-with-svn-from-tag/expected-pom.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + ~ Copyright 2022 The Apache Software Foundation. + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>groupId</groupId> + <artifactId>artifactId</artifactId> + <version>1.1-SNAPSHOT</version> + + <prerequisites> + <maven>3.2.5</maven> + </prerequisites> + + <scm> + <connection>scm:svn:file://localhost/svnroot/trunk/</connection> + <developerConnection>scm:svn:file://localhost/svnroot/trunk/</developerConnection> + <url>http://localhost/svn</url> + <tag>trunk</tag> + </scm> +</project> \ No newline at end of file diff --git a/maven-release-manager/src/test/resources/projects/rewrite-for-development/basic-pom-with-svn-from-tag/pom.xml b/maven-release-manager/src/test/resources/projects/rewrite-for-development/basic-pom-with-svn-from-tag/pom.xml new file mode 100644 index 00000000..a5d292b9 --- /dev/null +++ b/maven-release-manager/src/test/resources/projects/rewrite-for-development/basic-pom-with-svn-from-tag/pom.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + ~ Copyright 2022 The Apache Software Foundation. + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<project> + <modelVersion>4.0.0</modelVersion> + <groupId>groupId</groupId> + <artifactId>artifactId</artifactId> + <version>1.0</version> + + <prerequisites> + <maven>3.2.5</maven> + </prerequisites> + + <scm> + <connection>scm:svn:file://localhost/svnroot/trunk/</connection> + <developerConnection>scm:svn:file://localhost/svnroot/trunk/</developerConnection> + <url>http://localhost/svn</url> + <tag>trunk</tag> + </scm> +</project> \ No newline at end of file
