diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/buildsystem/BomConstants.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/buildsystem/SpringCloudBomConstants.java similarity index 94% rename from spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/buildsystem/BomConstants.java rename to spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/buildsystem/SpringCloudBomConstants.java index 442c8181..1a624311 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/buildsystem/BomConstants.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/buildsystem/SpringCloudBomConstants.java @@ -19,7 +19,7 @@ package org.springframework.cloud.release.cloud.buildsystem; /** * @author Marcin Grzejszczak */ -final class BomConstants { +final class SpringCloudBomConstants { static final String SPRING_BOOT = "spring-boot"; static final String BOOT_STARTER_ARTIFACT_ID = "spring-boot-starter"; @@ -29,7 +29,7 @@ final class BomConstants { static final String CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID = "spring-cloud-dependencies-parent"; static final String BUILD_ARTIFACT_ID = "spring-cloud-build"; - private BomConstants() { + private SpringCloudBomConstants() { throw new IllegalStateException("Don't instantiate a utility class"); } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/buildsystem/SpringCloudBomParser.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/buildsystem/SpringCloudMavenBomParser.java similarity index 80% rename from spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/buildsystem/SpringCloudBomParser.java rename to spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/buildsystem/SpringCloudMavenBomParser.java index 19fa47e5..ae79862d 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/buildsystem/SpringCloudBomParser.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/buildsystem/SpringCloudMavenBomParser.java @@ -29,29 +29,32 @@ import org.springframework.cloud.release.internal.buildsystem.CustomBomParser; import org.springframework.cloud.release.internal.buildsystem.PomReader; import org.springframework.cloud.release.internal.buildsystem.Project; import org.springframework.cloud.release.internal.buildsystem.VersionsFromBom; +import org.springframework.cloud.release.internal.buildsystem.VersionsFromBomBuilder; -import static org.springframework.cloud.release.cloud.buildsystem.BomConstants.BOOT_DEPENDENCIES_ARTIFACT_ID; -import static org.springframework.cloud.release.cloud.buildsystem.BomConstants.BOOT_STARTER_PARENT_ARTIFACT_ID; -import static org.springframework.cloud.release.cloud.buildsystem.BomConstants.BUILD_ARTIFACT_ID; -import static org.springframework.cloud.release.cloud.buildsystem.BomConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID; -import static org.springframework.cloud.release.cloud.buildsystem.BomConstants.SPRING_BOOT; +import static org.springframework.cloud.release.cloud.buildsystem.SpringCloudBomConstants.BOOT_DEPENDENCIES_ARTIFACT_ID; +import static org.springframework.cloud.release.cloud.buildsystem.SpringCloudBomConstants.BOOT_STARTER_PARENT_ARTIFACT_ID; +import static org.springframework.cloud.release.cloud.buildsystem.SpringCloudBomConstants.BUILD_ARTIFACT_ID; +import static org.springframework.cloud.release.cloud.buildsystem.SpringCloudBomConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID; +import static org.springframework.cloud.release.cloud.buildsystem.SpringCloudBomConstants.SPRING_BOOT; -public class SpringCloudBomParser implements CustomBomParser { +public class SpringCloudMavenBomParser implements CustomBomParser { - private static final Logger log = LoggerFactory.getLogger(SpringCloudBomParser.class); + private static final Logger log = LoggerFactory + .getLogger(SpringCloudMavenBomParser.class); @Override public boolean isApplicable(File root, ReleaserProperties properties, Set projects) { - return root.getName().startsWith("spring-cloud") || projects.stream() - .anyMatch(project -> BUILD_ARTIFACT_ID.equals(project.name)); + return isMaven(root) && root.getName().startsWith("spring-cloud") || projects + .stream().anyMatch(project -> BUILD_ARTIFACT_ID.equals(project.name)); } @Override public VersionsFromBom parseBom(File root, ReleaserProperties properties) { VersionsFromBom springCloudBuild = springCloudBuild(root, properties); VersionsFromBom boot = bootVersion(root, properties); - return new VersionsFromBom(properties, springCloudBuild, boot); + return new VersionsFromBomBuilder().releaserProperties(properties) + .projects(springCloudBuild, boot).versionsFromBom(); } private VersionsFromBom springCloudBuild(File root, ReleaserProperties properties) { @@ -65,7 +68,8 @@ public class SpringCloudBomParser implements CustomBomParser { } String buildVersion = model.getParent().getVersion(); log.debug("Spring Cloud Build version is equal to [{}]", buildVersion); - VersionsFromBom scBuild = new VersionsFromBom(properties); + VersionsFromBom scBuild = new VersionsFromBomBuilder() + .releaserProperties(properties).versionsFromBom(); scBuild.add(BUILD_ARTIFACT_ID, buildVersion); scBuild.add(CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildVersion); return scBuild; @@ -80,16 +84,17 @@ public class SpringCloudBomParser implements CustomBomParser { } String bootArtifactId = model.getParent().getArtifactId(); log.debug("Boot artifact id is equal to [{}]", bootArtifactId); - if (!BomConstants.BOOT_STARTER_PARENT_ARTIFACT_ID.equals(bootArtifactId)) { + if (!SpringCloudBomConstants.BOOT_STARTER_PARENT_ARTIFACT_ID.equals(bootArtifactId)) { if (log.isDebugEnabled()) { throw new IllegalStateException("The pom doesn't have a [" - + BomConstants.BOOT_STARTER_PARENT_ARTIFACT_ID + "] artifact id"); + + SpringCloudBomConstants.BOOT_STARTER_PARENT_ARTIFACT_ID + "] artifact id"); } return VersionsFromBom.EMPTY_VERSION; } String bootVersion = model.getParent().getVersion(); log.debug("Boot version is equal to [{}]", bootVersion); - VersionsFromBom versionsFromBom = new VersionsFromBom(properties); + VersionsFromBom versionsFromBom = new VersionsFromBomBuilder() + .releaserProperties(properties).versionsFromBom(); versionsFromBom.add(SPRING_BOOT, bootVersion); versionsFromBom.add(BOOT_STARTER_PARENT_ARTIFACT_ID, bootVersion); versionsFromBom.add(BOOT_DEPENDENCIES_ARTIFACT_ID, bootVersion); diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ProjectDocumentationUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/docs/SpringCloudCustomProjectDocumentationUpdater.java similarity index 87% rename from spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ProjectDocumentationUpdater.java rename to spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/docs/SpringCloudCustomProjectDocumentationUpdater.java index 081f9579..a01dc2e1 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ProjectDocumentationUpdater.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/cloud/docs/SpringCloudCustomProjectDocumentationUpdater.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cloud.release.internal.docs; +package org.springframework.cloud.release.cloud.docs; import java.io.File; import java.io.IOException; @@ -26,31 +26,36 @@ import org.slf4j.LoggerFactory; import org.springframework.cloud.release.internal.ReleaserProperties; import org.springframework.cloud.release.internal.ReleaserPropertiesAware; import org.springframework.cloud.release.internal.buildsystem.ProjectVersion; +import org.springframework.cloud.release.internal.docs.CustomProjectDocumentationUpdater; import org.springframework.cloud.release.internal.git.ProjectGitHandler; /** * @author Marcin Grzejszczak */ -// TODO: [SPRING-CLOUD] -class ProjectDocumentationUpdater implements ReleaserPropertiesAware { +class SpringCloudCustomProjectDocumentationUpdater implements CustomProjectDocumentationUpdater, ReleaserPropertiesAware { private static final String HTTP_SC_STATIC_URL = "http://cloud.spring.io/spring-cloud-static/"; private static final String HTTPS_SC_STATIC_URL = "https://cloud.spring.io/spring-cloud-static/"; private static final Logger log = LoggerFactory - .getLogger(ProjectDocumentationUpdater.class); + .getLogger(SpringCloudCustomProjectDocumentationUpdater.class); private final ProjectGitHandler gitHandler; private ReleaserProperties properties; - ProjectDocumentationUpdater(ReleaserProperties properties, + SpringCloudCustomProjectDocumentationUpdater(ReleaserProperties properties, ProjectGitHandler gitHandler) { this.gitHandler = gitHandler; this.properties = properties; } + @Override + public boolean isApplicable(File clonedDocumentationProject, ProjectVersion currentProject, String bomBranch) { + return clonedDocumentationProject.getName().startsWith("spring-cloud") || currentProject.projectName.startsWith("spring-cloud"); + } + /** * Updates the documentation repository if current release train version is greater or * equal than the one stored in the repo. @@ -59,7 +64,8 @@ class ProjectDocumentationUpdater implements ReleaserPropertiesAware { * @return {@link File cloned temporary directory} - {@code null} if wrong version is * used */ - File updateDocsRepo(ProjectVersion currentProject, String bomBranch) { + @Override + public File updateDocsRepo(File clonedDocumentationProject, ProjectVersion currentProject, String bomBranch) { if (!this.properties.getGit().isUpdateDocumentationRepo()) { log.info( "Will not update documentation repository, since the switch to do so " diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/BomParser.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/BomParser.java index 70410461..bbca4653 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/BomParser.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/BomParser.java @@ -21,7 +21,7 @@ import java.io.File; /** * Parses the bom and returns all parsed versions. */ -public interface BomParser { +interface BomParser { /** * @param clonedBom - location of the cloned BOM repository diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/CompositeBomParser.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/CompositeBomParser.java index 9331309c..1ab85176 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/CompositeBomParser.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/CompositeBomParser.java @@ -17,21 +17,19 @@ package org.springframework.cloud.release.internal.buildsystem; import java.io.File; - -import org.springframework.cloud.release.internal.ReleaserProperties; +import java.util.List; class CompositeBomParser implements BomParser { - private final ReleaserProperties properties; + private final List parsers; - CompositeBomParser(ReleaserProperties releaserProperties) { - this.properties = releaserProperties; + CompositeBomParser(List parsers) { + this.parsers = parsers; } @Override public boolean isApplicable(File clonedBom) { - return new MavenBomParser(this.properties).isApplicable(clonedBom) - || new GradleBomParser(this.properties).isApplicable(clonedBom); + return this.parsers.stream().anyMatch(b -> b.isApplicable(clonedBom)); } @Override @@ -40,11 +38,9 @@ class CompositeBomParser implements BomParser { } private BomParser firstMatching(File thisProjectRoot) { - BomParser gradle = new GradleBomParser(this.properties); - if (new GradleBomParser(this.properties).isApplicable(thisProjectRoot)) { - return gradle; - } - return new MavenBomParser(this.properties); + return this.parsers.stream().filter(b -> b.isApplicable(thisProjectRoot)) + .findFirst().orElseThrow( + () -> new IllegalStateException("Can't find a matching parser")); } } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/CustomBomParser.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/CustomBomParser.java index fb9a78e7..ba35cb4f 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/CustomBomParser.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/CustomBomParser.java @@ -17,16 +17,14 @@ package org.springframework.cloud.release.internal.buildsystem; import java.io.File; -import java.util.Collections; import java.util.LinkedHashSet; -import java.util.List; import java.util.Set; import org.springframework.cloud.release.internal.ReleaserProperties; -import org.springframework.core.io.support.SpringFactoriesLoader; +import org.springframework.lang.Nullable; /** - * Allows to pass in some additional BOM model to Versions mapping. + * Allows to pass in some additional gradle files parser. */ public interface CustomBomParser { @@ -39,7 +37,7 @@ public interface CustomBomParser { * @return {@code true} if the parser should be applied. */ boolean isApplicable(File thisProjectRoot, ReleaserProperties properties, - Set projects); + @Nullable Set projects); /** * When parsing a part of the BOM pom, one can add custom logic to perform project @@ -63,8 +61,13 @@ public interface CustomBomParser { return new LinkedHashSet<>(projects); } - List PARSERS = SpringFactoriesLoader - .loadFactories(CustomBomParser.class, null); + default boolean isMaven(File thisProjectRoot) { + return new File(thisProjectRoot, "pom.xml").exists(); + } + + default boolean isGradle(File thisProjectRoot) { + return new File(thisProjectRoot, "build.gradle").exists(); + } CustomBomParser NO_OP = new CustomBomParser() { @Override @@ -81,23 +84,4 @@ public interface CustomBomParser { }; - static CustomBomParser parser(File thisProjectRoot, ReleaserProperties properties, - Set projects) { - for (CustomBomParser parser : PARSERS) { - if (parser.isApplicable(thisProjectRoot, properties, projects)) { - return parser; - } - } - return NO_OP; - } - - static CustomBomParser parser(ReleaserProperties properties) { - return parser(new File(properties.getWorkingDir()), properties, - Collections.emptySet()); - } - - static CustomBomParser parser(ReleaserProperties properties, Set projects) { - return parser(new File(properties.getWorkingDir()), properties, projects); - } - } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/CustomGradleParser.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/CustomGradleParser.java deleted file mode 100644 index 314a1ba7..00000000 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/CustomGradleParser.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2013-2019 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.cloud.release.internal.buildsystem; - -import java.io.File; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import org.springframework.cloud.release.internal.ReleaserProperties; -import org.springframework.core.io.support.SpringFactoriesLoader; - -/** - * Allows to pass in some additional gradle files parser. - */ -public interface CustomGradleParser { - - /** - * Different projects can have different parsers. This method will tell whether the - * current parser should be applied or not. - * @param thisProjectRoot - location of the cloned project - * @param properties - releaser properties - * @param projects - parsed projects from the BOM - * @return {@code true} if the parser should be applied. - */ - boolean isApplicable(File thisProjectRoot, ReleaserProperties properties, - Set projects); - - /** - * When parsing a part of the BOM pom, one can add custom logic to perform project - * specific parsing. - * @param thisProjectRoot - location of the cloned project - * @param properties - releaser properties - * @return - versions retrieved from the BOM. Can be - * {@link VersionsFromBom#EMPTY_VERSION} if nothing was found. - */ - VersionsFromBom parseBom(File thisProjectRoot, ReleaserProperties properties); - - /** - * Allows to hook in custom logic for versions setting. - * @param projects - set of projects - * @param projectName - name of the project - * @param version - version of the project - * @return - a new collection with the modified versions from bom - */ - default Set setVersion(Set projects, String projectName, - String version) { - return new LinkedHashSet<>(projects); - } - - List PARSERS = SpringFactoriesLoader - .loadFactories(CustomGradleParser.class, null); - - CustomGradleParser NO_OP = new CustomGradleParser() { - @Override - public boolean isApplicable(File thisProjectRoot, ReleaserProperties properties, - Set projects) { - return true; - } - - @Override - public VersionsFromBom parseBom(File thisProjectRoot, - ReleaserProperties properties) { - return VersionsFromBom.EMPTY_VERSION; - } - - }; - - static CustomGradleParser parser(File thisProjectRoot, ReleaserProperties properties, - Set projects) { - for (CustomGradleParser parser : PARSERS) { - if (parser.isApplicable(thisProjectRoot, properties, projects)) { - return parser; - } - } - return NO_OP; - } - - static CustomGradleParser parser(ReleaserProperties properties) { - return parser(new File(properties.getWorkingDir()), properties, - Collections.emptySet()); - } - - static CustomGradleParser parser(ReleaserProperties properties, - Set projects) { - return parser(new File(properties.getWorkingDir()), properties, projects); - } - -} diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/GradleBomParser.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/GradleBomParser.java index 2935180c..13f1b9e8 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/GradleBomParser.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/GradleBomParser.java @@ -19,8 +19,7 @@ package org.springframework.cloud.release.internal.buildsystem; import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; +import java.util.List; import java.util.Map; import java.util.Properties; import java.util.regex.Matcher; @@ -30,10 +29,16 @@ import org.springframework.cloud.release.internal.ReleaserProperties; class GradleBomParser implements BomParser { + private static final Pattern VERSION_PATTERN = Pattern + .compile("^([a-zA-Z0-9]+)Version$"); + private final ReleaserProperties properties; - GradleBomParser(ReleaserProperties releaserProperties) { + private final List customParsers; + + GradleBomParser(ReleaserProperties releaserProperties, List customParsers) { this.properties = releaserProperties; + this.customParsers = customParsers; } @Override @@ -54,7 +59,9 @@ class GradleBomParser implements BomParser { Properties properties = loadProps(gradleProperties); final Map substitution = this.properties.getGradle() .getGradlePropsSubstitution(); - VersionsFromBom versionsFromBom = new VersionsFromBom(this.properties); + VersionsFromBom versionsFromBom = new VersionsFromBomBuilder().releaserProperties(this.properties) + .parsers(this.customParsers) + .versionsFromBom(); properties.forEach((key, value) -> { String projectName = projectName(substitution, key); versionsFromBom.setVersion(projectName, value.toString()); @@ -62,14 +69,13 @@ class GradleBomParser implements BomParser { return versionsFromBom; } - String projectName(Map substitution, Object key) { + private String projectName(Map substitution, Object key) { String projectName = key.toString(); if (substitution.containsKey(key)) { projectName = substitution.get(key); } else { - Pattern versionPattern = Pattern.compile("^([a-zA-Z]+)Version$"); - Matcher matcher = versionPattern.matcher(projectName); + Matcher matcher = VERSION_PATTERN.matcher(projectName); boolean versionMatches = matcher.matches(); if (versionMatches) { projectName = matcher.group(1); @@ -90,13 +96,4 @@ class GradleBomParser implements BomParser { return props; } - private String asString(Path path) { - try { - return new String(Files.readAllBytes(path)); - } - catch (IOException e) { - throw new IllegalStateException(e); - } - } - } diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/MavenBomParser.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/MavenBomParser.java index 83399e69..43822ef3 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/MavenBomParser.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/MavenBomParser.java @@ -17,6 +17,7 @@ package org.springframework.cloud.release.internal.buildsystem; import java.io.File; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Function; @@ -46,10 +47,13 @@ class MavenBomParser implements BomParser { private final ReleaserProperties properties; - MavenBomParser(ReleaserProperties properties) { + private final List customParsers; + + MavenBomParser(ReleaserProperties properties, List customParsers) { this.thisTrainBomLocation = properties.getPom().getThisTrainBom(); this.versionPattern = Pattern.compile(properties.getPom().getBomVersionPattern()); this.properties = properties; + this.customParsers = customParsers; } @Override @@ -72,15 +76,13 @@ class MavenBomParser implements BomParser { projects.add( new Project(this.properties.getMetaRelease().getReleaseTrainProjectName(), releaseTrainProjectVersion)); - VersionsFromBom bomVersions = new VersionsFromBom(this.properties, projects); - return new VersionsFromBom(properties, bomVersions, - customVersions(thisProjectRoot, projects)); - } - - private VersionsFromBom customVersions(File thisProjectRoot, Set projects) { - CustomBomParser parser = CustomBomParser.parser(thisProjectRoot, this.properties, - projects); - return parser.parseBom(thisProjectRoot, this.properties); + // @formatter:off + return new VersionsFromBomBuilder() + .releaserProperties(this.properties) + .parsers(this.customParsers) + .projects(projects) + .versionsFromBom(); + // @formatter:on } private Predicate> propertyMatchesVersionPattern() { diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/ProjectPomUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/ProjectPomUpdater.java index 7f314542..a2d4b938 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/ProjectPomUpdater.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/ProjectPomUpdater.java @@ -62,14 +62,12 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware { private ReleaserProperties properties; - public ProjectPomUpdater(ReleaserProperties properties) { + private final List bomParsers; + + public ProjectPomUpdater(ReleaserProperties properties, List bomParsers) { this.properties = properties; this.gitRepo = new ProjectGitHandler(properties); - } - - ProjectPomUpdater(ReleaserProperties properties, ProjectGitHandler gitRepo) { - this.properties = properties; - this.gitRepo = gitRepo; + this.bomParsers = bomParsers; } /** @@ -96,7 +94,7 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware { VersionsFromBom versionsFromBom = CACHE.computeIfAbsent(branch, s -> { File clonedBom = this.gitRepo.cloneReleaseTrainProject(); this.gitRepo.checkout(clonedBom, branch); - return new CompositeBomParser(this.properties).versionsFromBom(clonedBom); + return new CompositeBomParser(this.bomParsers).versionsFromBom(clonedBom); }); if (updateFixedVersions) { log.info("Will update the following versions manually [{}]", @@ -117,7 +115,8 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware { if (log.isDebugEnabled()) { log.debug("Will apply the following fixed versions {}", projects); } - return new VersionsFromBom(this.properties, projects).toProjectVersions(); + return new VersionsFromBomBuilder().releaserProperties(this.properties) + .projects(projects).versionsFromBom().toProjectVersions(); } /** @@ -132,8 +131,9 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware { */ public void updateProjectFromReleaseTrain(File projectRoot, Projects projects, ProjectVersion versionFromReleaseTrain, boolean assertVersions) { - VersionsFromBom versionsFromBom = new VersionsFromBom(this.properties, - projects.asProjects()); + VersionsFromBom versionsFromBom = new VersionsFromBomBuilder() + .releaserProperties(this.properties).projects(projects.asProjects()) + .versionsFromBom(); if (!this.pomUpdater.shouldProjectBeUpdated(projectRoot, versionsFromBom)) { log.info("Skipping project updating"); return; @@ -189,7 +189,9 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware { ReleaserProperties properties, ProjectVersion versionFromScRelease, boolean assertVersions) { this.rootPom = rootPom; - this.versionsFromBom = new VersionsFromBom(properties, projects.asProjects()); + this.versionsFromBom = new VersionsFromBomBuilder() + .releaserProperties(properties).projects(projects.asProjects()) + .versionsFromBom(); this.pomUpdater = pomUpdater; this.properties = properties; List unacceptableVersionPatterns = versionFromScRelease diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/VersionsFromBom.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/VersionsFromBom.java index 43a81cdf..06569fbf 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/VersionsFromBom.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/VersionsFromBom.java @@ -35,28 +35,32 @@ import org.springframework.cloud.release.internal.project.Projects; */ public class VersionsFromBom { - public static final VersionsFromBom EMPTY_VERSION = new VersionsFromBom(); + public static final VersionsFromBom EMPTY_VERSION = new VersionsFromBomBuilder().versionsFromBom(); Set projects = new HashSet<>(); ReleaserProperties properties; + CustomBomParser parser = CustomBomParser.NO_OP; + private VersionsFromBom() { this.properties = new ReleaserProperties(); } - public VersionsFromBom(ReleaserProperties releaserProperties) { + VersionsFromBom(ReleaserProperties releaserProperties, CustomBomParser parser) { this.properties = releaserProperties; + this.parser = parser; } - public VersionsFromBom(ReleaserProperties releaserProperties, Set projects) { + VersionsFromBom(ReleaserProperties releaserProperties, CustomBomParser parser, Set projects) { this.properties = releaserProperties; + this.parser = parser; projects.forEach(project -> setVersion(project.name, project.version)); } - public VersionsFromBom(ReleaserProperties releaserProperties, - VersionsFromBom... projects) { + VersionsFromBom(ReleaserProperties releaserProperties, CustomBomParser parser, VersionsFromBom... projects) { this.properties = releaserProperties; + this.parser = parser; Arrays.stream(projects).forEach(p -> this.projects.addAll(p.projects)); } @@ -130,7 +134,6 @@ public class VersionsFromBom { } public VersionsFromBom setVersion(String projectName, String version) { - CustomBomParser parser = CustomBomParser.parser(this.properties); Set projects = parser.setVersion(this.projects, projectName, version); if (!projects.equals(this.projects)) { this.projects.clear(); diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/VersionsFromBomBuilder.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/VersionsFromBomBuilder.java new file mode 100644 index 00000000..ee586e14 --- /dev/null +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/buildsystem/VersionsFromBomBuilder.java @@ -0,0 +1,94 @@ +/* + * Copyright 2013-2019 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.cloud.release.internal.buildsystem; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.springframework.cloud.release.internal.ReleaserProperties; + +public class VersionsFromBomBuilder { + + private ReleaserProperties releaserProperties; + + private Set projects = new HashSet<>(); + + private VersionsFromBom[] versionsFromBom = new VersionsFromBom[0]; + + private List parsers = new ArrayList<>(); + + public VersionsFromBomBuilder releaserProperties( + ReleaserProperties releaserProperties) { + this.releaserProperties = releaserProperties; + return this; + } + + public VersionsFromBomBuilder projects(Set projects) { + this.projects = projects; + return this; + } + + public VersionsFromBomBuilder projects(VersionsFromBom... versionsFromBom) { + this.versionsFromBom = versionsFromBom; + return this; + } + + public VersionsFromBomBuilder parsers(List parsers) { + this.parsers = parsers; + return this; + } + + public VersionsFromBom versionsFromBom() { + File thisProjectRoot = new File(this.releaserProperties.getWorkingDir()); + CustomBomParser bomParser = this.parsers + .stream().filter(p -> p.isApplicable(thisProjectRoot, + this.releaserProperties, this.projects)) + .findFirst().orElse(CustomBomParser.NO_OP); + VersionsFromBom versionsFromBom = versionsFromBom(bomParser); + VersionsFromBom customParsing = customParsing(thisProjectRoot, this.projects); + return new VersionsFromBom(this.releaserProperties, bomParser, versionsFromBom, customParsing); + } + + private VersionsFromBom versionsFromBom(CustomBomParser bomParser) { + if (!this.projects.isEmpty()) { + return new VersionsFromBom(this.releaserProperties, bomParser, this.projects); + } + else if (this.versionsFromBom.length != 0) { + return new VersionsFromBom(this.releaserProperties, bomParser, + this.versionsFromBom); + } + return new VersionsFromBom(this.releaserProperties, bomParser); + } + + private VersionsFromBom customParsing(File thisProjectRoot, Set projects) { + return this.parsers.stream() + .filter(p -> p.isApplicable(thisProjectRoot, this.releaserProperties, projects)) + .map(p -> p.parseBom(thisProjectRoot, this.releaserProperties)) + .reduce((versionsFromBom, + versionsFromBom2) -> new VersionsFromBomBuilder() + .parsers(this.parsers) + .releaserProperties(this.releaserProperties) + .projects(versionsFromBom, versionsFromBom2) + .versionsFromBom()) + .orElse(VersionsFromBom.EMPTY_VERSION); + } + + +} \ No newline at end of file diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/CustomProjectDocumentationUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/CustomProjectDocumentationUpdater.java new file mode 100644 index 00000000..2e8b1f1d --- /dev/null +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/CustomProjectDocumentationUpdater.java @@ -0,0 +1,68 @@ +/* + * Copyright 2013-2019 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 + * + * https://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.cloud.release.internal.docs; + +import java.io.File; + +import org.springframework.cloud.release.internal.buildsystem.ProjectVersion; + +/** + * @author Marcin Grzejszczak + */ +public interface CustomProjectDocumentationUpdater { + + /** + * Different projects can have different documentation updaters. This method will tell + * whether the current updater should be applied or not. Updates the documentation + * repository. + * @param clonedDocumentationProject path to the cloned documentation project + * @param currentProject project to update the docs repo for + * @param bomBranch the bom project branch + * @return {@code true} if the parser should be applied. + */ + boolean isApplicable(File clonedDocumentationProject, ProjectVersion currentProject, + String bomBranch); + + /** + * Updates the documentation repository. + * @param clonedDocumentationProject path to the cloned documentation project + * @param currentProject project to update the docs repo for + * @param bomBranch the bom project branch + * @return {@link File cloned temporary directory} - {@code null} if wrong version is + * used + */ + File updateDocsRepo(File clonedDocumentationProject, ProjectVersion currentProject, + String bomBranch); + + /** + * NO OP implementation of the updater. + */ + CustomProjectDocumentationUpdater NO_OP = new CustomProjectDocumentationUpdater() { + @Override + public boolean isApplicable(File clonedDocumentationProject, + ProjectVersion currentProject, String bomBranch) { + return true; + } + + @Override + public File updateDocsRepo(File clonedDocumentationProject, + ProjectVersion currentProject, String bomBranch) { + return clonedDocumentationProject; + } + }; + +} diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/DefaultProjectDocumentationUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/DefaultProjectDocumentationUpdater.java new file mode 100644 index 00000000..edb96348 --- /dev/null +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/DefaultProjectDocumentationUpdater.java @@ -0,0 +1,86 @@ +/* + * Copyright 2013-2019 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 + * + * https://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.cloud.release.internal.docs; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.cloud.release.internal.ReleaserProperties; +import org.springframework.cloud.release.internal.ReleaserPropertiesAware; +import org.springframework.cloud.release.internal.buildsystem.ProjectVersion; +import org.springframework.cloud.release.internal.git.ProjectGitHandler; + +/** + * @author Marcin Grzejszczak + */ +class DefaultProjectDocumentationUpdater implements ReleaserPropertiesAware { + + private static final Logger log = LoggerFactory + .getLogger(DefaultProjectDocumentationUpdater.class); + + private final ProjectGitHandler gitHandler; + + private ReleaserProperties properties; + + private final List updaters; + + DefaultProjectDocumentationUpdater(ReleaserProperties properties, + ProjectGitHandler gitHandler, + List updaters) { + this.gitHandler = gitHandler; + this.properties = properties; + this.updaters = updaters; + } + + DefaultProjectDocumentationUpdater(ReleaserProperties properties, + ProjectGitHandler gitHandler) { + this.gitHandler = gitHandler; + this.properties = properties; + this.updaters = new ArrayList<>(); + } + + public File updateDocsRepo(ProjectVersion currentProject, String bomBranch) { + if (!this.properties.getGit().isUpdateDocumentationRepo()) { + log.info( + "Will not update documentation repository, since the switch to do so " + + "is off. Set [releaser.git.update-documentation-repo] to [true] to change that"); + return null; + } + if (!currentProject.isReleaseOrServiceRelease()) { + log.info( + "Will not update documentation repository for non release or service release [{}]", + currentProject.version); + return null; + } + File documentationProject = this.gitHandler.cloneDocumentationProject(); + log.debug("Cloning the doc project to [{}]", documentationProject); + CustomProjectDocumentationUpdater updater = this.updaters.stream().filter( + u -> u.isApplicable(documentationProject, currentProject, bomBranch)) + .findFirst().orElse(CustomProjectDocumentationUpdater.NO_OP); + return updater.updateDocsRepo(documentationProject, currentProject, bomBranch); + } + + @Override + public void setReleaserProperties(ReleaserProperties properties) { + this.properties = properties; + } + +} diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/DocumentationUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/DocumentationUpdater.java index 4f691e72..0f84f8cc 100644 --- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/DocumentationUpdater.java +++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/DocumentationUpdater.java @@ -30,26 +30,25 @@ import org.springframework.cloud.release.internal.template.TemplateGenerator; */ public class DocumentationUpdater implements ReleaserPropertiesAware { - private final ProjectDocumentationUpdater projectDocumentationUpdater; + private final DefaultProjectDocumentationUpdater defaultProjectDocumentationUpdater; private final ReleaseTrainContentsUpdater releaseTrainContentsUpdater; private ReleaserProperties properties; public DocumentationUpdater(ProjectGitHandler gitHandler, - ReleaserProperties properties, TemplateGenerator templateGenerator) { + ReleaserProperties properties, TemplateGenerator templateGenerator, DefaultProjectDocumentationUpdater updater) { this.properties = properties; - this.projectDocumentationUpdater = new ProjectDocumentationUpdater( - this.properties, gitHandler); + this.defaultProjectDocumentationUpdater = updater; this.releaseTrainContentsUpdater = new ReleaseTrainContentsUpdater( this.properties, gitHandler, templateGenerator); } DocumentationUpdater(ReleaserProperties properties, - ProjectDocumentationUpdater updater, + DefaultProjectDocumentationUpdater updater, ReleaseTrainContentsUpdater contentsUpdater) { this.properties = properties; - this.projectDocumentationUpdater = updater; + this.defaultProjectDocumentationUpdater = updater; this.releaseTrainContentsUpdater = contentsUpdater; } @@ -62,7 +61,7 @@ public class DocumentationUpdater implements ReleaserPropertiesAware { * used */ public File updateDocsRepo(ProjectVersion currentProject, String bomReleaseBranch) { - return this.projectDocumentationUpdater.updateDocsRepo(currentProject, + return this.defaultProjectDocumentationUpdater.updateDocsRepo(currentProject, bomReleaseBranch); } @@ -92,8 +91,8 @@ public class DocumentationUpdater implements ReleaserPropertiesAware { @Override public void setReleaserProperties(ReleaserProperties properties) { this.properties = properties; - this.projectDocumentationUpdater.setReleaserProperties(properties); this.releaseTrainContentsUpdater.setReleaserProperties(properties); + this.defaultProjectDocumentationUpdater.setReleaserProperties(properties); } } diff --git a/spring-cloud-release-tools-core/src/main/resources/META-INF/spring.factories b/spring-cloud-release-tools-core/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 9a8479b0..00000000 --- a/spring-cloud-release-tools-core/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.cloud.release.internal.buildsystem.CustomBomParser=\ -org.springframework.cloud.release.cloud.buildsystem.SpringCloudBomParser diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ProjectDocumentationUpdaterTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/cloud/docs/SpringCloudCustomProjectDocumentationUpdaterTests.java similarity index 75% rename from spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ProjectDocumentationUpdaterTests.java rename to spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/cloud/docs/SpringCloudCustomProjectDocumentationUpdaterTests.java index 06c816fd..ca4613be 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/docs/ProjectDocumentationUpdaterTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/cloud/docs/SpringCloudCustomProjectDocumentationUpdaterTests.java @@ -1,12 +1,12 @@ /* * Copyright 2013-2019 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 - * - * https://www.apache.org/licenses/LICENSE-2.0 - * + * + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cloud.release.internal.docs; +package org.springframework.cloud.release.cloud.docs; import java.io.File; import java.io.IOException; @@ -39,7 +39,7 @@ import static org.assertj.core.api.BDDAssertions.then; /** * @author Marcin Grzejszczak */ -public class ProjectDocumentationUpdaterTests { +public class SpringCloudCustomProjectDocumentationUpdaterTests { @Rule public TemporaryFolder tmp = new TemporaryFolder(); @@ -57,7 +57,7 @@ public class ProjectDocumentationUpdaterTests { @Before public void setup() throws IOException, URISyntaxException { this.tmpFolder = this.tmp.newFolder(); - this.project = new File(ProjectDocumentationUpdaterTests.class + this.project = new File(SpringCloudCustomProjectDocumentationUpdater.class .getResource("/projects/spring-cloud-static").toURI()); TestUtils.prepareLocalRepo(); FileSystemUtils.copyRecursively(file("/projects"), this.tmpFolder); @@ -78,9 +78,11 @@ public class ProjectDocumentationUpdaterTests { file("/projects/spring-cloud-release/").toURI().toString()); BDDAssertions - .thenThrownBy(() -> new ProjectDocumentationUpdater(properties, - new ProjectGitHandler(properties)) - .updateDocsRepo(releaseTrainVersion, "vAngel.SR33")) + .thenThrownBy( + () -> new SpringCloudCustomProjectDocumentationUpdater(properties, + new ProjectGitHandler(properties)).updateDocsRepo( + this.clonedDocProject, releaseTrainVersion, + "vAngel.SR33")) .isInstanceOf(IllegalStateException.class) .hasMessageContaining("index.html is not present"); } @@ -94,13 +96,15 @@ public class ProjectDocumentationUpdaterTests { properties.getGit().setDocumentationUrl( file("/projects/spring-cloud-static/").toURI().toString()); - BDDAssertions.thenThrownBy(() -> new ProjectDocumentationUpdater(properties, - new ProjectGitHandler(properties)) { - @Override - String readIndexHtmlContents(File indexHtml) { - return ""; - } - }.updateDocsRepo(releaseTrainVersion, "vAngel.SR33")) + BDDAssertions.thenThrownBy( + () -> new SpringCloudCustomProjectDocumentationUpdater(properties, + new ProjectGitHandler(properties)) { + @Override + String readIndexHtmlContents(File indexHtml) { + return ""; + } + }.updateDocsRepo(this.clonedDocProject, releaseTrainVersion, + "vAngel.SR33")) .isInstanceOf(IllegalStateException.class) .hasMessageContaining("The URL to the documentation repo not found"); } @@ -111,9 +115,9 @@ public class ProjectDocumentationUpdaterTests { "2.0.0.BUILD-SNAPSHOT"); ReleaserProperties properties = new ReleaserProperties(); - File updatedDocs = new ProjectDocumentationUpdater(properties, - new ProjectGitHandler(properties)).updateDocsRepo(releaseTrainVersion, - "vAngel.M7"); + File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(properties, + new ProjectGitHandler(properties)).updateDocsRepo(this.clonedDocProject, + releaseTrainVersion, "vAngel.M7"); then(updatedDocs).isNull(); } @@ -127,9 +131,9 @@ public class ProjectDocumentationUpdaterTests { properties.getGit().setDocumentationUrl( file("/projects/spring-cloud-static/").toURI().toString()); - File updatedDocs = new ProjectDocumentationUpdater(properties, - new ProjectGitHandler(properties)).updateDocsRepo(releaseTrainVersion, - "vAngel.SR33"); + File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(properties, + new ProjectGitHandler(properties)).updateDocsRepo(this.clonedDocProject, + releaseTrainVersion, "vAngel.SR33"); String indexHtmlContent = new String( Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath())); @@ -145,8 +149,9 @@ public class ProjectDocumentationUpdaterTests { properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString()); ProjectGitHandler handler = BDDMockito.spy(new ProjectGitHandler(properties)); - new ProjectDocumentationUpdater(properties, handler) - .updateDocsRepo(releaseTrainVersion, "vDalston.SR3"); + new SpringCloudCustomProjectDocumentationUpdater(properties, handler) + .updateDocsRepo(this.clonedDocProject, releaseTrainVersion, + "vDalston.SR3"); BDDMockito.then(handler).should(BDDMockito.never()) .commit(BDDMockito.any(File.class), BDDMockito.anyString()); @@ -160,9 +165,9 @@ public class ProjectDocumentationUpdaterTests { ReleaserProperties properties = new ReleaserProperties(); properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString()); - File updatedDocs = new ProjectDocumentationUpdater(properties, - new ProjectGitHandler(properties)).updateDocsRepo(releaseTrainVersion, - "Angel.SR33"); + File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(properties, + new ProjectGitHandler(properties)).updateDocsRepo(this.clonedDocProject, + releaseTrainVersion, "Angel.SR33"); String indexHtmlContent = new String( Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath())); @@ -178,9 +183,9 @@ public class ProjectDocumentationUpdaterTests { ReleaserProperties properties = new ReleaserProperties(); properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString()); - File updatedDocs = new ProjectDocumentationUpdater(properties, - new ProjectGitHandler(properties)).updateDocsRepo(releaseTrainVersion, - "vFinchley.SR33"); + File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(properties, + new ProjectGitHandler(properties)).updateDocsRepo(this.clonedDocProject, + releaseTrainVersion, "vFinchley.SR33"); String indexHtmlContent = new String( Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath())); @@ -196,9 +201,9 @@ public class ProjectDocumentationUpdaterTests { ReleaserProperties properties = new ReleaserProperties(); properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString()); - File updatedDocs = new ProjectDocumentationUpdater(properties, - new ProjectGitHandler(properties)).updateDocsRepo(releaseTrainVersion, - "Finchley.SR33"); + File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(properties, + new ProjectGitHandler(properties)).updateDocsRepo(this.clonedDocProject, + releaseTrainVersion, "Finchley.SR33"); String indexHtmlContent = new String( Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath())); @@ -214,16 +219,16 @@ public class ProjectDocumentationUpdaterTests { properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString()); properties.getGit().setUpdateDocumentationRepo(false); - File updatedDocs = new ProjectDocumentationUpdater(properties, - new ProjectGitHandler(properties)).updateDocsRepo(releaseTrainVersion, - "Finchley.SR33"); + File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(properties, + new ProjectGitHandler(properties)).updateDocsRepo(this.clonedDocProject, + releaseTrainVersion, "Finchley.SR33"); then(updatedDocs).isNull(); } private File file(String relativePath) throws URISyntaxException { - return new File( - ProjectDocumentationUpdaterTests.class.getResource(relativePath).toURI()); + return new File(SpringCloudCustomProjectDocumentationUpdater.class + .getResource(relativePath).toURI()); } } 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 da2ea8d0..fed79ec1 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 @@ -20,6 +20,7 @@ import java.io.File; import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.Files; +import java.util.ArrayList; import org.apache.maven.model.Model; import org.assertj.core.api.BDDAssertions; @@ -58,7 +59,7 @@ public class PomUpdateAcceptanceTests { 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); + ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties, new ArrayList<>()); Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom(); File project = new File(this.temporaryFolder, "/spring-cloud-sleuth"); @@ -90,7 +91,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); + ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties, new ArrayList<>()); Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom(); projects.add(new ProjectVersion("spring-cloud-sleuth-samples", "0.0.5.RELEASE")); File project = new File(this.temporaryFolder, @@ -112,7 +113,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); + ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties, new ArrayList<>()); Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom(); File project = new File(this.temporaryFolder, "/spring-cloud-sleuth-with-unmatched-property"); @@ -128,7 +129,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); + ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties, new ArrayList<>()); Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom(); projects.removeIf(projectVersion -> projectVersion.projectName .contains("spring-cloud-build")); @@ -144,7 +145,7 @@ public class PomUpdateAcceptanceTests { @Test public void should_not_update_a_project_that_is_not_on_the_list() throws Exception { ReleaserProperties releaserProperties = releaserProperties(); - ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties); + ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties, new ArrayList<>()); File beforeProcessing = pom("/projects/project/"); Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom(); File project = tmpFile("/project/"); diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/GradleBomParserTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/GradleBomParserTests.java index 171c19f5..8cf3b566 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/GradleBomParserTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/GradleBomParserTests.java @@ -17,6 +17,7 @@ package org.springframework.cloud.release.internal.buildsystem; import java.io.File; +import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Properties; @@ -30,7 +31,7 @@ class GradleBomParserTests { @Test void should_read_versions_from_bom_from_properties() { - GradleBomParser parser = new GradleBomParser(new ReleaserProperties()) { + GradleBomParser parser = new GradleBomParser(new ReleaserProperties(), new ArrayList<>()) { @Override public boolean isApplicable(File clonedBom) { return true; @@ -61,7 +62,7 @@ class GradleBomParserTests { gradleSubstitution.put("verifierVersion", "spring-cloud-contract"); ReleaserProperties releaserProperties = new ReleaserProperties(); releaserProperties.getGradle().setGradlePropsSubstitution(gradleSubstitution); - GradleBomParser parser = new GradleBomParser(releaserProperties) { + GradleBomParser parser = new GradleBomParser(releaserProperties, new ArrayList<>()) { @Override public boolean isApplicable(File clonedBom) { return true; @@ -88,14 +89,14 @@ class GradleBomParserTests { @Test void should_be_not_applicable_when_no_build_gradle_is_present() { - GradleBomParser parser = new GradleBomParser(new ReleaserProperties()); + GradleBomParser parser = new GradleBomParser(new ReleaserProperties(), new ArrayList<>()); BDDAssertions.then(parser.isApplicable(new File("."))).isFalse(); } @Test void should_be_applicable_when_build_gradle_is_present() { - GradleBomParser parser = new GradleBomParser(new ReleaserProperties()) { + GradleBomParser parser = new GradleBomParser(new ReleaserProperties(), new ArrayList<>()) { @Override File file(File clonedBom, String child) { return clonedBom; @@ -107,7 +108,7 @@ class GradleBomParserTests { @Test void should_return_empty_version_when_no_gradle_properties_is_present() { - GradleBomParser parser = new GradleBomParser(new ReleaserProperties()); + GradleBomParser parser = new GradleBomParser(new ReleaserProperties(), new ArrayList<>()); VersionsFromBom versionsFromBom = parser.versionsFromBom(new File(".")); diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/MavenBomParserTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/MavenBomParserTests.java index 81585bbe..dd07a505 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/MavenBomParserTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/MavenBomParserTests.java @@ -18,6 +18,7 @@ package org.springframework.cloud.release.internal.buildsystem; import java.io.File; import java.net.URISyntaxException; +import java.util.ArrayList; import org.junit.Before; import org.junit.Test; @@ -45,7 +46,7 @@ public class MavenBomParserTests { @Test public void should_throw_exception_when_boot_pom_is_missing() { - MavenBomParser parser = new MavenBomParser(this.properties); + MavenBomParser parser = new MavenBomParser(this.properties, new ArrayList<>()); File file = new File("."); thenThrownBy(() -> parser.versionsFromBom(file)) @@ -57,7 +58,7 @@ public class MavenBomParserTests { public void should_throw_exception_when_null_is_passed_to_boot() { this.properties.getPom().setPomWithBootStarterParent(null); this.properties.getPom().setThisTrainBom(null); - MavenBomParser parser = new MavenBomParser(this.properties); + MavenBomParser parser = new MavenBomParser(this.properties, new ArrayList<>()); thenThrownBy(() -> parser.versionsFromBom(this.springCloudReleaseProject)) .isInstanceOf(IllegalStateException.class) @@ -67,7 +68,7 @@ public class MavenBomParserTests { @Test public void should_throw_exception_when_boot_version_is_missing_in_pom() { this.properties.getPom().setPomWithBootStarterParent("pom.xml"); - MavenBomParser parser = new MavenBomParser(this.properties); + MavenBomParser parser = new MavenBomParser(this.properties, new ArrayList<>()); thenThrownBy(() -> parser.versionsFromBom(this.springCloudReleaseProject)) .isInstanceOf(IllegalStateException.class).hasMessageContaining( @@ -76,7 +77,7 @@ public class MavenBomParserTests { @Test public void should_populate_sc_release_version() { - MavenBomParser parser = new MavenBomParser(this.properties); + MavenBomParser parser = new MavenBomParser(this.properties, new ArrayList<>()); String scReleaseVersion = parser.versionsFromBom(this.springCloudReleaseProject) .versionForProject("spring-cloud-release"); @@ -86,7 +87,7 @@ public class MavenBomParserTests { @Test public void should_populate_boot_version() { - MavenBomParser parser = new MavenBomParser(this.properties); + MavenBomParser parser = new MavenBomParser(this.properties, new ArrayList<>()); String bootVersion = parser.versionsFromBom(this.springCloudReleaseProject) .versionForProject("spring-boot"); @@ -96,7 +97,7 @@ public class MavenBomParserTests { @Test public void should_throw_exception_when_cloud_pom_is_missing() { - MavenBomParser parser = new MavenBomParser(this.properties); + MavenBomParser parser = new MavenBomParser(this.properties, new ArrayList<>()); thenThrownBy(() -> parser.versionsFromBom(new File("."))) .isInstanceOf(IllegalStateException.class) @@ -107,7 +108,7 @@ public class MavenBomParserTests { public void should_throw_exception_when_null_is_passed_to_cloud() { this.properties.getPom().setPomWithBootStarterParent(null); this.properties.getPom().setThisTrainBom(null); - MavenBomParser parser = new MavenBomParser(this.properties); + MavenBomParser parser = new MavenBomParser(this.properties, new ArrayList<>()); thenThrownBy(() -> parser.versionsFromBom(this.springCloudReleaseProject)) .isInstanceOf(IllegalStateException.class) @@ -118,7 +119,7 @@ public class MavenBomParserTests { public void should_throw_exception_when_cloud_version_is_missing_in_pom() { this.properties.getPom().setPomWithBootStarterParent("pom.xml"); this.properties.getPom().setThisTrainBom("pom.xml"); - MavenBomParser parser = new MavenBomParser(this.properties); + MavenBomParser parser = new MavenBomParser(this.properties, new ArrayList<>()); thenThrownBy(() -> parser.versionsFromBom(this.springCloudReleaseProject)) .isInstanceOf(IllegalStateException.class).hasMessageContaining( @@ -127,7 +128,7 @@ public class MavenBomParserTests { @Test public void should_populate_cloud_version() { - MavenBomParser parser = new MavenBomParser(this.properties); + MavenBomParser parser = new MavenBomParser(this.properties, new ArrayList<>()); VersionsFromBom cloudVersionsFromBom = parser .versionsFromBom(this.springCloudReleaseProject); @@ -139,7 +140,7 @@ public class MavenBomParserTests { @Test public void should_populate_boot_and_cloud_version() { - MavenBomParser parser = new MavenBomParser(this.properties); + MavenBomParser parser = new MavenBomParser(this.properties, new ArrayList<>()); VersionsFromBom cloudVersionsFromBom = parser .versionsFromBom(this.springCloudReleaseProject); diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/PomUpdaterTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/PomUpdaterTests.java index a46c7b68..7087f9a9 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/PomUpdaterTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/PomUpdaterTests.java @@ -46,8 +46,8 @@ public class PomUpdaterTests { @Rule public TemporaryFolder tmp = new TemporaryFolder(); - VersionsFromBom versionsFromBom = new VersionsFromBom(new ReleaserProperties(), - projects()); + VersionsFromBom versionsFromBom = new VersionsFromBomBuilder().releaserProperties(new ReleaserProperties()) + .projects(projects()).versionsFromBom(); PomUpdater pomUpdater = new PomUpdater(); diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/ProjectPomUpdaterTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/ProjectPomUpdaterTests.java index c103be96..4a8f895b 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/ProjectPomUpdaterTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/ProjectPomUpdaterTests.java @@ -17,6 +17,7 @@ package org.springframework.cloud.release.internal.buildsystem; import java.io.File; +import java.util.ArrayList; import java.util.Map; import java.util.stream.Collectors; @@ -65,7 +66,7 @@ public class ProjectPomUpdaterTests { "Finchley.BUILD-SNAPSHOT"); properties.getFixedVersions().put("spring-boot", "2.0.3.RELEASE"); properties.getFixedVersions().put("spring-cloud-gateway", "2.0.1.BUILD-SNAPSHOT"); - ProjectPomUpdater updater = new ProjectPomUpdater(properties); + ProjectPomUpdater updater = new ProjectPomUpdater(properties, new ArrayList<>()); Map fixedVersions = updater.fixedVersions().stream() .collect(Collectors.toMap(projectVersion -> projectVersion.projectName, @@ -84,7 +85,7 @@ public class ProjectPomUpdaterTests { public void should_skip_any_steps_if_there_is_no_pom_xml() { ReleaserProperties properties = new ReleaserProperties(); ProjectGitHandler handler = BDDMockito.mock(ProjectGitHandler.class); - ProjectPomUpdater updater = new ProjectPomUpdater(properties, handler); + ProjectPomUpdater updater = new ProjectPomUpdater(properties, new ArrayList<>()); updater.updateProjectFromReleaseTrain(new File("target"), new Projects(), new ProjectVersion("foo", "1.0.0.RELEASE"), false); diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/PropertyVersionChangerTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/PropertyVersionChangerTests.java index dc84825b..4ba4cfc9 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/PropertyVersionChangerTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/PropertyVersionChangerTests.java @@ -78,7 +78,8 @@ public class PropertyVersionChangerTests { } VersionsFromBom versions() { - return new VersionsFromBom(new ReleaserProperties(), allProjects()); + return new VersionsFromBomBuilder().releaserProperties(new ReleaserProperties()).projects(allProjects()) + .versionsFromBom(); } @SuppressWarnings("unchecked") diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/VersionsFromBomTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/VersionsFromBomTests.java index 0de0c36d..bbee3872 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/VersionsFromBomTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/buildsystem/VersionsFromBomTests.java @@ -32,12 +32,13 @@ import static org.assertj.core.api.BDDAssertions.then; */ public class VersionsFromBomTests { - VersionsFromBom versionsFromBom = new VersionsFromBom(new ReleaserProperties(), - projects()); + VersionsFromBom versionsFromBom = new VersionsFromBomBuilder().releaserProperties(new ReleaserProperties()) + .projects(projects()).versionsFromBom(); @Test public void should_add_boot_to_versions_when_version_is_created() { - VersionsFromBom versionsFromBom = new VersionsFromBom(new ReleaserProperties()); + VersionsFromBom versionsFromBom = new VersionsFromBomBuilder().releaserProperties(new ReleaserProperties()) + .versionsFromBom(); versionsFromBom.setVersion("spring-boot", "1.2.3.RELEASE"); then(versionsFromBom.projects).contains( @@ -240,11 +241,13 @@ public class VersionsFromBomTests { } private VersionsFromBom mixedVersions() { - return new VersionsFromBom(new ReleaserProperties(), mixedProjects()); + return new VersionsFromBomBuilder().releaserProperties(new ReleaserProperties()).projects(mixedProjects()) + .versionsFromBom(); } private VersionsFromBom mixedVersions(ReleaserProperties properties) { - return new VersionsFromBom(properties, mixedProjects()); + return new VersionsFromBomBuilder().releaserProperties(properties).projects(mixedProjects()) + .versionsFromBom(); } private ReleaserProperties customBom() { diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/postrelease/PostReleaseActionsTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/postrelease/PostReleaseActionsTests.java index 703cd49d..b4875b5b 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/postrelease/PostReleaseActionsTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/postrelease/PostReleaseActionsTests.java @@ -18,6 +18,7 @@ package org.springframework.cloud.release.internal.postrelease; import java.io.File; import java.net.URISyntaxException; +import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -90,7 +91,7 @@ public class PostReleaseActionsTests { } }; - ProjectPomUpdater updater = new ProjectPomUpdater(this.properties); + ProjectPomUpdater updater = new ProjectPomUpdater(this.properties, new ArrayList<>()); VersionsFetcher versionsFetcher = new VersionsFetcher(properties, updater); diff --git a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/versions/VersionsFromBomFetcherTests.java b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/versions/VersionsFromBomFetcherTests.java index a3b8d05e..ecb46f22 100644 --- a/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/versions/VersionsFromBomFetcherTests.java +++ b/spring-cloud-release-tools-core/src/test/java/org/springframework/cloud/release/internal/versions/VersionsFromBomFetcherTests.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.nio.file.Files; +import java.util.ArrayList; import org.assertj.core.api.BDDAssertions; import org.junit.jupiter.api.BeforeEach; @@ -58,7 +59,7 @@ class VersionsFromBomFetcherTests { properties.getVersions().setAllVersionsFileUrl(initilizrUri.toString()); properties.getGit().setReleaseTrainBomUrl( file("/projects/spring-cloud-release/").toURI().toString() + "/"); - ProjectPomUpdater updater = new ProjectPomUpdater(properties); + ProjectPomUpdater updater = new ProjectPomUpdater(properties, new ArrayList<>()); VersionsFetcher versionsFetcher = new VersionsFetcher(properties, updater); boolean latestGa = versionsFetcher.isLatestGa(projectVersion); @@ -77,7 +78,7 @@ class VersionsFromBomFetcherTests { properties.getVersions().setAllVersionsFileUrl(initilizrUri.toString()); properties.getGit().setReleaseTrainBomUrl( file("/projects/spring-cloud-release/").toURI().toString() + "/"); - ProjectPomUpdater updater = new ProjectPomUpdater(properties); + ProjectPomUpdater updater = new ProjectPomUpdater(properties, new ArrayList<>()); VersionsFetcher versionsFetcher = new VersionsFetcher(properties, updater); boolean latestGa = versionsFetcher.isLatestGa(projectVersion); @@ -96,7 +97,7 @@ class VersionsFromBomFetcherTests { properties.getVersions().setAllVersionsFileUrl(initilizrUri.toString()); properties.getGit().setReleaseTrainBomUrl( file("/projects/spring-cloud-release/").toURI().toString()); - ProjectPomUpdater updater = new ProjectPomUpdater(properties); + ProjectPomUpdater updater = new ProjectPomUpdater(properties, new ArrayList<>()); VersionsFetcher versionsFetcher = new VersionsFetcher(properties, updater); boolean latestGa = versionsFetcher.isLatestGa(projectVersion); @@ -109,7 +110,7 @@ class VersionsFromBomFetcherTests { ProjectVersion projectVersion = new ProjectVersion("spring-cloud-contract", "1.0.0.BUILD-SNAPSHOT"); ReleaserProperties properties = new ReleaserProperties(); - ProjectPomUpdater updater = new ProjectPomUpdater(properties); + ProjectPomUpdater updater = new ProjectPomUpdater(properties, new ArrayList<>()); VersionsFetcher versionsFetcher = new VersionsFetcher(properties, updater); boolean latestGa = versionsFetcher.isLatestGa(projectVersion); @@ -123,7 +124,7 @@ class VersionsFromBomFetcherTests { "1.0.0.BUILD-SNAPSHOT"); ReleaserProperties properties = new ReleaserProperties(); VersionsFetcher versionsFetcher = new VersionsFetcher(properties, - new ProjectPomUpdater(properties) { + new ProjectPomUpdater(properties, new ArrayList<>()) { @Override public Projects retrieveVersionsFromReleaseTrainBom(String branch, boolean updateFixedVersions) { diff --git a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserConfiguration.java b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserConfiguration.java index db1932d3..66ee498b 100644 --- a/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserConfiguration.java +++ b/spring-cloud-release-tools-spring/src/main/java/org/springframework/cloud/release/internal/spring/ReleaserConfiguration.java @@ -63,7 +63,7 @@ class ReleaserConfiguration { @Bean ProjectPomUpdater pomUpdater() { - return new ProjectPomUpdater(this.properties); + return new ProjectPomUpdater(this.properties, bomParsers); } @Bean diff --git a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/docs/TestDocumentationUpdater.java b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/docs/TestDocumentationUpdater.java index 24bc5d17..2062745f 100644 --- a/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/docs/TestDocumentationUpdater.java +++ b/spring-cloud-release-tools-spring/src/test/java/org/springframework/cloud/release/internal/docs/TestDocumentationUpdater.java @@ -29,7 +29,7 @@ import org.springframework.cloud.release.internal.template.TemplateGenerator; public class TestDocumentationUpdater extends DocumentationUpdater { public TestDocumentationUpdater(ReleaserProperties properties, - TestProjectDocumentationUpdater updater, + TestCustomProjectDocumentationUpdater updater, TestReleaseContentsUpdater testRelease) { super(properties, updater, testRelease); } @@ -48,12 +48,12 @@ public class TestDocumentationUpdater extends DocumentationUpdater { } - public static class TestProjectDocumentationUpdater - extends ProjectDocumentationUpdater { + public static class TestCustomProjectDocumentationUpdater + extends CustomProjectDocumentationUpdater { private final String version; - public TestProjectDocumentationUpdater(ReleaserProperties properties, + public TestCustomProjectDocumentationUpdater(ReleaserProperties properties, ProjectGitHandler gitHandler, String version) { super(properties, gitHandler); this.version = version; 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 6e0a6ef5..76a48879 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 @@ -697,7 +697,7 @@ public class AcceptanceTests { private Releaser defaultReleaser(String expectedVersion, String projectName, ReleaserProperties properties) { - ProjectPomUpdater pomUpdater = new ProjectPomUpdater(properties); + ProjectPomUpdater pomUpdater = new ProjectPomUpdater(properties, bomParsers); ProjectCommandExecutor projectCommandExecutor = new ProjectCommandExecutor( properties); ProjectGitHandler gitHandler = new ProjectGitHandler(properties); @@ -710,7 +710,7 @@ public class AcceptanceTests { this.releaserProperties); DocumentationUpdater documentationUpdater = new TestDocumentationUpdater( properties, - new TestDocumentationUpdater.TestProjectDocumentationUpdater(properties, + new TestDocumentationUpdater.TestCustomProjectDocumentationUpdater(properties, gitHandler, "Brixton.SR1"), new TestDocumentationUpdater.TestReleaseContentsUpdater(properties, gitHandler, templateGenerator)) { @@ -731,7 +731,7 @@ public class AcceptanceTests { } private Releaser defaultMetaReleaser(ReleaserProperties properties) { - ProjectPomUpdater pomUpdater = new ProjectPomUpdater(properties); + ProjectPomUpdater pomUpdater = new ProjectPomUpdater(properties, bomParsers); ProjectCommandExecutor projectCommandExecutor = new ProjectCommandExecutor( properties); NonAssertingTestProjectGitHubHandler handler = new NonAssertingTestProjectGitHubHandler( @@ -745,7 +745,7 @@ public class AcceptanceTests { .spy(new SaganUpdater(this.saganClient, this.releaserProperties)); DocumentationUpdater documentationUpdater = Mockito .spy(new TestDocumentationUpdater(properties, - new TestDocumentationUpdater.TestProjectDocumentationUpdater( + new TestDocumentationUpdater.TestCustomProjectDocumentationUpdater( properties, nonAssertingGitHandler, "Brixton.SR1"), new TestDocumentationUpdater.TestReleaseContentsUpdater( properties, nonAssertingGitHandler, templateGenerator) {