Added an option to pass versions manually
with this change it's enough to pass `releaser.fixed-versions` with a projectName->version mapping. This will override anything that came from spring cloud release fixes #16
This commit is contained in:
@@ -36,6 +36,8 @@ why this tool makes it easy to automate the release / dependency update process
|
||||
- Publishes the docs (to `spring-cloud-static` for non-snapshots, to `gh-pages` for snapshots)
|
||||
- Reverts back to snapshots, bumps the version by a patch (`1.0.1.RELEASE` -> `1.0.2.BUILD-SNAPSHOT`) (ONLY FOR RELEASE VERSIONS)
|
||||
- Closes the milestone on Github (e.g. `v1.0.1.RELEASE`) (ONLY FOR NON-SNAPSHOT VERSIONS)
|
||||
- Generates an email template under `target/email.txt` (ONLY FOR NON-SNAPSHOT VERSIONS)
|
||||
- Generates a blog template under `target/blog.md` (ONLY FOR NON-SNAPSHOT VERSIONS)
|
||||
|
||||
=== How to run it
|
||||
|
||||
@@ -58,6 +60,8 @@ TIP: It is important that you clone the repository you are going to release usi
|
||||
|
||||
=== Project options
|
||||
|
||||
- `releaser.fixed-versions` - A String to String mapping of manually set versions. E.g. `"spring-cloud-cli" -> "1.0.0.RELEASE"` will set
|
||||
the `spring-cloud-cli.version` to `1.0.0.RELEASE` regardless of what was set in `spring-cloud-release` project
|
||||
- `releaser.git.clone-destination-dir` - Where should the Spring Cloud Release repo get cloned to. If null defaults to a temporary directory
|
||||
- `releaser.git.spring-cloud-release-git-url` - URL to Spring Cloud Release Git repository. Defaults to `https://github.com/spring-cloud/spring-cloud-release`
|
||||
- `releaser.git.oauth-token` - GitHub OAuth token to be used to interact with GitHub repo.
|
||||
|
||||
@@ -26,6 +26,8 @@ why this tool makes it easy to automate the release / dependency update process
|
||||
- Publishes the docs (to `spring-cloud-static` for non-snapshots, to `gh-pages` for snapshots)
|
||||
- Reverts back to snapshots, bumps the version by a patch (`1.0.1.RELEASE` -> `1.0.2.BUILD-SNAPSHOT`) (ONLY FOR RELEASE VERSIONS)
|
||||
- Closes the milestone on Github (e.g. `v1.0.1.RELEASE`) (ONLY FOR NON-SNAPSHOT VERSIONS)
|
||||
- Generates an email template under `target/email.txt` (ONLY FOR NON-SNAPSHOT VERSIONS)
|
||||
- Generates a blog template under `target/blog.md` (ONLY FOR NON-SNAPSHOT VERSIONS)
|
||||
|
||||
=== How to run it
|
||||
|
||||
@@ -48,6 +50,8 @@ TIP: It is important that you clone the repository you are going to release usi
|
||||
|
||||
=== Project options
|
||||
|
||||
- `releaser.fixed-versions` - A String to String mapping of manually set versions. E.g. `"spring-cloud-cli" -> "1.0.0.RELEASE"` will set
|
||||
the `spring-cloud-cli.version` to `1.0.0.RELEASE` regardless of what was set in `spring-cloud-release` project
|
||||
- `releaser.git.clone-destination-dir` - Where should the Spring Cloud Release repo get cloned to. If null defaults to a temporary directory
|
||||
- `releaser.git.spring-cloud-release-git-url` - URL to Spring Cloud Release Git repository. Defaults to `https://github.com/spring-cloud/spring-cloud-release`
|
||||
- `releaser.git.oauth-token` - GitHub OAuth token to be used to interact with GitHub repo.
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
package org.springframework.cloud.release.internal;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -40,6 +42,8 @@ public class ReleaserProperties {
|
||||
|
||||
private Maven maven = new Maven();
|
||||
|
||||
private Map<String, String> fixedVersions = new HashMap<>();
|
||||
|
||||
public static class Git {
|
||||
|
||||
/**
|
||||
@@ -209,4 +213,12 @@ public class ReleaserProperties {
|
||||
public void setMaven(Maven maven) {
|
||||
this.maven = maven;
|
||||
}
|
||||
|
||||
public Map<String, String> getFixedVersions() {
|
||||
return this.fixedVersions;
|
||||
}
|
||||
|
||||
public void setFixedVersions(Map<String, String> fixedVersions) {
|
||||
this.fixedVersions = fixedVersions;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,8 @@ public class ProjectPomUpdater {
|
||||
SCReleasePomParser sCReleasePomParser = new SCReleasePomParser(clonedScRelease);
|
||||
Versions versions = sCReleasePomParser.allVersions();
|
||||
log.info("Retrieved the following versions\n{}", versions);
|
||||
log.info("Will update the following versions manually [{}]", this.properties.getFixedVersions());
|
||||
this.properties.getFixedVersions().forEach(versions::setVersion);
|
||||
return versions.toProjectVersions();
|
||||
}
|
||||
|
||||
|
||||
@@ -110,6 +110,35 @@ class Versions {
|
||||
return this.projects.stream().anyMatch(project -> project.version.endsWith("BUILD-SNAPSHOT"));
|
||||
}
|
||||
|
||||
Versions setVersion(String projectName, String version) {
|
||||
switch (projectName) {
|
||||
case SPRING_BOOT_PROJECT_NAME:
|
||||
case BOOT_STARTER_ARTIFACT_ID:
|
||||
this.bootVersion = version;
|
||||
remove(SPRING_BOOT_PROJECT_NAME);
|
||||
remove(BOOT_STARTER_ARTIFACT_ID);
|
||||
this.projects.add(new Project(SPRING_BOOT_PROJECT_NAME, version));
|
||||
this.projects.add(new Project(BOOT_STARTER_ARTIFACT_ID, version));
|
||||
break;
|
||||
case BUILD_ARTIFACT_ID:
|
||||
case CLOUD_DEPENDENCIES_ARTIFACT_ID:
|
||||
this.scBuildVersion = version;
|
||||
remove(BUILD_ARTIFACT_ID);
|
||||
remove(CLOUD_DEPENDENCIES_ARTIFACT_ID);
|
||||
this.projects.add(new Project(BUILD_ARTIFACT_ID, version));
|
||||
this.projects.add(new Project(CLOUD_DEPENDENCIES_ARTIFACT_ID, version));
|
||||
break;
|
||||
default:
|
||||
remove(projectName);
|
||||
this.projects.add(new Project(projectName, version));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private void remove(String expectedProjectName) {
|
||||
this.projects.removeIf(project -> expectedProjectName.equals(project.name));
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return "Spring Boot Version=[" + this.bootVersion + ']' + "\nSpring Cloud Build Version=["
|
||||
+ this.scBuildVersion + ']' + "\nProjects=\n\t" + this.projects.stream().map(Object::toString).collect(
|
||||
|
||||
@@ -38,6 +38,7 @@ public class PomUpdateAcceptanceTests {
|
||||
@Test
|
||||
public void should_update_all_versions_for_a_release_train() throws Exception {
|
||||
ReleaserProperties releaserProperties = releaserProperties();
|
||||
releaserProperties.getFixedVersions().put("checkstyle", "100.0.0.RELEASE");
|
||||
ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties);
|
||||
Projects projects = projectPomUpdater.retrieveVersionsFromSCRelease();
|
||||
|
||||
@@ -54,7 +55,8 @@ public class PomUpdateAcceptanceTests {
|
||||
.containsEntry("spring-cloud-build.version","1.3.1.BUILD-SNAPSHOT")
|
||||
.containsEntry("spring-cloud-commons.version","1.2.0.BUILD-SNAPSHOT")
|
||||
.containsEntry("spring-cloud-stream.version","Chelsea.BUILD-SNAPSHOT")
|
||||
.containsEntry("spring-cloud-netflix.version","1.3.0.BUILD-SNAPSHOT");
|
||||
.containsEntry("spring-cloud-netflix.version","1.3.0.BUILD-SNAPSHOT")
|
||||
.containsEntry("checkstyle.version","100.0.0.RELEASE");
|
||||
then(depsPom.getVersion()).isEqualTo("1.2.0.BUILD-SNAPSHOT");
|
||||
then(depsPom.getParent().getVersion()).isEqualTo("1.3.1.BUILD-SNAPSHOT");
|
||||
then(corePom.getParent().getVersion()).isEqualTo("1.2.0.BUILD-SNAPSHOT");
|
||||
|
||||
@@ -90,6 +90,43 @@ public class VersionsTests {
|
||||
then(new Versions("", mixedProjects()).isSnapshot()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_update_projects_for_boot() {
|
||||
Versions versions = mixedVersions().setVersion("spring-boot", "3.0.0");
|
||||
|
||||
then(versions.versionForProject("spring-boot")).isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-boot-starter-parent")).isEqualTo("3.0.0");
|
||||
|
||||
versions = mixedVersions().setVersion("spring-boot-starter-parent", "3.0.0");
|
||||
|
||||
then(versions.versionForProject("spring-boot")).isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-boot-starter-parent")).isEqualTo("3.0.0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_update_projects_for_build() {
|
||||
Versions versions = mixedVersions().setVersion("spring-cloud-build", "3.0.0");
|
||||
|
||||
then(versions.versionForProject("spring-cloud-build")).isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-cloud-dependencies-parent")).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");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_update_projects_for_custom_project() {
|
||||
Versions versions = mixedVersions().setVersion("foo", "3.0.0");
|
||||
|
||||
then(versions.versionForProject("foo")).isEqualTo("3.0.0");
|
||||
}
|
||||
|
||||
private Versions mixedVersions() {
|
||||
return new Versions("1.0.0", "2.0.0", mixedProjects());
|
||||
}
|
||||
|
||||
Set<Project> projects() {
|
||||
Set<Project> projects = new HashSet<>();
|
||||
projects.add(new Project("foo", "bar"));
|
||||
|
||||
Reference in New Issue
Block a user