From 3c30011c42dfebfa33d6abc88794be7fb84f1f93 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Tue, 16 Oct 2018 19:01:09 +0200 Subject: [PATCH] WIP on BOM parametrization. Still needs to resovle sc-build and alike in BomParser --- README.adoc | 4 +- .../asciidoc/spring-cloud-release-tools.adoc | 9 ++- .../cloud/release/internal/Releaser.java | 3 +- .../release/internal/ReleaserProperties.java | 66 ++++++++++++++++--- .../internal/git/ProjectGitHandler.java | 7 +- ...SCReleasePomParser.java => BomParser.java} | 40 +++++------ .../internal/pom/ProjectPomUpdater.java | 8 +-- .../internal/PomUpdateAcceptanceTests.java | 13 ++-- ...omParserTests.java => BomParserTests.java} | 33 ++++++---- .../internal/spring/AcceptanceTests.java | 8 +-- 10 files changed, 120 insertions(+), 71 deletions(-) rename spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/{SCReleasePomParser.java => BomParser.java} (76%) rename spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/{SCReleasePomParserTests.java => BomParserTests.java} (73%) diff --git a/README.adoc b/README.adoc index bba41485..5af6183a 100644 --- a/README.adoc +++ b/README.adoc @@ -30,7 +30,7 @@ why this tool makes it easy to automate the release / dependency update process For a single project - Clones the Spring Cloud Release project and picks all versions (Boot + Cloud projects) -- Modifies the project versions with values from SC-Release +- Modifies the project versions with values from a BOM (e.g. for Spring Cloud it's Spring Cloud Release) * throws an exception when we bump versions to release and there's a SNAPSHOT version referenced in the POM - Performs the build and checks if the `docs` modules have properly created the documentation * throws an exception when in the `docs` module there's an unresolved tag in any HTML file @@ -278,7 +278,7 @@ train depends on projects that got already released. We default this list to `[s - `releaser.git.fetch-versions-from-git` - If `true` then should fill the map of versions from Git. If `false` then picks fixed versions - `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.release-train-bom-url` - URL to a project containing a BOM. Defaults to Spring Cloud Release Git repository: `https://github.com/spring-cloud/spring-cloud-release` - `releaser.git.documentation-url` - URL to the documentation Git repository. Defaults to `https://github.com/spring-cloud/spring-cloud-static` - `releaser.git.documentation-branch` - Branch to check out for the documentation project. Defaults to `gh-pages` - `releaser.git.update-documentation-repo` - If `true` then will update documentation repository with the `current` URL. Defaults to `true` diff --git a/docs/src/main/asciidoc/spring-cloud-release-tools.adoc b/docs/src/main/asciidoc/spring-cloud-release-tools.adoc index 37364dac..ac804c7d 100644 --- a/docs/src/main/asciidoc/spring-cloud-release-tools.adoc +++ b/docs/src/main/asciidoc/spring-cloud-release-tools.adoc @@ -20,7 +20,7 @@ why this tool makes it easy to automate the release / dependency update process For a single project - Clones the Spring Cloud Release project and picks all versions (Boot + Cloud projects) -- Modifies the project versions with values from SC-Release +- Modifies the project versions with values from a BOM (e.g. for Spring Cloud it's Spring Cloud Release) * throws an exception when we bump versions to release and there's a SNAPSHOT version referenced in the POM - Performs the build and checks if the `docs` modules have properly created the documentation * throws an exception when in the `docs` module there's an unresolved tag in any HTML file @@ -268,7 +268,7 @@ train depends on projects that got already released. We default this list to `[s - `releaser.git.fetch-versions-from-git` - If `true` then should fill the map of versions from Git. If `false` then picks fixed versions - `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.release-train-bom-url` - URL to a project containing a BOM. Defaults to Spring Cloud Release Git repository: `https://github.com/spring-cloud/spring-cloud-release` - `releaser.git.documentation-url` - URL to the documentation Git repository. Defaults to `https://github.com/spring-cloud/spring-cloud-static` - `releaser.git.documentation-branch` - Branch to check out for the documentation project. Defaults to `gh-pages` - `releaser.git.update-documentation-repo` - If `true` then will update documentation repository with the `current` URL. Defaults to `true` @@ -288,7 +288,10 @@ Defaults to the standard Spring Cloud wget and execution of ghpages. a project name. E.g. in `gradle.properties` you have `foo=1.0.0.BUILD-SNAPSHOT` and you would like `spring-cloud-contract` version to be set there. Just provide a mapping for the `gradle-props-substition` looking like this `foo=spring-cloud-contract` and the result (e.g for sc-contract version `2.0.0.RELEASE`) will be an updated `gradle.properties` with entry `foo=2.0.0.RELEASE` -- `releaser.pom.branch` - Which branch of Spring Cloud Release should be checked out. Defaults to "master", +- `releaser.pom.branch` - Which branch of Spring Cloud Release should be checked out. Defaults to `master`, +- `releaser.pom.pom-with-boot-starter-parent` - What is the location of the `pom.xml` that contains the `spring-boot-starter-parent` as its parent pom. Defaults to `spring-cloud-starter-parent/pom.xml`. +- `releaser.pom.this-train-bom` - What is the location of the `pom.xml` that contains all the versions for the release train. Defaults to `spring-cloud-dependencies/pom.xml`. +- `releaser.pom.bom-version-pattern` - Regular expression that will match the versions of projects in the BOM pom.xml. Defaults to `^(spring-cloud-.*)\.version$` - `releaser.pom.ignored-pom-regex` - List of regular expressions of ignored poms. Defaults to test projects and samples. Example: `"--releaser.pom.ignored-pom-regex=".{asterisk}\\.git/.{asterisk}$,.\{asterisk}spring-cloud-contract-maven-plugin/src/test/projects/.{asterisk}$,.{asterisk}spring-cloud-contract-maven-plugin/target/.{asterisk}$,.{asterisk}samples/standalone/[a-z]+/.{asterisk}$"` - `releaser.working-dir` - By default Releaser assumes running the program from the current working directory. diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/Releaser.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/Releaser.java index 63496916..edc129f4 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/Releaser.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/Releaser.java @@ -1,7 +1,6 @@ package org.springframework.cloud.release.internal; import java.io.File; -import java.lang.invoke.MethodHandles; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,7 +50,7 @@ public class Releaser { } public Projects retrieveVersionsFromSCRelease() { - return this.projectPomUpdater.retrieveVersionsFromSCRelease(); + return this.projectPomUpdater.retrieveVersionsFromReleaseTrainBom(); } public Projects fixedVersions() { diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserProperties.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserProperties.java index f9eebd2e..382a2409 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserProperties.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserProperties.java @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.regex.Pattern; import org.apache.commons.lang.SerializationUtils; @@ -139,7 +140,7 @@ public class ReleaserProperties implements Serializable { /** * URL to Spring Cloud Release Git repository */ - private String springCloudReleaseGitUrl = "https://github.com/spring-cloud/spring-cloud-release"; + private String releaseTrainBomUrl = "https://github.com/spring-cloud/spring-cloud-release"; /** * URL to the documentation Git repository @@ -192,12 +193,12 @@ public class ReleaserProperties implements Serializable { */ private boolean updateSpringGuides = true; - public String getSpringCloudReleaseGitUrl() { - return this.springCloudReleaseGitUrl; + public String getReleaseTrainBomUrl() { + return this.releaseTrainBomUrl; } - public void setSpringCloudReleaseGitUrl(String springCloudReleaseGitUrl) { - this.springCloudReleaseGitUrl = springCloudReleaseGitUrl; + public void setReleaseTrainBomUrl(String releaseTrainBomUrl) { + this.releaseTrainBomUrl = releaseTrainBomUrl; } public String getDocumentationUrl() { @@ -283,7 +284,7 @@ public class ReleaserProperties implements Serializable { @Override public String toString() { return "Git{" + - "springCloudReleaseGitUrl='" + this.springCloudReleaseGitUrl + '\'' + + "releaseTrainBomUrl='" + this.releaseTrainBomUrl + '\'' + ", documentationUrl='" + this.documentationUrl + '\'' + ", documentationBranch='" + this.documentationBranch + '\'' + ", updateDocumentationRepo=" + this.updateDocumentationRepo + @@ -299,10 +300,25 @@ public class ReleaserProperties implements Serializable { public static class Pom implements Serializable { /** - * Which branch of Spring Cloud Release should be checked out. Defaults to {@code master} + * Which branch of release train BOM should be checked out. Defaults to {@code master} */ private String branch = "master"; + /** + * Subfolder of the pom that contains the {@code spring-boot-starer-parent} dependency + */ + private String pomWithBootStarterParent = "spring-cloud-starter-parent/pom.xml"; + + /** + * Subfolder of the pom that contains the versions for the release train + */ + private String thisTrainBom = "spring-cloud-dependencies/pom.xml"; + + /** + * The pattern to match a version property in a BOM + */ + private String bomVersionPattern = "^(spring-cloud-.*)\\.version$"; + /** * List of regular expressions of ignored poms. Defaults to test projects and samples. */ @@ -330,9 +346,39 @@ public class ReleaserProperties implements Serializable { this.ignoredPomRegex = ignoredPomRegex; } - @Override public String toString() { - return "Pom{" + "branch='" + this.branch + '\'' + ", ignoredPomRegex=" - + this.ignoredPomRegex + '}'; + public String getPomWithBootStarterParent() { + return this.pomWithBootStarterParent; + } + + public void setPomWithBootStarterParent(String pomWithBootStarterParent) { + this.pomWithBootStarterParent = pomWithBootStarterParent; + } + + public String getThisTrainBom() { + return this.thisTrainBom; + } + + public void setThisTrainBom(String thisTrainBom) { + this.thisTrainBom = thisTrainBom; + } + + public String getBomVersionPattern() { + return this.bomVersionPattern; + } + + public void setBomVersionPattern(String bomVersionPattern) { + this.bomVersionPattern = bomVersionPattern; + } + + @Override + public String toString() { + return "Pom{" + + "branch='" + this.branch + '\'' + + ", pomWithBootStarterParent='" + this.pomWithBootStarterParent + '\'' + + ", thisTrainBom='" + this.thisTrainBom + '\'' + + ", bomVersionPattern='" + this.bomVersionPattern + '\'' + + ", ignoredPomRegex=" + this.ignoredPomRegex + + '}'; } } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/ProjectGitHandler.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/ProjectGitHandler.java index c9b11d8d..5d81d8e1 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/ProjectGitHandler.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/ProjectGitHandler.java @@ -1,9 +1,6 @@ package org.springframework.cloud.release.internal.git; import java.io.File; -import java.lang.invoke.MethodHandles; -import java.net.URI; -import java.net.URL; import java.nio.file.Files; import org.eclipse.jgit.transport.URIish; @@ -67,8 +64,8 @@ public class ProjectGitHandler implements ReleaserPropertiesAware { gitRepo.commit(message); } - public File cloneScReleaseProject() { - return cloneProject(this.properties.getGit().getSpringCloudReleaseGitUrl()); + public File cloneReleaseTrainProject() { + return cloneProject(this.properties.getGit().getReleaseTrainBomUrl()); } public File cloneDocumentationProject() { 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/BomParser.java similarity index 76% rename from spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/SCReleasePomParser.java rename to spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/BomParser.java index 03cfd4c2..1a5d68d3 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/BomParser.java @@ -16,7 +16,6 @@ package org.springframework.cloud.release.internal.pom; import java.io.File; -import java.lang.invoke.MethodHandles; import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -30,32 +29,29 @@ import org.apache.maven.model.Model; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.cloud.release.internal.ReleaserProperties; + /** * Parses the poms for a given project and populates versions from Spring Cloud Release * * @author Marcin Grzejszczak */ -class SCReleasePomParser { +class BomParser { - private static final Logger log = LoggerFactory.getLogger(SCReleasePomParser.class); + private static final Logger log = LoggerFactory.getLogger(BomParser.class); - private static final String STARTER_POM = "spring-cloud-starter-parent/pom.xml"; - private static final String DEPENDENCIES_POM = "spring-cloud-dependencies/pom.xml"; - private static final Pattern SC_VERSION_PATTERN = Pattern.compile("^(spring-cloud-.*)\\.version$"); - - private final File springCloudReleaseDir; - private final String bootPom; - private final String dependenciesPomPath; + private final File thisProjectRoot; + private final String pomWithBootStarterParent; + private final String thisTrainBom; private final PomReader pomReader = new PomReader(); + private final Pattern versionPattern; - SCReleasePomParser(File springCloudReleaseDir) { - this(springCloudReleaseDir, STARTER_POM, DEPENDENCIES_POM); - } - SCReleasePomParser(File springCloudReleaseDir, String bootPom, String dependenciesPom) { - this.springCloudReleaseDir = springCloudReleaseDir; - this.bootPom = bootPom; - this.dependenciesPomPath = dependenciesPom; + BomParser( ReleaserProperties properties, File thisProjectRoot) { + this.thisProjectRoot = thisProjectRoot; + this.pomWithBootStarterParent = properties.getPom().getPomWithBootStarterParent(); + this.thisTrainBom = properties.getPom().getThisTrainBom(); + this.versionPattern = Pattern.compile(properties.getPom().getBomVersionPattern()); } Versions allVersions() { @@ -72,7 +68,7 @@ class SCReleasePomParser { } Versions bootVersion() { - Model model = pom(this.bootPom); + Model model = pom(this.pomWithBootStarterParent); String bootArtifactId = model.getParent().getArtifactId(); log.debug("Boot artifact id is equal to [{}]", bootArtifactId); if (!SpringCloudConstants.BOOT_STARTER_PARENT_ARTIFACT_ID.equals(bootArtifactId)) { @@ -88,7 +84,7 @@ class SCReleasePomParser { if (pom == null) { throw new IllegalStateException("Pom is not present"); } - File pomFile = new File(this.springCloudReleaseDir, pom); + File pomFile = new File(this.thisProjectRoot, pom); if (!pomFile.exists()) { throw new IllegalStateException("Pom is not present"); } @@ -96,7 +92,7 @@ class SCReleasePomParser { } Versions springCloudVersions() { - Model model = pom(this.dependenciesPomPath); + Model model = pom(this.thisTrainBom); String buildArtifact = model.getParent().getArtifactId(); log.debug("[{}] artifact id is equal to [{}]", SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildArtifact); if (!SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID.equals(buildArtifact)) { @@ -116,12 +112,12 @@ class SCReleasePomParser { } private Predicate> propertyMatchesSCPattern() { - return entry -> SC_VERSION_PATTERN.matcher(entry.getKey().toString()).matches(); + return entry -> this.versionPattern.matcher(entry.getKey().toString()).matches(); } private Function, Project> toProject() { return entry -> { - Matcher matcher = SC_VERSION_PATTERN.matcher(entry.getKey().toString()); + Matcher matcher = this.versionPattern.matcher(entry.getKey().toString()); // you have to first match to get info about the group matcher.matches(); String name = matcher.group(1); diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectPomUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectPomUpdater.java index 758ecccd..81674973 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectPomUpdater.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectPomUpdater.java @@ -24,10 +24,8 @@ import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.Scanner; import java.util.Set; -import java.util.function.Function; import java.util.stream.Collectors; import org.slf4j.Logger; @@ -62,10 +60,10 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware { * For the given root folder (typically the working directory) retrieves list of versions * for a given release version. */ - public Projects retrieveVersionsFromSCRelease() { - File clonedScRelease = this.gitRepo.cloneScReleaseProject(); + public Projects retrieveVersionsFromReleaseTrainBom() { + File clonedScRelease = this.gitRepo.cloneReleaseTrainProject(); this.gitRepo.checkout(clonedScRelease, this.properties.getPom().getBranch()); - SCReleasePomParser sCReleasePomParser = new SCReleasePomParser(clonedScRelease); + BomParser sCReleasePomParser = new BomParser(this.properties, clonedScRelease); Versions versions = sCReleasePomParser.allVersions(); log.info("Will update the following versions manually [{}]", this.properties.getFixedVersions()); this.properties.getFixedVersions().forEach(versions::setVersion); diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/PomUpdateAcceptanceTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/PomUpdateAcceptanceTests.java index b6ddbc3c..4e6be06b 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/PomUpdateAcceptanceTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/PomUpdateAcceptanceTests.java @@ -4,7 +4,6 @@ import java.io.File; import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.Files; -import java.util.HashSet; import org.apache.maven.model.Model; import org.assertj.core.api.BDDAssertions; @@ -42,7 +41,7 @@ public class PomUpdateAcceptanceTests { ReleaserProperties releaserProperties = releaserProperties(); releaserProperties.getFixedVersions().put("checkstyle", "100.0.0.RELEASE"); ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties); - Projects projects = projectPomUpdater.retrieveVersionsFromSCRelease(); + Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom(); File project = new File(this.temporaryFolder, "/spring-cloud-sleuth"); projectPomUpdater @@ -70,7 +69,7 @@ public class PomUpdateAcceptanceTests { public void should_not_fail_when_after_updating_a_release_version_there_still_is_a_snapshot_version() throws Exception { ReleaserProperties releaserProperties = branchReleaserProperties(); ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties); - Projects projects = projectPomUpdater.retrieveVersionsFromSCRelease(); + Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom(); projects.add(new ProjectVersion("spring-cloud-sleuth-samples", "0.0.5.RELEASE")); File project = new File(this.temporaryFolder, "/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-samples"); addBuildSnapshotToChildPom(project); @@ -89,7 +88,7 @@ public class PomUpdateAcceptanceTests { public void should_not_fail_update_when_after_updating_a_release_version_there_still_is_a_snapshot_version_in_a_non_deployable_module() throws Exception { ReleaserProperties releaserProperties = branchReleaserProperties(); ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties); - Projects projects = projectPomUpdater.retrieveVersionsFromSCRelease(); + Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom(); File project = new File(this.temporaryFolder, "/spring-cloud-sleuth-with-unmatched-property"); BDDAssertions.thenThrownBy(() -> @@ -102,7 +101,7 @@ public class PomUpdateAcceptanceTests { public void should_update_fail_when_after_updating_a_release_version_there_still_is_a_snapshot_version_for_boot_snapshot_version() throws Exception { ReleaserProperties releaserProperties = branchReleaserProperties(); ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties); - Projects projects = projectPomUpdater.retrieveVersionsFromSCRelease(); + Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom(); projects.removeIf(projectVersion -> projectVersion.projectName.contains("spring-cloud-build")); projects.add(new ProjectVersion("spring-cloud-build", "1.4.2.BUILD-SNAPSHOT")); File project = new File(this.temporaryFolder, "/spring-cloud-sleuth"); @@ -118,7 +117,7 @@ public class PomUpdateAcceptanceTests { ReleaserProperties releaserProperties = releaserProperties(); ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties); File beforeProcessing = pom("/projects/project/"); - Projects projects = projectPomUpdater.retrieveVersionsFromSCRelease(); + Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom(); File project = tmpFile("/project/"); projectPomUpdater.updateProjectFromSCRelease(project, projects, @@ -131,7 +130,7 @@ public class PomUpdateAcceptanceTests { private ReleaserProperties releaserProperties() throws URISyntaxException { ReleaserProperties releaserProperties = new ReleaserProperties(); - releaserProperties.getGit().setSpringCloudReleaseGitUrl(file("/projects/spring-cloud-release/").toURI().toString()); + releaserProperties.getGit().setReleaseTrainBomUrl(file("/projects/spring-cloud-release/").toURI().toString()); return releaserProperties; } diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/SCReleasePomParserTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/BomParserTests.java similarity index 73% rename from spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/SCReleasePomParserTests.java rename to spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/BomParserTests.java index 33c14868..85d81368 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/SCReleasePomParserTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/pom/BomParserTests.java @@ -6,6 +6,8 @@ import java.net.URISyntaxException; import org.junit.Before; import org.junit.Test; + +import org.springframework.cloud.release.internal.ReleaserProperties; import org.springframework.cloud.release.internal.git.GitRepoTests; import static org.assertj.core.api.BDDAssertions.then; @@ -14,9 +16,10 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy; /** * @author Marcin Grzejszczak */ -public class SCReleasePomParserTests { +public class BomParserTests { File springCloudReleaseProject; + ReleaserProperties properties = new ReleaserProperties(); @Before public void setup() throws IOException, URISyntaxException { @@ -25,7 +28,7 @@ public class SCReleasePomParserTests { @Test public void should_throw_exception_when_boot_pom_is_missing() { - SCReleasePomParser parser = new SCReleasePomParser(new File(".")); + BomParser parser = new BomParser(this.properties, new File(".")); thenThrownBy(parser::bootVersion) .isInstanceOf(IllegalStateException.class) @@ -34,7 +37,9 @@ public class SCReleasePomParserTests { @Test public void should_throw_exception_when_null_is_passed_to_boot() { - SCReleasePomParser parser = new SCReleasePomParser(this.springCloudReleaseProject, null, null); + this.properties.getPom().setPomWithBootStarterParent(null); + this.properties.getPom().setThisTrainBom(null); + BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject); thenThrownBy(parser::bootVersion) .isInstanceOf(IllegalStateException.class) @@ -43,7 +48,9 @@ public class SCReleasePomParserTests { @Test public void should_throw_exception_when_boot_version_is_missing_in_pom() { - SCReleasePomParser parser = new SCReleasePomParser(this.springCloudReleaseProject, "pom.xml", null); + this.properties.getPom().setPomWithBootStarterParent("pom.xml"); + this.properties.getPom().setThisTrainBom(null); + BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject); thenThrownBy(parser::bootVersion) .isInstanceOf(IllegalStateException.class) @@ -52,7 +59,7 @@ public class SCReleasePomParserTests { @Test public void should_populate_sc_release_version() { - SCReleasePomParser parser = new SCReleasePomParser(this.springCloudReleaseProject); + BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject); String scReleaseVersion = parser.allVersions().versionForProject("spring-cloud-release"); @@ -61,7 +68,7 @@ public class SCReleasePomParserTests { @Test public void should_populate_boot_version() { - SCReleasePomParser parser = new SCReleasePomParser(this.springCloudReleaseProject); + BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject); String bootVersion = parser.bootVersion().bootVersion; @@ -70,7 +77,7 @@ public class SCReleasePomParserTests { @Test public void should_throw_exception_when_cloud_pom_is_missing() { - SCReleasePomParser parser = new SCReleasePomParser(new File(".")); + BomParser parser = new BomParser(this.properties, new File(".")); thenThrownBy(parser::springCloudVersions) .isInstanceOf(IllegalStateException.class) @@ -79,7 +86,9 @@ public class SCReleasePomParserTests { @Test public void should_throw_exception_when_null_is_passed_to_cloud() { - SCReleasePomParser parser = new SCReleasePomParser(this.springCloudReleaseProject, null, null); + this.properties.getPom().setPomWithBootStarterParent(null); + this.properties.getPom().setThisTrainBom(null); + BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject); thenThrownBy(parser::springCloudVersions) .isInstanceOf(IllegalStateException.class) @@ -88,7 +97,9 @@ public class SCReleasePomParserTests { @Test public void should_throw_exception_when_cloud_version_is_missing_in_pom() { - SCReleasePomParser parser = new SCReleasePomParser(this.springCloudReleaseProject, null, "pom.xml"); + this.properties.getPom().setPomWithBootStarterParent(null); + this.properties.getPom().setThisTrainBom("pom.xml"); + BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject); thenThrownBy(parser::springCloudVersions) .isInstanceOf(IllegalStateException.class) @@ -97,7 +108,7 @@ public class SCReleasePomParserTests { @Test public void should_populate_cloud_version() { - SCReleasePomParser parser = new SCReleasePomParser(this.springCloudReleaseProject); + BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject); Versions cloudVersions = parser.springCloudVersions(); @@ -107,7 +118,7 @@ public class SCReleasePomParserTests { @Test public void should_populate_boot_and_cloud_version() { - SCReleasePomParser parser = new SCReleasePomParser(this.springCloudReleaseProject); + BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject); Versions cloudVersions = parser.allVersions(); diff --git a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/AcceptanceTests.java b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/AcceptanceTests.java index d8422b03..7601efc0 100644 --- a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/AcceptanceTests.java +++ b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/spring/AcceptanceTests.java @@ -633,7 +633,7 @@ public class AcceptanceTests { private ReleaserProperties releaserProperties(File project, String branch) throws URISyntaxException { ReleaserProperties releaserProperties = new ReleaserProperties(); - releaserProperties.getGit().setSpringCloudReleaseGitUrl(file("/projects/spring-cloud-release/").toURI().toString()); + releaserProperties.getGit().setReleaseTrainBomUrl(file("/projects/spring-cloud-release/").toURI().toString()); releaserProperties.getGit().setDocumentationUrl(file("/projects/spring-cloud-static-angel/").toURI().toString()); releaserProperties.getMaven().setBuildCommand("echo build"); releaserProperties.getMaven().setDeployCommand("echo deploy"); @@ -666,7 +666,7 @@ public class AcceptanceTests { private ReleaserProperties snapshotScReleaseReleaserProperties(File project, String branch) throws URISyntaxException { ReleaserProperties releaserProperties = releaserProperties(project, branch); - releaserProperties.getGit().setSpringCloudReleaseGitUrl(file("/projects/spring-cloud-release-with-snapshot/").toURI().toString()); + releaserProperties.getGit().setReleaseTrainBomUrl(file("/projects/spring-cloud-release-with-snapshot/").toURI().toString()); releaserProperties.getGit().setDocumentationUrl(file("/projects/spring-cloud-static/").toURI().toString()); this.releaserProperties = releaserProperties; return releaserProperties; @@ -725,8 +725,8 @@ public class AcceptanceTests { return "http://foo.bar.com/" + releaseVersion.toString(); } - @Override public File cloneScReleaseProject() { - File file = super.cloneScReleaseProject(); + @Override public File cloneReleaseTrainProject() { + File file = super.cloneReleaseTrainProject(); this.clonedProjects.add(file); return file; }