#8 - The execution of the versions plugin now cleans up after itself.
Tweaked the expansion of the Maven plugins to only map the plugin so that e.g. versions:set gets expanded to the fully qualified version of the versions plugin as registered in application.properties. Tweaked the expansion to inspect all arguments given but ignore properties not containing a colon or staring with a dash.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String> goals = new ArrayList<>();
|
||||
goals.add(properties.getFullyQualifiedPlugin(arguments.get(0)));
|
||||
goals.addAll(arguments.subList(1, arguments.size()));
|
||||
List<String> goals = arguments.stream()//
|
||||
.map(argument -> properties.getFullyQualifiedPlugin(argument))//
|
||||
.collect(Collectors.toList());
|
||||
|
||||
request.setGoals(goals);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user