Added option to resolve {{nextVersion}} {{version}} and {{oldVersion}} in all commands
fixes gh-171
This commit is contained in:
@@ -101,23 +101,24 @@ public class Releaser implements ReleaserPropertiesAware {
|
||||
}
|
||||
|
||||
public void updateProjectFromBom(File project, Projects versions,
|
||||
ProjectVersion versionFromScRelease) {
|
||||
updateProjectFromBom(project, versions, versionFromScRelease, ASSERT_SNAPSHOTS);
|
||||
ProjectVersion versionFromBom) {
|
||||
updateProjectFromBom(project, versions, versionFromBom, ASSERT_SNAPSHOTS);
|
||||
}
|
||||
|
||||
private void updateProjectFromBom(File project, Projects versions,
|
||||
ProjectVersion versionFromScRelease, boolean assertSnapshots) {
|
||||
ProjectVersion versionFromBom, boolean assertSnapshots) {
|
||||
log.info("Will update the project with versions [{}]", versions);
|
||||
this.projectPomUpdater.updateProjectFromReleaseTrain(project, versions,
|
||||
versionFromScRelease, assertSnapshots);
|
||||
this.gradleUpdater.updateProjectFromBom(project, versions, versionFromScRelease,
|
||||
versionFromBom, assertSnapshots);
|
||||
this.gradleUpdater.updateProjectFromBom(project, versions, versionFromBom,
|
||||
assertSnapshots);
|
||||
ProjectVersion changedVersion = new ProjectVersion(project);
|
||||
log.info("\n\nProject was successfully updated to [{}]", changedVersion.version);
|
||||
}
|
||||
|
||||
public void buildProject(ProjectVersion versionFromScRelease) {
|
||||
this.projectCommandExecutor.build(versionFromScRelease);
|
||||
public void buildProject(ProjectVersion originalVersion,
|
||||
ProjectVersion versionFromBom) {
|
||||
this.projectCommandExecutor.build(originalVersion, versionFromBom);
|
||||
log.info("\nProject was successfully built");
|
||||
}
|
||||
|
||||
@@ -126,13 +127,14 @@ public class Releaser implements ReleaserPropertiesAware {
|
||||
log.info("\nCommit was made and tag was pushed successfully");
|
||||
}
|
||||
|
||||
public void deploy(ProjectVersion versionFromScRelease) {
|
||||
this.projectCommandExecutor.deploy(versionFromScRelease);
|
||||
public void deploy(ProjectVersion originalVersion, ProjectVersion versionFromBom) {
|
||||
this.projectCommandExecutor.deploy(originalVersion, versionFromBom);
|
||||
log.info("\nThe artifact was deployed successfully");
|
||||
}
|
||||
|
||||
public void publishDocs(ProjectVersion changedVersion) {
|
||||
this.projectCommandExecutor.publishDocs(changedVersion.version);
|
||||
public void publishDocs(ProjectVersion originalVersion,
|
||||
ProjectVersion changedVersion) {
|
||||
this.projectCommandExecutor.publishDocs(originalVersion, changedVersion);
|
||||
log.info("\nThe docs were published successfully");
|
||||
}
|
||||
|
||||
|
||||
@@ -746,18 +746,25 @@ public class ReleaserProperties implements Serializable {
|
||||
public static final String PROFILE_PROPS_PLACEHOLDER = "{{profile}}";
|
||||
|
||||
/**
|
||||
* Command to be executed to build the project.
|
||||
*/
|
||||
* Command to be executed to build the project. If present "{{version}}" will be
|
||||
* replaced by the provided version. "{{nextVersion}}" with the bumped snapshot
|
||||
* version and "{{oldVersion}}" with the version before version updating.
|
||||
**/
|
||||
private String buildCommand = "./mvnw clean install -B -Pdocs {{systemProps}}";
|
||||
|
||||
/**
|
||||
* Command to be executed to deploy a built project.
|
||||
*/
|
||||
* Command to be executed to deploy a built project. If present "{{version}}" will
|
||||
* be replaced by the provided version. "{{nextVersion}}" with the bumped snapshot
|
||||
* version and "{{oldVersion}}" with the version before version updating.
|
||||
**/
|
||||
private String deployCommand = "./mvnw deploy -DskipTests -B -Pfast,deploy {{systemProps}}";
|
||||
|
||||
/**
|
||||
* Command to be executed to build and deploy guides project only.
|
||||
*/
|
||||
* Command to be executed to build and deploy guides project only. If present
|
||||
* "{{version}}" will be replaced by the provided version. "{{nextVersion}}" with
|
||||
* the bumped snapshot version and "{{oldVersion}}" with the version before
|
||||
* version updating.
|
||||
**/
|
||||
private String deployGuidesCommand = "./mvnw clean verify deploy -B -Pguides,integration -pl guides {{systemProps}}";
|
||||
|
||||
/**
|
||||
@@ -865,23 +872,31 @@ public class ReleaserProperties implements Serializable {
|
||||
public static final String SYSTEM_PROPS_PLACEHOLDER = "{{systemProps}}";
|
||||
|
||||
/**
|
||||
* Command to be executed to build the project.
|
||||
* Command to be executed to build the project. If present "{{version}}" will be
|
||||
* replaced by the provided version. "{{nextVersion}}" with the bumped snapshot
|
||||
* version and "{{oldVersion}}" with the version before version updating.
|
||||
*/
|
||||
private String buildCommand = "echo \"{{systemProps}}\"";
|
||||
|
||||
/**
|
||||
* Command to be executed to deploy a built project.
|
||||
* Command to be executed to deploy a built project. If present "{{version}}" will
|
||||
* be replaced by the provided version. "{{nextVersion}}" with the bumped snapshot
|
||||
* version and "{{oldVersion}}" with the version before version updating.
|
||||
*/
|
||||
private String deployCommand = "echo \"{{systemProps}}\"";
|
||||
|
||||
/**
|
||||
* Command to be executed to build and deploy guides project only.
|
||||
* Command to be executed to build and deploy guides project only. If present
|
||||
* "{{version}}" will be replaced by the provided version. "{{nextVersion}}" with
|
||||
* the bumped snapshot version and "{{oldVersion}}" with the version before
|
||||
* version updating.
|
||||
*/
|
||||
private String deployGuidesCommand = "echo \"{{systemProps}}\"";
|
||||
|
||||
/**
|
||||
* Command to be executed to publish documentation. If present "{{version}}" will
|
||||
* be replaced by the provided version.
|
||||
* be replaced by the provided version. "{{nextVersion}}" with the bumped snapshot
|
||||
* version and "{{oldVersion}}" with the version before version updating.
|
||||
*/
|
||||
private String[] publishDocsCommands = { "mkdir -p target",
|
||||
"echo \"{{version}}\"" };
|
||||
@@ -1010,19 +1025,21 @@ public class ReleaserProperties implements Serializable {
|
||||
"^.*src/test/bats/.*$", "^.*samples/standalone/[a-z]+/.*$");
|
||||
|
||||
/**
|
||||
* Command to be executed to build the project.
|
||||
*/
|
||||
private String buildCommand = "./gradlew clean build publishToMavenLocal --console=plain {{systemProps}}";
|
||||
* Command to be executed to build the project If present "{{version}}" will be
|
||||
* replaced by the provided version. "{{nextVersion}}" with the bumped snapshot
|
||||
* version and "{{oldVersion}}" with the version before version updating.
|
||||
**/
|
||||
private String buildCommand = "./gradlew clean build publishToMavenLocal --console=plain -PnextVersion={{nextVersion}} -PoldVersion={{oldVersion}} -PcurrentVersion={{version}} {{systemProps}}";
|
||||
|
||||
/**
|
||||
* Command to be executed to deploy a built project.
|
||||
*/
|
||||
private String deployCommand = "./gradlew publish --console=plain {{systemProps}}";
|
||||
private String deployCommand = "./gradlew publish --console=plain -PnextVersion={{nextVersion}} -PoldVersion={{oldVersion}} -PcurrentVersion={{version}} {{systemProps}}";
|
||||
|
||||
/**
|
||||
* Command to be executed to build and deploy guides project only.
|
||||
*/
|
||||
private String deployGuidesCommand = "./gradlew clean build deployGuides --console=plain {{systemProps}}";
|
||||
private String deployGuidesCommand = "./gradlew clean build deployGuides --console=plain -PnextVersion={{nextVersion}} -PoldVersion={{oldVersion}} -PcurrentVersion={{version}} {{systemProps}}";
|
||||
|
||||
/**
|
||||
* Command to be executed to publish documentation. If present "{{version}}" will
|
||||
|
||||
@@ -117,7 +117,8 @@ public class PostReleaseActions implements Closeable {
|
||||
Projects newProjects = addVersionForTestsProject(projects, projectVersion,
|
||||
releaseTrainVersion);
|
||||
updateWithVersions(file, newProjects);
|
||||
this.projectCommandExecutor.build(projectVersion, file.getAbsolutePath());
|
||||
this.projectCommandExecutor.build(projectVersion, projectVersion,
|
||||
file.getAbsolutePath());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,8 +172,9 @@ public class PostReleaseActions implements Closeable {
|
||||
File clonedProject = this.projectGitHandler
|
||||
.cloneProjectFromOrg(processedProject.projectName());
|
||||
this.projectGitHandler.checkout(clonedProject, tagName);
|
||||
projectBuilder(processedProject)
|
||||
.deployGuides(processedProject.newProjectVersion);
|
||||
projectBuilder(processedProject).deployGuides(
|
||||
processedProject.originalProjectVersion,
|
||||
processedProject.newProjectVersion);
|
||||
})))
|
||||
.map(this::getSingleResult).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -37,24 +37,35 @@ public class ProcessedProject {
|
||||
*/
|
||||
public final ProjectVersion newProjectVersion;
|
||||
|
||||
/**
|
||||
* Version before updating.
|
||||
*/
|
||||
public final ProjectVersion originalProjectVersion;
|
||||
|
||||
public ProcessedProject(ReleaserProperties propertiesForProject,
|
||||
ProjectVersion newProjectVersion) {
|
||||
ProjectVersion newProjectVersion, ProjectVersion originalProjectVersion) {
|
||||
this.propertiesForProject = propertiesForProject;
|
||||
this.newProjectVersion = newProjectVersion;
|
||||
this.originalProjectVersion = originalProjectVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProcessedProject{" + "name=" + projectName() + ",version="
|
||||
+ projectVersion() + '}';
|
||||
return "ProcessedProject{" + "name=" + this.newProjectVersion.projectName
|
||||
+ ",version=" + this.newProjectVersion.version + '}'
|
||||
+ ",originalProjectVersion=" + this.originalProjectVersion + '}';
|
||||
}
|
||||
|
||||
public String projectName() {
|
||||
return this.newProjectVersion.projectName;
|
||||
}
|
||||
|
||||
private String projectVersion() {
|
||||
return this.newProjectVersion.version;
|
||||
}
|
||||
|
||||
public String newVersion() {
|
||||
return this.newProjectVersion.version;
|
||||
}
|
||||
|
||||
public String originalVersion() {
|
||||
return this.originalProjectVersion.version;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,6 +52,10 @@ public class ProjectCommandExecutor implements ReleaserPropertiesAware {
|
||||
|
||||
private static final String VERSION_MUSTACHE = "{{version}}";
|
||||
|
||||
private static final String OLD_VERSION_MUSTACHE = "{{oldVersion}}";
|
||||
|
||||
private static final String NEXT_VERSION_MUSTACHE = "{{nextVersion}}";
|
||||
|
||||
private ReleaserProperties properties;
|
||||
|
||||
public ProjectCommandExecutor(ReleaserProperties properties) {
|
||||
@@ -63,8 +67,9 @@ public class ProjectCommandExecutor implements ReleaserPropertiesAware {
|
||||
this.properties = new ReleaserProperties();
|
||||
}
|
||||
|
||||
public void build(ProjectVersion versionFromReleaseTrain) {
|
||||
build(versionFromReleaseTrain, this.properties.getWorkingDir());
|
||||
public void build(ProjectVersion originalVersion,
|
||||
ProjectVersion versionFromReleaseTrain) {
|
||||
build(originalVersion, versionFromReleaseTrain, this.properties.getWorkingDir());
|
||||
}
|
||||
|
||||
public String version() {
|
||||
@@ -93,10 +98,13 @@ public class ProjectCommandExecutor implements ReleaserPropertiesAware {
|
||||
}
|
||||
}
|
||||
|
||||
public void build(ProjectVersion versionFromReleaseTrain, String projectRoot) {
|
||||
public void build(ProjectVersion originalVersion,
|
||||
ProjectVersion versionFromReleaseTrain, String projectRoot) {
|
||||
try {
|
||||
String[] commands = new CommandPicker(this.properties, projectRoot)
|
||||
.buildCommand(versionFromReleaseTrain).split(" ");
|
||||
String command = new CommandPicker(this.properties, projectRoot)
|
||||
.buildCommand(versionFromReleaseTrain);
|
||||
String[] commands = replaceAllPlaceHolders(originalVersion,
|
||||
versionFromReleaseTrain, command).split(" ");
|
||||
runCommand(projectRoot, commands);
|
||||
assertNoHtmlFilesInDocsContainUnresolvedTags(projectRoot);
|
||||
log.info("No HTML files from docs contain unresolved tags");
|
||||
@@ -134,19 +142,24 @@ public class ProjectCommandExecutor implements ReleaserPropertiesAware {
|
||||
}
|
||||
}
|
||||
|
||||
public void deploy(ProjectVersion version) {
|
||||
doDeploy(new CommandPicker(properties, this.properties.getWorkingDir())
|
||||
.deployCommand(version));
|
||||
public void deploy(ProjectVersion originalVersion, ProjectVersion version) {
|
||||
doDeploy(originalVersion, version,
|
||||
new CommandPicker(properties, this.properties.getWorkingDir())
|
||||
.deployCommand(version));
|
||||
}
|
||||
|
||||
public void deployGuides(ProjectVersion version) {
|
||||
doDeploy(new CommandPicker(properties, this.properties.getWorkingDir())
|
||||
.deployGuidesCommand(version));
|
||||
public void deployGuides(ProjectVersion originalVersion, ProjectVersion version) {
|
||||
doDeploy(originalVersion, version,
|
||||
new CommandPicker(properties, this.properties.getWorkingDir())
|
||||
.deployGuidesCommand(version));
|
||||
}
|
||||
|
||||
private void doDeploy(String command) {
|
||||
private void doDeploy(ProjectVersion originalVersion, ProjectVersion changedVersion,
|
||||
String command) {
|
||||
try {
|
||||
String[] commands = command.split(" ");
|
||||
String replacedCommand = replaceAllPlaceHolders(originalVersion,
|
||||
changedVersion, command);
|
||||
String[] commands = replacedCommand.split(" ");
|
||||
runCommand(commands);
|
||||
log.info("The project has successfully been deployed");
|
||||
}
|
||||
@@ -170,10 +183,12 @@ public class ProjectCommandExecutor implements ReleaserPropertiesAware {
|
||||
return new ProcessExecutor(workDir);
|
||||
}
|
||||
|
||||
public void publishDocs(String version) {
|
||||
public void publishDocs(ProjectVersion originalVersion,
|
||||
ProjectVersion changedVersion) {
|
||||
try {
|
||||
for (String command : new CommandPicker(properties).publishDocsCommands()) {
|
||||
command = command.replace(VERSION_MUSTACHE, version);
|
||||
command = replaceAllPlaceHolders(originalVersion, changedVersion,
|
||||
command);
|
||||
String[] commands = command.split(" ");
|
||||
runCommand(commands);
|
||||
}
|
||||
@@ -184,6 +199,13 @@ public class ProjectCommandExecutor implements ReleaserPropertiesAware {
|
||||
}
|
||||
}
|
||||
|
||||
private String replaceAllPlaceHolders(ProjectVersion originalVersion,
|
||||
ProjectVersion changedVersion, String command) {
|
||||
return command.replace(VERSION_MUSTACHE, changedVersion.version)
|
||||
.replace(NEXT_VERSION_MUSTACHE, changedVersion.bumpedVersion())
|
||||
.replace(OLD_VERSION_MUSTACHE, originalVersion.version);
|
||||
}
|
||||
|
||||
/**
|
||||
* We need to insert the system properties as a list of -Dkey=value entries instead of
|
||||
* just pasting the String that contains these values.
|
||||
|
||||
@@ -333,13 +333,13 @@ public class PostReleaseActionsTests {
|
||||
ProjectVersion projectVersion = new ProjectVersion(
|
||||
new File(projects, "spring-cloud-release"));
|
||||
|
||||
actions.deployGuides(Collections
|
||||
.singletonList(new ProcessedProject(this.properties, projectVersion)));
|
||||
actions.deployGuides(Collections.singletonList(
|
||||
new ProcessedProject(this.properties, projectVersion, projectVersion)));
|
||||
|
||||
Awaitility.await().untilAsserted(() -> {
|
||||
BDDAssertions.then(projectBuilderStub.get()).isNotNull();
|
||||
BDDMockito.then(projectBuilderStub.get()).should()
|
||||
.deployGuides(projectVersion);
|
||||
.deployGuides(projectVersion, projectVersion);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
builder.build(original(), new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("resolved.log");
|
||||
@@ -90,7 +90,7 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(new File("/foo/bar").getAbsolutePath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"),
|
||||
builder.build(original(), new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"),
|
||||
tmpFile("/builder/resolved").getPath());
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
@@ -105,7 +105,7 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.M1"));
|
||||
builder.build(original(), new ProjectVersion("foo", "1.0.0.M1"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log"))).contains("foo");
|
||||
}
|
||||
@@ -118,7 +118,7 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.RC1"));
|
||||
builder.build(original(), new ProjectVersion("foo", "1.0.0.RC1"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log"))).contains("foo")
|
||||
.doesNotContain("-Pguides");
|
||||
@@ -132,7 +132,7 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.RELEASE"));
|
||||
builder.build(original(), new ProjectVersion("foo", "1.0.0.RELEASE"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log"))).contains("foo");
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.SR1"));
|
||||
builder.build(original(), new ProjectVersion("foo", "1.0.0.SR1"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log"))).contains("foo");
|
||||
}
|
||||
@@ -159,7 +159,7 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
builder.build(original(), new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("-Dhello=world -Dfoo=bar");
|
||||
@@ -173,7 +173,7 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
builder.build(original(), new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log"))).contains("foo");
|
||||
}
|
||||
@@ -187,7 +187,7 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
builder.build(original(), new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("hello=world foo=bar");
|
||||
@@ -202,7 +202,7 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
builder.build(original(), new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("-Dhello=world -Dfoo=bar bar");
|
||||
@@ -217,7 +217,7 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
builder.build(original(), new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("bar -Dhello=world -Dfoo=bar");
|
||||
@@ -230,10 +230,9 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/unresolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
thenThrownBy(
|
||||
() -> builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT")))
|
||||
.hasMessageContaining(
|
||||
"contains a tag that wasn't resolved properly");
|
||||
thenThrownBy(() -> builder.build(original(),
|
||||
new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"))).hasMessageContaining(
|
||||
"contains a tag that wasn't resolved properly");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -244,10 +243,9 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/unresolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
thenThrownBy(
|
||||
() -> builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT")))
|
||||
.hasMessageContaining(
|
||||
"Process waiting time of [0] minutes exceeded");
|
||||
thenThrownBy(() -> builder.build(original(),
|
||||
new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"))).hasMessageContaining(
|
||||
"Process waiting time of [0] minutes exceeded");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -257,7 +255,7 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
builder.deploy(original(), new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("resolved.log");
|
||||
@@ -271,7 +269,7 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.M1"));
|
||||
builder.deploy(original(), new ProjectVersion("foo", "1.0.0.M1"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log"))).contains("foo")
|
||||
.doesNotContain("-Pguides");
|
||||
@@ -287,7 +285,7 @@ public class ProjectCommandExecutorTests {
|
||||
.runCommand(new String[] { "touch", "pom.xml" }, 1);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.M1"));
|
||||
builder.deploy(original(), new ProjectVersion("foo", "1.0.0.M1"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("foo -Pmilestone").doesNotContain("-Pguides");
|
||||
@@ -301,7 +299,7 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.RC1"));
|
||||
builder.deploy(original(), new ProjectVersion("foo", "1.0.0.RC1"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log"))).contains("foo")
|
||||
.doesNotContain("-Pguides");
|
||||
@@ -317,7 +315,7 @@ public class ProjectCommandExecutorTests {
|
||||
.runCommand(new String[] { "touch", "pom.xml" }, 1);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.RC1"));
|
||||
builder.deploy(original(), new ProjectVersion("foo", "1.0.0.RC1"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("foo -Pmilestone").doesNotContain("-Pguides");
|
||||
@@ -331,7 +329,7 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.RELEASE"));
|
||||
builder.deploy(original(), new ProjectVersion("foo", "1.0.0.RELEASE"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log"))).contains("foo");
|
||||
}
|
||||
@@ -346,7 +344,7 @@ public class ProjectCommandExecutorTests {
|
||||
.runCommand(new String[] { "touch", "pom.xml" }, 1);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.RELEASE"));
|
||||
builder.deploy(original(), new ProjectVersion("foo", "1.0.0.RELEASE"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("foo -Pcentral");
|
||||
@@ -360,7 +358,7 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.SR1"));
|
||||
builder.deploy(original(), new ProjectVersion("foo", "1.0.0.SR1"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log"))).contains("foo");
|
||||
}
|
||||
@@ -374,7 +372,7 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
builder.deploy(original(), new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("-Dhello=hello-world");
|
||||
@@ -389,7 +387,7 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
builder.deploy(original(), new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("-Dhello=hello-world");
|
||||
@@ -403,16 +401,16 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/unresolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
thenThrownBy(
|
||||
() -> builder.deploy(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT")))
|
||||
.hasMessageContaining(
|
||||
"Process waiting time of [0] minutes exceeded");
|
||||
thenThrownBy(() -> builder.deploy(original(),
|
||||
new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"))).hasMessageContaining(
|
||||
"Process waiting time of [0] minutes exceeded");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_successfully_execute_a_publish_docs_command() throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getBash().setPublishDocsCommands(new String[] { "ls -al", "ls -al" });
|
||||
properties.getBash().setPublishDocsCommands(new String[] { "ls -al",
|
||||
"echo {{version}} {{oldVersion}} {{nextVersion}}" });
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
TestProcessExecutor executor = testExecutor(properties.getWorkingDir());
|
||||
ProjectCommandExecutor builder = new ProjectCommandExecutor(properties) {
|
||||
@@ -422,10 +420,10 @@ public class ProjectCommandExecutorTests {
|
||||
}
|
||||
};
|
||||
|
||||
builder.publishDocs("");
|
||||
builder.publishDocs(original(), new ProjectVersion("foo", "1.0.0.RELEASE"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("resolved.log");
|
||||
.contains("1.0.0.RELEASE 0.100.0.BUILD-SNAPSHOT 1.0.1.RELEASE");
|
||||
then(executor.counter).isEqualTo(2);
|
||||
}
|
||||
|
||||
@@ -445,7 +443,7 @@ public class ProjectCommandExecutorTests {
|
||||
}
|
||||
};
|
||||
|
||||
builder.publishDocs("");
|
||||
builder.publishDocs(original(), new ProjectVersion("foo", "Finchley.RELEASE"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("-Dhello=world -Dfoo=bar 2");
|
||||
@@ -467,7 +465,7 @@ public class ProjectCommandExecutorTests {
|
||||
}
|
||||
};
|
||||
|
||||
builder.publishDocs("1.1.0.RELEASE");
|
||||
builder.publishDocs(original(), new ProjectVersion("foo", "1.1.0.RELEASE"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("1.1.0.RELEASE");
|
||||
@@ -503,8 +501,9 @@ public class ProjectCommandExecutorTests {
|
||||
properties.setWorkingDir(tmpFile("/builder/unresolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
thenThrownBy(() -> builder.publishDocs(""))
|
||||
.hasMessageContaining("Process waiting time of [0] minutes exceeded");
|
||||
thenThrownBy(() -> builder.publishDocs(original(),
|
||||
new ProjectVersion("foo", "1.0.0.RELEASE"))).hasMessageContaining(
|
||||
"Process waiting time of [0] minutes exceeded");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -524,10 +523,9 @@ public class ProjectCommandExecutorTests {
|
||||
}
|
||||
};
|
||||
|
||||
thenThrownBy(
|
||||
() -> builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT")))
|
||||
.hasMessageContaining(
|
||||
"The process has exited with exit code [1]");
|
||||
thenThrownBy(() -> builder.build(original(),
|
||||
new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"))).hasMessageContaining(
|
||||
"The process has exited with exit code [1]");
|
||||
}
|
||||
|
||||
private Process processWithInvalidExitCode() {
|
||||
@@ -580,6 +578,10 @@ public class ProjectCommandExecutorTests {
|
||||
return new String(Files.readAllBytes(file.toPath()));
|
||||
}
|
||||
|
||||
private ProjectVersion original() {
|
||||
return new ProjectVersion("foo", "0.100.0.BUILD-SNAPSHOT");
|
||||
}
|
||||
|
||||
class TestProcessExecutor extends ProcessExecutor {
|
||||
|
||||
int counter = 0;
|
||||
|
||||
@@ -68,8 +68,8 @@ class Args {
|
||||
this.originalVersion = originalVersion;
|
||||
this.versionFromBom = versionFromBom;
|
||||
this.properties = properties;
|
||||
this.processedProjects = Collections
|
||||
.singletonList(new ProcessedProject(properties, versionFromBom));
|
||||
this.processedProjects = Collections.singletonList(
|
||||
new ProcessedProject(properties, versionFromBom, originalVersion));
|
||||
this.interactive = interactive;
|
||||
this.taskType = taskType;
|
||||
this.applicationEventPublisher = applicationEventPublisher;
|
||||
|
||||
@@ -108,7 +108,8 @@ public class SpringReleaser {
|
||||
log.info("Successfully cloned the project [{}] to [{}]", project,
|
||||
clonedProjectFromOrg);
|
||||
ProjectsAndVersion projects = projects(clonedProjectFromOrg);
|
||||
return new ProcessedProject(properties, projects.versionFromBom);
|
||||
ProjectVersion original = new ProjectVersion(clonedProjectFromOrg);
|
||||
return new ProcessedProject(properties, projects.versionFromBom, original);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -155,9 +156,11 @@ public class SpringReleaser {
|
||||
clonedProjectFromOrg);
|
||||
ProjectsAndVersion projectsAndVersion;
|
||||
try {
|
||||
ProjectVersion original = new ProjectVersion(clonedProjectFromOrg);
|
||||
projectsAndVersion = processProject(options, clonedProjectFromOrg,
|
||||
TaskType.RELEASE);
|
||||
return new ProcessedProject(copy, projectsAndVersion.versionFromBom);
|
||||
return new ProcessedProject(copy, projectsAndVersion.versionFromBom,
|
||||
original);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("\n\n\nBUILD FAILED!!!\n\nException occurred for project <"
|
||||
|
||||
@@ -38,15 +38,17 @@ final class Tasks {
|
||||
args -> args.releaser.updateProjectFromBom(args.project, args.projects,
|
||||
args.versionFromBom));
|
||||
static Task BUILD_PROJECT = task("build", "b", "BUILD PROJECT", "Build the project",
|
||||
args -> args.releaser.buildProject(args.versionFromBom));
|
||||
args -> args.releaser.buildProject(args.originalVersion,
|
||||
args.versionFromBom));
|
||||
static Task COMMIT = task("commit", "c",
|
||||
"COMMITTING (ALL) AND PUSHING TAGS (NON-SNAPSHOTS)",
|
||||
"Commit, tag and push the tag",
|
||||
args -> args.releaser.commitAndPushTags(args.project, args.versionFromBom));
|
||||
static Task DEPLOY = task("deploy", "d", "ARTIFACT DEPLOYMENT",
|
||||
"Deploy the artifacts", args -> args.releaser.deploy(args.versionFromBom));
|
||||
"Deploy the artifacts",
|
||||
args -> args.releaser.deploy(args.originalVersion, args.versionFromBom));
|
||||
static Task PUBLISH_DOCS = task("docs", "o", "PUBLISHING DOCS", "Publish the docs",
|
||||
args -> args.releaser.publishDocs(args.versionFromBom));
|
||||
args -> args.releaser.publishDocs(args.originalVersion, args.versionFromBom));
|
||||
static Task SNAPSHOTS = task("snapshots", "s",
|
||||
"REVERTING CHANGES & BUMPING VERSION (RELEASE ONLY)",
|
||||
"Go back to snapshots and bump originalVersion by patch",
|
||||
|
||||
Reference in New Issue
Block a user