This is an automated email from the ASF dual-hosted git repository. rfscholte pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-release.git
commit c72c43139994fb2fb99b5fb422d5882d1226311b Author: rfscholte <rfscho...@apache.org> AuthorDate: Sun Feb 25 14:53:17 2018 +0100 [MRELEASE-694] -SNAPSHOT is unexpectedly appended to version in branched pom.xml --- .../shared/release/phase/MapVersionsPhase.java | 12 +++- .../shared/release/phase/MapVersionsPhaseTest.java | 73 ++++++++++++++++++++ .../src/it/projects/branch/MRELEASE-694/pom.xml | 77 ++++++++++++++++++++++ .../projects/branch/MRELEASE-694/test.properties | 21 ++++++ .../it/projects/branch/MRELEASE-694/verify.groovy | 27 ++++++++ 5 files changed, 208 insertions(+), 2 deletions(-) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapVersionsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapVersionsPhase.java index 8f4517d..700f53d 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapVersionsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapVersionsPhase.java @@ -281,7 +281,7 @@ public class MapVersionsPhase { throw new ReleaseExecutionException( e.getMessage(), e ); } - } + } if ( releaseDescriptor.isInteractive() ) { @@ -295,10 +295,18 @@ public class MapVersionsPhase //@todo validate next version, maybe with DefaultArtifactVersion } - else + else if ( defaultVersion == null ) { nextVersion = suggestedVersion; } + else if ( convertToSnapshot ) + { + throw new ReleaseExecutionException( defaultVersion + " is invalid, expected a snapshot" ); + } + else + { + throw new ReleaseExecutionException( defaultVersion + " is invalid, expected a non-snapshot" ); + } } } catch ( PrompterException e ) diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/MapVersionsPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/MapVersionsPhaseTest.java index 36e98bb..338d979 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/MapVersionsPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/MapVersionsPhaseTest.java @@ -2139,6 +2139,79 @@ public class MapVersionsPhaseTest // test phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); } + + @Test + public void testUpdateBranchInvalidDefaultReleaseVersion_NonInteractive() + throws Exception + { + // prepare + ReleasePhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + + List<MavenProject> reactorProjects = Collections.singletonList( createProject( "bar", "1.11-SNAPSHOT" ) ); + + ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); + builder.setDefaultReleaseVersion( "3.0" ); + builder.setInteractive( false ); + builder.setUpdateBranchVersions( true ); + + // test + try { + phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); + fail( "Should fail due to invalid version" ); + } + catch( ReleaseExecutionException e ) + { + assertEquals( "3.0 is invalid, expected a snapshot", e.getMessage() ); + } + } + + @Test + public void testUpdateReleaseInvalidDefaultReleaseVersion_NonInteractive() + throws Exception + { + // prepare + ReleasePhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_RELEASE_VERSIONS ); + + List<MavenProject> reactorProjects = Collections.singletonList( createProject( "bar", "1.11-SNAPSHOT" ) ); + + ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); + builder.setDefaultReleaseVersion( "3.0-SNAPSHOT" ); + builder.setInteractive( false ); + + // test + try { + phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); + fail( "Should fail due to invalid version" ); + } + catch( ReleaseExecutionException e ) + { + assertEquals( "3.0-SNAPSHOT is invalid, expected a non-snapshot", e.getMessage() ); + } + } + + @Test + public void testUpdateDevelopmentInvalidDefaultDevelopmentVersion_NonInteractive() + throws Exception + { + // prepare + ReleasePhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + + List<MavenProject> reactorProjects = Collections.singletonList( createProject( "bar", "1.11-SNAPSHOT" ) ); + + ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); + builder.setDefaultDevelopmentVersion( "3.0" ); + builder.setInteractive( false ); + + // test + try { + phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); + fail( "Should fail due to invalid version" ); + } + catch( ReleaseExecutionException e ) + { + assertEquals( "3.0 is invalid, expected a snapshot", e.getMessage() ); + } + } private static MavenProject createProject( String artifactId, String version ) { diff --git a/maven-release-plugin/src/it/projects/branch/MRELEASE-694/pom.xml b/maven-release-plugin/src/it/projects/branch/MRELEASE-694/pom.xml new file mode 100644 index 0000000..e84c5ea --- /dev/null +++ b/maven-release-plugin/src/it/projects/branch/MRELEASE-694/pom.xml @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you 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. + --> + + <!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you 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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugin.release.it</groupId> + <artifactId>mrelease-694</artifactId> + <version>1.0-SNAPSHOT</version> + + <scm> + <connection>scm:dummy|nul</connection> + <developerConnection>scm:dummy|nul</developerConnection> + </scm> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-release-plugin</artifactId> + <version>2.4.2</version> + <configuration> + <autoVersionSubmodules>true</autoVersionSubmodules> + <updateBranchVersions>true</updateBranchVersions> + <updateWorkingCopyVersions>true</updateWorkingCopyVersions> + <updateDependencies>true</updateDependencies> + <pushChanges>true</pushChanges> + <remoteTagging>false</remoteTagging> + <suppressCommitBeforeBranch>false</suppressCommitBeforeBranch> + </configuration> + <dependencies> + <dependency> + <groupId>org.apache.maven.its.release</groupId> + <artifactId>maven-scm-provider-dummy</artifactId> + <version>1.0</version> + </dependency> + </dependencies> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file diff --git a/maven-release-plugin/src/it/projects/branch/MRELEASE-694/test.properties b/maven-release-plugin/src/it/projects/branch/MRELEASE-694/test.properties new file mode 100644 index 0000000..38e8076 --- /dev/null +++ b/maven-release-plugin/src/it/projects/branch/MRELEASE-694/test.properties @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +branchName=RELEASE-2.6.0 +developmentVersion=2.6.1-DEV-SNAPSHOT +releaseVersion=2.6.0-BRANCH-SNAPSHOT +updateVersionsToSnapshot=false +dryRun=true \ No newline at end of file diff --git a/maven-release-plugin/src/it/projects/branch/MRELEASE-694/verify.groovy b/maven-release-plugin/src/it/projects/branch/MRELEASE-694/verify.groovy new file mode 100644 index 0000000..8d7f901 --- /dev/null +++ b/maven-release-plugin/src/it/projects/branch/MRELEASE-694/verify.groovy @@ -0,0 +1,27 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +def projectBranch = new XmlSlurper().parse( new File( basedir, "pom.xml.branch" ) ) +assert projectBranch.version.text() == "2.6.0-BRANCH-SNAPSHOT" + +def projectNext = new XmlSlurper().parse( new File( basedir, "pom.xml.next" ) ) +assert projectNext.version.text() == "2.6.1-DEV-SNAPSHOT" + +return true \ No newline at end of file -- To stop receiving notification emails like this one, please contact rfscho...@apache.org.