From 997f4bd98f4d90cb592f8e3e03c5e67a61efc0b4 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Mon, 25 Jun 2018 15:13:13 +0200 Subject: [PATCH] Spring Cloud Release versions are automatically added upon version setting --- README.adoc | 13 +++++++++---- .../release/internal/pom/SCReleasePomParser.java | 7 ++++--- .../internal/pom/SpringCloudConstants.java | 5 ++++- .../cloud/release/internal/pom/Versions.java | 15 +++++++++++++++ .../cloud/release/internal/pom/VersionsTests.java | 15 +++++++++++++++ 5 files changed, 47 insertions(+), 8 deletions(-) diff --git a/README.adoc b/README.adoc index a93a8d2b..061b5ec6 100644 --- a/README.adoc +++ b/README.adoc @@ -152,7 +152,7 @@ You will see a help screen looking like more or less like this ---- Here you can find the list of tasks in order -[updatePoms,build,commit,deploy,docs,snapshots,push,closeMilestone,createTemplates,updateSagan,updateGuides,updateDocumentation] +[release,releaseVerbose,metaRelease,postRelease,updatePoms,build,commit,deploy,docs,snapshots,push,closeMilestone,updateSagan,createTemplates,updateGuides,updateDocumentation] Option Description @@ -164,12 +164,13 @@ Option Description -b, --build [String] Build the project -c, --commit [String] Commit, tag and push the tag -d, --deploy [String] Deploy the artifacts --f, --full-release [Boolean] Do you want to do the full release - (default: false) +-f, --full-release [Boolean] Do you want to do the full release of a + single project? (default: false) -g, --updateSagan [String] Updating Sagan with release info -h, --help [String] -i, --interactive Do you want to set the properties from - the command line (default: true) + the command line of a single project? + (default: true) -m, --closeMilestone [String] Close the milestone at Github -o, --docs [String] Publish the docs -p, --push [String] Push the commits @@ -182,10 +183,14 @@ Option Description -s, --snapshots [String] Go back to snapshots and bump originalVersion by patch -t, --createTemplates [String] Create email / blog / tweet etc. templates +--task-names, --tn Starts all release task for the given + task names -u, --updatePoms [String] Update poms with versions from Spring Cloud Release --ud, --updateDocumentation [String] Updating documentation repository --ug, --updateGuides [String] Updating Spring Guides +-x, --meta-release Do you want to do the meta release? + (default: false) Examples of usage: diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/SCReleasePomParser.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/SCReleasePomParser.java index 144445ec..fdcf2665 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/SCReleasePomParser.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/SCReleasePomParser.java @@ -98,9 +98,10 @@ class SCReleasePomParser { Versions springCloudVersions() { Model model = pom(this.dependenciesPomPath); String buildArtifact = model.getParent().getArtifactId(); - log.debug("[{}] artifact id is equal to [{}]", SpringCloudConstants.CLOUD_DEPENDENCIES_ARTIFACT_ID, buildArtifact); - if (!SpringCloudConstants.CLOUD_DEPENDENCIES_ARTIFACT_ID.equals(buildArtifact)) { - throw new IllegalStateException("The pom doesn't have a [" + SpringCloudConstants.CLOUD_DEPENDENCIES_ARTIFACT_ID + "] artifact id"); + log.debug("[{}] artifact id is equal to [{}]", SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildArtifact); + if (!SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID.equals(buildArtifact)) { + throw new IllegalStateException("The pom doesn't have a [" + SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID + + "] artifact id"); } String buildVersion = model.getParent().getVersion(); log.debug("Spring Cloud Build version is equal to [{}]", buildVersion); diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/SpringCloudConstants.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/SpringCloudConstants.java index a06a2927..f69b1020 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/SpringCloudConstants.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/SpringCloudConstants.java @@ -21,11 +21,14 @@ package org.springframework.cloud.release.internal.pom; */ final class SpringCloudConstants { static final String SPRING_BOOT = "spring-boot"; + static final String CLOUD_DEPENDENCIES_ARTIFACT_ID = "spring-cloud-dependencies"; static final String BOOT_STARTER_ARTIFACT_ID = "spring-boot-starter"; static final String BOOT_STARTER_PARENT_ARTIFACT_ID = BOOT_STARTER_ARTIFACT_ID + "-parent"; static final String BOOT_DEPENDENCIES_ARTIFACT_ID = "spring-boot-dependencies"; - static final String CLOUD_DEPENDENCIES_ARTIFACT_ID = "spring-cloud-dependencies-parent"; + static final String CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID = "spring-cloud-dependencies-parent"; static final String BUILD_ARTIFACT_ID = "spring-cloud-build"; + static final String SPRING_CLOUD_RELEASE = "spring-cloud-release"; + static final String SPRING_CLOUD = "spring-cloud"; private SpringCloudConstants() { throw new IllegalStateException("Don't instantiate a utility class"); diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Versions.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Versions.java index a48edeac..0f3aa54c 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Versions.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Versions.java @@ -23,7 +23,10 @@ import java.util.stream.Collectors; import static org.springframework.cloud.release.internal.pom.SpringCloudConstants.BOOT_DEPENDENCIES_ARTIFACT_ID; import static org.springframework.cloud.release.internal.pom.SpringCloudConstants.BOOT_STARTER_PARENT_ARTIFACT_ID; import static org.springframework.cloud.release.internal.pom.SpringCloudConstants.BUILD_ARTIFACT_ID; +import static org.springframework.cloud.release.internal.pom.SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID; import static org.springframework.cloud.release.internal.pom.SpringCloudConstants.CLOUD_DEPENDENCIES_ARTIFACT_ID; +import static org.springframework.cloud.release.internal.pom.SpringCloudConstants.SPRING_CLOUD; +import static org.springframework.cloud.release.internal.pom.SpringCloudConstants.SPRING_CLOUD_RELEASE; /** * Represents versions taken out from Spring Cloud Release pom @@ -49,6 +52,7 @@ class Versions { Versions(String scBuildVersion, Set projects) { this.scBuildVersion = scBuildVersion; this.projects.add(new Project(BUILD_ARTIFACT_ID, scBuildVersion)); + this.projects.add(new Project(CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, scBuildVersion)); this.projects.add(new Project(CLOUD_DEPENDENCIES_ARTIFACT_ID, scBuildVersion)); this.projects.addAll(projects); } @@ -61,6 +65,7 @@ class Versions { this.projects.add(new Project(BOOT_DEPENDENCIES_ARTIFACT_ID, bootVersion)); this.projects.add(new Project(BUILD_ARTIFACT_ID, scBuildVersion)); this.projects.add(new Project(CLOUD_DEPENDENCIES_ARTIFACT_ID, scBuildVersion)); + this.projects.add(new Project(CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, scBuildVersion)); this.projects.addAll(projects); } @@ -129,12 +134,22 @@ class Versions { break; case BUILD_ARTIFACT_ID: case CLOUD_DEPENDENCIES_ARTIFACT_ID: + case CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID: this.scBuildVersion = version; remove(BUILD_ARTIFACT_ID); + remove(CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID); remove(CLOUD_DEPENDENCIES_ARTIFACT_ID); this.projects.add(new Project(BUILD_ARTIFACT_ID, version)); + this.projects.add(new Project(CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, version)); this.projects.add(new Project(CLOUD_DEPENDENCIES_ARTIFACT_ID, version)); break; + case SPRING_CLOUD_RELEASE: + case SPRING_CLOUD: + remove(SPRING_CLOUD_RELEASE); + remove(SPRING_CLOUD); + this.projects.add(new Project(SPRING_CLOUD_RELEASE, version)); + this.projects.add(new Project(SPRING_CLOUD, version)); + break; default: remove(projectName); this.projects.add(new Project(projectName, version)); diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/VersionsTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/VersionsTests.java index 0b0a2270..d4ba917e 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/VersionsTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/VersionsTests.java @@ -108,11 +108,26 @@ public class VersionsTests { then(versions.versionForProject("spring-cloud-build")).isEqualTo("3.0.0"); then(versions.versionForProject("spring-cloud-dependencies-parent")).isEqualTo("3.0.0"); + then(versions.versionForProject("spring-cloud-dependencies")).isEqualTo("3.0.0"); versions = mixedVersions().setVersion("spring-cloud-dependencies-parent", "3.0.0"); then(versions.versionForProject("spring-cloud-build")).isEqualTo("3.0.0"); then(versions.versionForProject("spring-cloud-dependencies-parent")).isEqualTo("3.0.0"); + then(versions.versionForProject("spring-cloud-dependencies")).isEqualTo("3.0.0"); + } + + @Test + public void should_update_projects_for_spring_cloud_release() { + Versions versions = mixedVersions().setVersion("spring-cloud", "3.0.0"); + + then(versions.versionForProject("spring-cloud")).isEqualTo("3.0.0"); + then(versions.versionForProject("spring-cloud-release")).isEqualTo("3.0.0"); + + versions = mixedVersions().setVersion("spring-cloud-release", "3.0.0"); + + then(versions.versionForProject("spring-cloud")).isEqualTo("3.0.0"); + then(versions.versionForProject("spring-cloud-release")).isEqualTo("3.0.0"); } @Test