diff --git a/src/main/java/org/springframework/data/release/build/MavenBuildSystem.java b/src/main/java/org/springframework/data/release/build/MavenBuildSystem.java index 0b322e6..c9a4537 100644 --- a/src/main/java/org/springframework/data/release/build/MavenBuildSystem.java +++ b/src/main/java/org/springframework/data/release/build/MavenBuildSystem.java @@ -219,12 +219,12 @@ class MavenBuildSystem implements BuildSystem { Project project = module.getProject(); UpdateInformation information = new UpdateInformation(module.getTrainIteration(), phase); - mvn.execute(project, "versions-set", + mvn.execute(project, "versions:set", "versions:commit", "-DnewVersion=".concat(information.getProjectVersionToSet(project).toString())); if (BUILD.equals(project)) { - mvn.execute(project, "versions-set", // + mvn.execute(project, "versions:set", // "-DnewVersion=".concat(information.getReleaseTrainVersion()), // "-DgroupId=org.springframework.data", // "-DartifactId=spring-data-releasetrain"); @@ -272,13 +272,6 @@ class MavenBuildSystem implements BuildSystem { return isMavenProject(project); } - private void updateVersion(ModuleIteration iteration, File workingDirectory) { - - ArtifactVersion version = ArtifactVersion.of(iteration); - - mvn.execute(iteration.getProject(), "versions-set", "-DnewVersion=".concat(version.toString())); - } - private boolean isMavenProject(Project project) { return workspace.getFile(POM_XML, project).exists(); } diff --git a/src/main/java/org/springframework/data/release/build/MavenProperties.java b/src/main/java/org/springframework/data/release/build/MavenProperties.java index 7c7460b..f1a3672 100644 --- a/src/main/java/org/springframework/data/release/build/MavenProperties.java +++ b/src/main/java/org/springframework/data/release/build/MavenProperties.java @@ -68,6 +68,17 @@ class MavenProperties { public String getFullyQualifiedPlugin(String goal) { Assert.hasText(goal, "Goal must not be null or empty!"); - return plugins.containsKey(goal) ? plugins.get(goal) : goal; + + if (goal.startsWith("-")) { + return goal; + } + + String[] parts = goal.split(":"); + + if (parts.length != 2 || !plugins.containsKey(parts[0])) { + return goal; + } + + return plugins.get(parts[0]).concat(":").concat(parts[1]); } } diff --git a/src/main/java/org/springframework/data/release/build/MavenRuntime.java b/src/main/java/org/springframework/data/release/build/MavenRuntime.java index 9127240..30678a2 100644 --- a/src/main/java/org/springframework/data/release/build/MavenRuntime.java +++ b/src/main/java/org/springframework/data/release/build/MavenRuntime.java @@ -18,7 +18,6 @@ package org.springframework.data.release.build; import lombok.extern.slf4j.Slf4j; import java.io.File; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -87,9 +86,9 @@ class MavenRuntime { request.setShellEnvironmentInherited(true); request.setBaseDirectory(workspace.getProjectDirectory(project)); - List goals = new ArrayList<>(); - goals.add(properties.getFullyQualifiedPlugin(arguments.get(0))); - goals.addAll(arguments.subList(1, arguments.size())); + List goals = arguments.stream()// + .map(argument -> properties.getFullyQualifiedPlugin(argument))// + .collect(Collectors.toList()); request.setGoals(goals); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 3e2fb8d..2ef0c37 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -2,8 +2,7 @@ io.work-dir=~/temp/spring-data-shell/workspace # Maven setup maven.localRepository=~/temp/spring-data-shell/repository -maven.plugins.versions-set=org.codehaus.mojo:versions-maven-plugin:2.2:set -maven.plugins.artifactory-deploy=org.jfrog.buildinfo:artifactory-maven-plugin:2.4.0:publish +maven.plugins.versions=org.codehaus.mojo:versions-maven-plugin:2.2 deployment.server.uri=https://repo.spring.io deployment.staging-repository=libs-staging-local diff --git a/src/test/java/org/springframework/data/release/build/MavenPropertiesUnitTests.java b/src/test/java/org/springframework/data/release/build/MavenPropertiesUnitTests.java new file mode 100644 index 0000000..46245d5 --- /dev/null +++ b/src/test/java/org/springframework/data/release/build/MavenPropertiesUnitTests.java @@ -0,0 +1,67 @@ +/* + * Copyright 2016 the original author or authors. + * + * 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. + */ +package org.springframework.data.release.build; + +import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.*; + +import java.util.Collections; + +import org.junit.Before; +import org.junit.Test; + +/** + * Unit tests for {@link MavenProperties}. + * + * @author Oliver Gierke + */ +public class MavenPropertiesUnitTests { + + MavenProperties properties; + + @Before + public void setUp() { + + this.properties = new MavenProperties(); + this.properties.setPlugins(Collections.singletonMap("versions", "org.codehaus.mojo:versions-maven-plugin:2.2")); + } + + /** + * @see #8 + */ + @Test + public void expandsGoalsCorrectly() { + + assertThat(properties.getFullyQualifiedPlugin("versions:set"), + is("org.codehaus.mojo:versions-maven-plugin:2.2:set")); + } + + /** + * @see #8 + */ + @Test + public void doesNotExpandGoalStartingWithDash() { + assertThat(properties.getFullyQualifiedPlugin("-versions:set"), is("-versions:set")); + } + + /** + * @see #8 + */ + @Test + public void doesNotExpandGoalWithoutColon() { + assertThat(properties.getFullyQualifiedPlugin("versions-set"), is("versions-set")); + } +}