Refactored core
This commit is contained in:
@@ -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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* 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,
|
||||
@@ -21,14 +21,24 @@ package org.springframework.cloud.release.cloud.buildsystem;
|
||||
*/
|
||||
final class SpringCloudBomConstants {
|
||||
|
||||
// boot
|
||||
static final String SPRING_BOOT = "spring-boot";
|
||||
static final String BOOT_STARTER_ARTIFACT_ID = "spring-boot-starter";
|
||||
static final String BOOT_STARTER_PARENT_ARTIFACT_ID = BOOT_STARTER_ARTIFACT_ID
|
||||
+ "-parent";
|
||||
static final String BOOT_DEPENDENCIES_ARTIFACT_ID = "spring-boot-dependencies";
|
||||
|
||||
// sc-build
|
||||
static final String CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID = "spring-cloud-dependencies-parent";
|
||||
static final String BUILD_ARTIFACT_ID = "spring-cloud-build";
|
||||
|
||||
// sc-release
|
||||
static final String CLOUD_DEPENDENCIES_ARTIFACT_ID = "spring-cloud-dependencies";
|
||||
static final String CLOUD_ARTIFACT_ID = "spring-cloud";
|
||||
static final String CLOUD_RELEASE_ARTIFACT_ID = "spring-cloud-release";
|
||||
static final String CLOUD_STARTER_ARTIFACT_ID = "spring-cloud-starter";
|
||||
static final String CLOUD_STARTER_PARENT_ARTIFACT_ID = "spring-cloud-starter-parent";
|
||||
|
||||
private SpringCloudBomConstants() {
|
||||
throw new IllegalStateException("Don't instantiate a utility class");
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* 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,
|
||||
@@ -30,11 +30,18 @@ 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 org.springframework.util.StringUtils;
|
||||
|
||||
import static org.springframework.cloud.release.cloud.buildsystem.SpringCloudBomConstants.BOOT_DEPENDENCIES_ARTIFACT_ID;
|
||||
import static org.springframework.cloud.release.cloud.buildsystem.SpringCloudBomConstants.BOOT_STARTER_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_ARTIFACT_ID;
|
||||
import static org.springframework.cloud.release.cloud.buildsystem.SpringCloudBomConstants.CLOUD_DEPENDENCIES_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.CLOUD_RELEASE_ARTIFACT_ID;
|
||||
import static org.springframework.cloud.release.cloud.buildsystem.SpringCloudBomConstants.CLOUD_STARTER_ARTIFACT_ID;
|
||||
import static org.springframework.cloud.release.cloud.buildsystem.SpringCloudBomConstants.CLOUD_STARTER_PARENT_ARTIFACT_ID;
|
||||
import static org.springframework.cloud.release.cloud.buildsystem.SpringCloudBomConstants.SPRING_BOOT;
|
||||
|
||||
public class SpringCloudMavenBomParser implements CustomBomParser {
|
||||
@@ -53,11 +60,31 @@ public class SpringCloudMavenBomParser implements CustomBomParser {
|
||||
public VersionsFromBom parseBom(File root, ReleaserProperties properties) {
|
||||
VersionsFromBom springCloudBuild = springCloudBuild(root, properties);
|
||||
VersionsFromBom boot = bootVersion(root, properties);
|
||||
return new VersionsFromBomBuilder().releaserProperties(properties)
|
||||
.projects(springCloudBuild, boot).versionsFromBom();
|
||||
return new VersionsFromBomBuilder().thisProjectRoot(root)
|
||||
.releaserProperties(properties).projects(springCloudBuild, boot).merged();
|
||||
}
|
||||
|
||||
private VersionsFromBom springCloudBuild(File root, ReleaserProperties properties) {
|
||||
String buildVersion = buildVersion(root, properties);
|
||||
if (StringUtils.isEmpty(buildVersion)) {
|
||||
return VersionsFromBom.EMPTY_VERSION;
|
||||
}
|
||||
VersionsFromBom scBuild = new VersionsFromBomBuilder().thisProjectRoot(root)
|
||||
.releaserProperties(properties).merged();
|
||||
scBuild.add(BUILD_ARTIFACT_ID, buildVersion);
|
||||
scBuild.add(CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildVersion);
|
||||
return scBuild;
|
||||
}
|
||||
|
||||
private String buildVersion(File root, ReleaserProperties properties) {
|
||||
String buildVersion = properties.getFixedVersions().get(BUILD_ARTIFACT_ID);
|
||||
if (StringUtils.hasText(buildVersion)) {
|
||||
return buildVersion;
|
||||
}
|
||||
File pom = new File(root, properties.getPom().getThisTrainBom());
|
||||
if (!pom.exists()) {
|
||||
return "";
|
||||
}
|
||||
Model model = PomReader.pom(root, properties.getPom().getThisTrainBom());
|
||||
String buildArtifact = model.getParent().getArtifactId();
|
||||
log.debug("[{}] artifact id is equal to [{}]",
|
||||
@@ -66,35 +93,48 @@ public class SpringCloudMavenBomParser implements CustomBomParser {
|
||||
throw new IllegalStateException(
|
||||
"The pom doesn't have a [spring-cloud-dependencies-parent] artifact id");
|
||||
}
|
||||
String buildVersion = model.getParent().getVersion();
|
||||
buildVersion = model.getParent().getVersion();
|
||||
log.debug("Spring Cloud Build version is equal to [{}]", buildVersion);
|
||||
VersionsFromBom scBuild = new VersionsFromBomBuilder()
|
||||
.releaserProperties(properties).versionsFromBom();
|
||||
scBuild.add(BUILD_ARTIFACT_ID, buildVersion);
|
||||
scBuild.add(CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildVersion);
|
||||
return scBuild;
|
||||
return buildVersion;
|
||||
}
|
||||
|
||||
VersionsFromBom bootVersion(File root, ReleaserProperties properties) {
|
||||
private String boot(File root, ReleaserProperties properties) {
|
||||
String bootVersion = properties.getFixedVersions().get(SPRING_BOOT);
|
||||
if (StringUtils.hasText(bootVersion)) {
|
||||
return bootVersion;
|
||||
}
|
||||
String pomWithBootStarterParent = properties.getPom()
|
||||
.getPomWithBootStarterParent();
|
||||
File pom = new File(root, pomWithBootStarterParent);
|
||||
if (!pom.exists()) {
|
||||
return "";
|
||||
}
|
||||
Model model = PomReader.pom(root, pomWithBootStarterParent);
|
||||
if (model == null) {
|
||||
return VersionsFromBom.EMPTY_VERSION;
|
||||
return "";
|
||||
}
|
||||
String bootArtifactId = model.getParent().getArtifactId();
|
||||
log.debug("Boot artifact id is equal to [{}]", bootArtifactId);
|
||||
if (!SpringCloudBomConstants.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 ["
|
||||
+ SpringCloudBomConstants.BOOT_STARTER_PARENT_ARTIFACT_ID + "] artifact id");
|
||||
+ SpringCloudBomConstants.BOOT_STARTER_PARENT_ARTIFACT_ID
|
||||
+ "] artifact id");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
return model.getParent().getVersion();
|
||||
}
|
||||
|
||||
VersionsFromBom bootVersion(File root, ReleaserProperties properties) {
|
||||
String bootVersion = boot(root, properties);
|
||||
if (StringUtils.isEmpty(bootVersion)) {
|
||||
return VersionsFromBom.EMPTY_VERSION;
|
||||
}
|
||||
String bootVersion = model.getParent().getVersion();
|
||||
log.debug("Boot version is equal to [{}]", bootVersion);
|
||||
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder()
|
||||
.releaserProperties(properties).versionsFromBom();
|
||||
.thisProjectRoot(root).releaserProperties(properties).merged();
|
||||
versionsFromBom.add(SPRING_BOOT, bootVersion);
|
||||
versionsFromBom.add(BOOT_STARTER_PARENT_ARTIFACT_ID, bootVersion);
|
||||
versionsFromBom.add(BOOT_DEPENDENCIES_ARTIFACT_ID, bootVersion);
|
||||
@@ -107,6 +147,7 @@ public class SpringCloudMavenBomParser implements CustomBomParser {
|
||||
Set<Project> newProjects = new LinkedHashSet<>(projects);
|
||||
switch (projectName) {
|
||||
case SPRING_BOOT:
|
||||
case BOOT_STARTER_ARTIFACT_ID:
|
||||
case BOOT_STARTER_PARENT_ARTIFACT_ID:
|
||||
case BOOT_DEPENDENCIES_ARTIFACT_ID:
|
||||
updateBootVersions(newProjects, version);
|
||||
@@ -115,15 +156,24 @@ public class SpringCloudMavenBomParser implements CustomBomParser {
|
||||
case CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID:
|
||||
updateBuildVersions(newProjects, version);
|
||||
break;
|
||||
case CLOUD_ARTIFACT_ID:
|
||||
case CLOUD_DEPENDENCIES_ARTIFACT_ID:
|
||||
case CLOUD_RELEASE_ARTIFACT_ID:
|
||||
case CLOUD_STARTER_ARTIFACT_ID:
|
||||
case CLOUD_STARTER_PARENT_ARTIFACT_ID:
|
||||
updateSpringCloudVersions(newProjects, version);
|
||||
break;
|
||||
}
|
||||
return newProjects;
|
||||
}
|
||||
|
||||
private void updateBootVersions(Set<Project> newProjects, String version) {
|
||||
remove(newProjects, SPRING_BOOT);
|
||||
remove(newProjects, BOOT_DEPENDENCIES_ARTIFACT_ID);
|
||||
remove(newProjects, BOOT_STARTER_ARTIFACT_ID);
|
||||
remove(newProjects, BOOT_STARTER_PARENT_ARTIFACT_ID);
|
||||
remove(newProjects, BOOT_DEPENDENCIES_ARTIFACT_ID);
|
||||
add(newProjects, SPRING_BOOT, version);
|
||||
add(newProjects, BOOT_STARTER_ARTIFACT_ID, version);
|
||||
add(newProjects, BOOT_STARTER_PARENT_ARTIFACT_ID, version);
|
||||
add(newProjects, BOOT_DEPENDENCIES_ARTIFACT_ID, version);
|
||||
}
|
||||
@@ -135,6 +185,19 @@ public class SpringCloudMavenBomParser implements CustomBomParser {
|
||||
add(newProjects, CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, version);
|
||||
}
|
||||
|
||||
private void updateSpringCloudVersions(Set<Project> newProjects, String version) {
|
||||
remove(newProjects, CLOUD_DEPENDENCIES_ARTIFACT_ID);
|
||||
remove(newProjects, CLOUD_ARTIFACT_ID);
|
||||
remove(newProjects, CLOUD_RELEASE_ARTIFACT_ID);
|
||||
remove(newProjects, CLOUD_STARTER_ARTIFACT_ID);
|
||||
remove(newProjects, CLOUD_STARTER_PARENT_ARTIFACT_ID);
|
||||
add(newProjects, CLOUD_DEPENDENCIES_ARTIFACT_ID, version);
|
||||
add(newProjects, CLOUD_ARTIFACT_ID, version);
|
||||
add(newProjects, CLOUD_RELEASE_ARTIFACT_ID, version);
|
||||
add(newProjects, CLOUD_STARTER_ARTIFACT_ID, version);
|
||||
add(newProjects, CLOUD_STARTER_PARENT_ARTIFACT_ID, version);
|
||||
}
|
||||
|
||||
private void add(Set<Project> projects, String key, String value) {
|
||||
projects.add(new Project(key, value));
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* 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,
|
||||
@@ -23,8 +23,6 @@ import java.nio.file.Files;
|
||||
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.docs.CustomProjectDocumentationUpdater;
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
@@ -32,7 +30,8 @@ import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
class SpringCloudCustomProjectDocumentationUpdater implements CustomProjectDocumentationUpdater, ReleaserPropertiesAware {
|
||||
class SpringCloudCustomProjectDocumentationUpdater
|
||||
implements CustomProjectDocumentationUpdater {
|
||||
|
||||
private static final String HTTP_SC_STATIC_URL = "http://cloud.spring.io/spring-cloud-static/";
|
||||
|
||||
@@ -43,17 +42,15 @@ class SpringCloudCustomProjectDocumentationUpdater implements CustomProjectDocum
|
||||
|
||||
private final ProjectGitHandler gitHandler;
|
||||
|
||||
private ReleaserProperties properties;
|
||||
|
||||
SpringCloudCustomProjectDocumentationUpdater(ReleaserProperties properties,
|
||||
ProjectGitHandler gitHandler) {
|
||||
SpringCloudCustomProjectDocumentationUpdater(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");
|
||||
public boolean isApplicable(File clonedDocumentationProject,
|
||||
ProjectVersion currentProject, String bomBranch) {
|
||||
return clonedDocumentationProject.getName().startsWith("spring-cloud")
|
||||
|| currentProject.projectName.startsWith("spring-cloud");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,28 +62,20 @@ class SpringCloudCustomProjectDocumentationUpdater implements CustomProjectDocum
|
||||
* used
|
||||
*/
|
||||
@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 "
|
||||
+ "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);
|
||||
public File updateDocsRepo(File clonedDocumentationProject,
|
||||
ProjectVersion currentProject, String bomBranch) {
|
||||
log.debug("Cloning the doc project to [{}]", clonedDocumentationProject);
|
||||
String pathToIndexHtml = "current/index.html";
|
||||
File indexHtml = new File(documentationProject, pathToIndexHtml);
|
||||
File indexHtml = indexHtml(clonedDocumentationProject, pathToIndexHtml);
|
||||
if (!indexHtml.exists()) {
|
||||
throw new IllegalStateException(
|
||||
"index.html is not present at [" + pathToIndexHtml + "]");
|
||||
}
|
||||
return updateTheDocsRepo(bomBranch, documentationProject, indexHtml);
|
||||
return updateTheDocsRepo(bomBranch, clonedDocumentationProject, indexHtml);
|
||||
}
|
||||
|
||||
File indexHtml(File clonedDocumentationProject, String pathToIndexHtml) {
|
||||
return new File(clonedDocumentationProject, pathToIndexHtml);
|
||||
}
|
||||
|
||||
private File updateTheDocsRepo(String springCloudReleaseBranch,
|
||||
@@ -109,10 +98,9 @@ class SpringCloudCustomProjectDocumentationUpdater implements CustomProjectDocum
|
||||
springCloudReleaseBranch);
|
||||
String firstLetterOfCurrentReleaseTrain = String
|
||||
.valueOf(currentReleaseTrainVersion.charAt(0));
|
||||
boolean newerOrEqualReleaseTrain = (!storedReleaseTrain
|
||||
.equals(currentReleaseTrainVersion))
|
||||
&& firstLetterOfCurrentReleaseTrain
|
||||
.compareToIgnoreCase(firstLetterOfReleaseTrain) >= 0;
|
||||
boolean newerOrEqualReleaseTrain = isNewerOrEqualReleaseTrain(
|
||||
storedReleaseTrain, firstLetterOfReleaseTrain,
|
||||
currentReleaseTrainVersion, firstLetterOfCurrentReleaseTrain);
|
||||
if (!newerOrEqualReleaseTrain) {
|
||||
log.info(
|
||||
"Current release train [{}] is not newer than the stored one [{}]",
|
||||
@@ -127,6 +115,14 @@ class SpringCloudCustomProjectDocumentationUpdater implements CustomProjectDocum
|
||||
}
|
||||
}
|
||||
|
||||
boolean isNewerOrEqualReleaseTrain(String storedReleaseTrain,
|
||||
String firstLetterOfReleaseTrain, String currentReleaseTrainVersion,
|
||||
String firstLetterOfCurrentReleaseTrain) {
|
||||
return (!storedReleaseTrain.equals(currentReleaseTrainVersion))
|
||||
&& firstLetterOfCurrentReleaseTrain
|
||||
.compareToIgnoreCase(firstLetterOfReleaseTrain) >= 0;
|
||||
}
|
||||
|
||||
private int beginIndex(int httpIndex, int httpsIndex) {
|
||||
if (httpIndex != -1) {
|
||||
return httpIndex + HTTP_SC_STATIC_URL.length();
|
||||
@@ -161,9 +157,4 @@ class SpringCloudCustomProjectDocumentationUpdater implements CustomProjectDocum
|
||||
return new String(Files.readAllBytes(indexHtml.toPath()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReleaserProperties(ReleaserProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class Releaser implements ReleaserPropertiesAware {
|
||||
return this.projectGitHandler.cloneProjectFromOrg(projectName);
|
||||
}
|
||||
|
||||
public Projects retrieveVersionsFromSCRelease() {
|
||||
public Projects retrieveVersionsFromBom() {
|
||||
return this.projectPomUpdater.retrieveVersionsFromReleaseTrainBom();
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* 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,
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.cloud.release.internal.buildsystem;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Parses the bom and returns all parsed versions.
|
||||
@@ -35,4 +36,9 @@ interface BomParser {
|
||||
*/
|
||||
VersionsFromBom versionsFromBom(File thisProjectRoot);
|
||||
|
||||
/**
|
||||
* @return a list of available custom bom parsers
|
||||
*/
|
||||
List<CustomBomParser> customBomParsers();
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* 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,
|
||||
@@ -18,6 +18,7 @@ package org.springframework.cloud.release.internal.buildsystem;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class CompositeBomParser implements BomParser {
|
||||
|
||||
@@ -43,4 +44,10 @@ class CompositeBomParser implements BomParser {
|
||||
() -> new IllegalStateException("Can't find a matching parser"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CustomBomParser> customBomParsers() {
|
||||
return this.parsers.stream().flatMap(b -> b.customBomParsers().stream())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* 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,
|
||||
|
||||
@@ -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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* 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,
|
||||
@@ -36,7 +36,8 @@ class GradleBomParser implements BomParser {
|
||||
|
||||
private final List<CustomBomParser> customParsers;
|
||||
|
||||
GradleBomParser(ReleaserProperties releaserProperties, List<CustomBomParser> customParsers) {
|
||||
GradleBomParser(ReleaserProperties releaserProperties,
|
||||
List<CustomBomParser> customParsers) {
|
||||
this.properties = releaserProperties;
|
||||
this.customParsers = customParsers;
|
||||
}
|
||||
@@ -59,9 +60,9 @@ class GradleBomParser implements BomParser {
|
||||
Properties properties = loadProps(gradleProperties);
|
||||
final Map<String, String> substitution = this.properties.getGradle()
|
||||
.getGradlePropsSubstitution();
|
||||
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder().releaserProperties(this.properties)
|
||||
.parsers(this.customParsers)
|
||||
.versionsFromBom();
|
||||
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder()
|
||||
.thisProjectRoot(thisProjectRoot).releaserProperties(this.properties)
|
||||
.parsers(this.customParsers).retrieveFromBom();
|
||||
properties.forEach((key, value) -> {
|
||||
String projectName = projectName(substitution, key);
|
||||
versionsFromBom.setVersion(projectName, value.toString());
|
||||
@@ -96,4 +97,9 @@ class GradleBomParser implements BomParser {
|
||||
return props;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CustomBomParser> customBomParsers() {
|
||||
return this.customParsers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -78,10 +78,11 @@ class MavenBomParser implements BomParser {
|
||||
releaseTrainProjectVersion));
|
||||
// @formatter:off
|
||||
return new VersionsFromBomBuilder()
|
||||
.thisProjectRoot(thisProjectRoot)
|
||||
.releaserProperties(this.properties)
|
||||
.parsers(this.customParsers)
|
||||
.projects(projects)
|
||||
.versionsFromBom();
|
||||
.retrieveFromBom();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@@ -99,4 +100,9 @@ class MavenBomParser implements BomParser {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CustomBomParser> customBomParsers() {
|
||||
return this.customParsers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ class PomUpdater {
|
||||
}
|
||||
|
||||
ModelWrapper readModel(File pom) {
|
||||
return new ModelWrapper(PomReader.readPom(pom));
|
||||
return new ModelWrapper(PomReader.readPom(pom), pom);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,7 +152,7 @@ class PomUpdater {
|
||||
sourceChanges);
|
||||
sourceChanges = updateVersionIfPossible(rootPom, versionsFromBom, model,
|
||||
sourceChanges);
|
||||
return new ModelWrapper(model, sourceChanges, versionsFromBom);
|
||||
return new ModelWrapper(model, sourceChanges, versionsFromBom, pom);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,16 +267,26 @@ class ModelWrapper {
|
||||
|
||||
final List<VersionChange> sourceChanges = new ArrayList<>();
|
||||
|
||||
final File rootFile;
|
||||
|
||||
ModelWrapper(Model model, List<VersionChange> sourceChanges,
|
||||
VersionsFromBom versionsFromBom) {
|
||||
VersionsFromBom versionsFromBom, File rootFile) {
|
||||
this.model = model;
|
||||
this.versionsFromBom = versionsFromBom;
|
||||
this.sourceChanges.addAll(sourceChanges);
|
||||
this.rootFile = rootFile;
|
||||
}
|
||||
|
||||
ModelWrapper(Model model, File rootFile) {
|
||||
this.model = model;
|
||||
this.versionsFromBom = VersionsFromBom.EMPTY_VERSION;
|
||||
this.rootFile = rootFile;
|
||||
}
|
||||
|
||||
ModelWrapper(Model model) {
|
||||
this.model = model;
|
||||
this.versionsFromBom = VersionsFromBom.EMPTY_VERSION;
|
||||
this.rootFile = null;
|
||||
}
|
||||
|
||||
String projectName() {
|
||||
|
||||
@@ -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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* 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,
|
||||
|
||||
@@ -91,11 +91,7 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
|
||||
// TODO: I don't like this flag but don't have a better idea
|
||||
public Projects retrieveVersionsFromReleaseTrainBom(String branch,
|
||||
boolean updateFixedVersions) {
|
||||
VersionsFromBom versionsFromBom = CACHE.computeIfAbsent(branch, s -> {
|
||||
File clonedBom = this.gitRepo.cloneReleaseTrainProject();
|
||||
this.gitRepo.checkout(clonedBom, branch);
|
||||
return new CompositeBomParser(this.bomParsers).versionsFromBom(clonedBom);
|
||||
});
|
||||
VersionsFromBom versionsFromBom = cachedVersionFromBom(branch);
|
||||
if (updateFixedVersions) {
|
||||
log.info("Will update the following versions manually [{}]",
|
||||
this.properties.getFixedVersions());
|
||||
@@ -105,6 +101,18 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
|
||||
return versionsFromBom.toProjectVersions();
|
||||
}
|
||||
|
||||
private VersionsFromBom cachedVersionFromBom(String branch) {
|
||||
return CACHE.computeIfAbsent(branch, s -> {
|
||||
File clonedBom = this.gitRepo.cloneReleaseTrainProject();
|
||||
this.gitRepo.checkout(clonedBom, branch);
|
||||
return compositeBomParser().versionsFromBom(clonedBom);
|
||||
});
|
||||
}
|
||||
|
||||
private CompositeBomParser compositeBomParser() {
|
||||
return new CompositeBomParser(this.bomParsers);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return map of fixed versions
|
||||
*/
|
||||
@@ -116,7 +124,8 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
|
||||
log.debug("Will apply the following fixed versions {}", projects);
|
||||
}
|
||||
return new VersionsFromBomBuilder().releaserProperties(this.properties)
|
||||
.projects(projects).versionsFromBom().toProjectVersions();
|
||||
.parsers(compositeBomParser().customBomParsers()).projects(projects)
|
||||
.merged().toProjectVersions();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,16 +141,16 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
|
||||
public void updateProjectFromReleaseTrain(File projectRoot, Projects projects,
|
||||
ProjectVersion versionFromReleaseTrain, boolean assertVersions) {
|
||||
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder()
|
||||
.releaserProperties(this.properties).projects(projects.asProjects())
|
||||
.versionsFromBom();
|
||||
.thisProjectRoot(projectRoot).releaserProperties(this.properties)
|
||||
.projects(projects.asProjects()).merged();
|
||||
if (!this.pomUpdater.shouldProjectBeUpdated(projectRoot, versionsFromBom)) {
|
||||
log.info("Skipping project updating");
|
||||
return;
|
||||
}
|
||||
updatePoms(projectRoot, projects, versionFromReleaseTrain, assertVersions);
|
||||
updatePoms(projectRoot, versionsFromBom, versionFromReleaseTrain, assertVersions);
|
||||
}
|
||||
|
||||
private void updatePoms(File projectRoot, Projects projects,
|
||||
private void updatePoms(File projectRoot, VersionsFromBom projects,
|
||||
ProjectVersion versionFromScRelease, boolean assertVersions) {
|
||||
File rootPom = new File(projectRoot, "pom.xml");
|
||||
if (!rootPom.exists()) {
|
||||
@@ -185,13 +194,11 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
|
||||
|
||||
private final List<Pattern> unacceptableVersionPatterns;
|
||||
|
||||
private PomWalker(ModelWrapper rootPom, Projects projects, PomUpdater pomUpdater,
|
||||
ReleaserProperties properties, ProjectVersion versionFromScRelease,
|
||||
boolean assertVersions) {
|
||||
private PomWalker(ModelWrapper rootPom, VersionsFromBom projects,
|
||||
PomUpdater pomUpdater, ReleaserProperties properties,
|
||||
ProjectVersion versionFromScRelease, boolean assertVersions) {
|
||||
this.rootPom = rootPom;
|
||||
this.versionsFromBom = new VersionsFromBomBuilder()
|
||||
.releaserProperties(properties).projects(projects.asProjects())
|
||||
.versionsFromBom();
|
||||
this.versionsFromBom = projects;
|
||||
this.pomUpdater = pomUpdater;
|
||||
this.properties = properties;
|
||||
List<Pattern> unacceptableVersionPatterns = versionFromScRelease
|
||||
|
||||
@@ -66,7 +66,7 @@ public class ProjectVersion implements Comparable<ProjectVersion> {
|
||||
private final String artifactId;
|
||||
|
||||
public ProjectVersion(String projectName, String version) {
|
||||
this.projectName = nameWithoutParent(projectName);
|
||||
this.projectName = projectName;
|
||||
this.version = version;
|
||||
this.groupId = "";
|
||||
this.artifactId = "";
|
||||
|
||||
@@ -35,13 +35,13 @@ import org.springframework.cloud.release.internal.project.Projects;
|
||||
*/
|
||||
public class VersionsFromBom {
|
||||
|
||||
public static final VersionsFromBom EMPTY_VERSION = new VersionsFromBomBuilder().versionsFromBom();
|
||||
public static final VersionsFromBom EMPTY_VERSION = new VersionsFromBom();
|
||||
|
||||
Set<Project> projects = new HashSet<>();
|
||||
|
||||
ReleaserProperties properties;
|
||||
|
||||
CustomBomParser parser = CustomBomParser.NO_OP;
|
||||
CustomBomParser parser;
|
||||
|
||||
private VersionsFromBom() {
|
||||
this.properties = new ReleaserProperties();
|
||||
@@ -52,13 +52,15 @@ public class VersionsFromBom {
|
||||
this.parser = parser;
|
||||
}
|
||||
|
||||
VersionsFromBom(ReleaserProperties releaserProperties, CustomBomParser parser, Set<Project> projects) {
|
||||
VersionsFromBom(ReleaserProperties releaserProperties, CustomBomParser parser,
|
||||
Set<Project> projects) {
|
||||
this.properties = releaserProperties;
|
||||
this.parser = parser;
|
||||
projects.forEach(project -> setVersion(project.name, project.version));
|
||||
}
|
||||
|
||||
VersionsFromBom(ReleaserProperties releaserProperties, CustomBomParser parser, 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));
|
||||
|
||||
@@ -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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* 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,
|
||||
@@ -34,6 +34,13 @@ public class VersionsFromBomBuilder {
|
||||
|
||||
private List<CustomBomParser> parsers = new ArrayList<>();
|
||||
|
||||
private File thisProjectRoot;
|
||||
|
||||
public VersionsFromBomBuilder thisProjectRoot(File thisProjectRoot) {
|
||||
this.thisProjectRoot = thisProjectRoot;
|
||||
return this;
|
||||
}
|
||||
|
||||
public VersionsFromBomBuilder releaserProperties(
|
||||
ReleaserProperties releaserProperties) {
|
||||
this.releaserProperties = releaserProperties;
|
||||
@@ -55,15 +62,35 @@ public class VersionsFromBomBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public VersionsFromBom versionsFromBom() {
|
||||
File thisProjectRoot = new File(this.releaserProperties.getWorkingDir());
|
||||
CustomBomParser bomParser = this.parsers
|
||||
public VersionsFromBom merged() {
|
||||
File thisProjectRoot = thisProjectRoot();
|
||||
CustomBomParser bomParser = parser(thisProjectRoot);
|
||||
if (!this.projects.isEmpty()) {
|
||||
return new VersionsFromBom(this.releaserProperties, bomParser, this.projects);
|
||||
}
|
||||
return new VersionsFromBom(this.releaserProperties, bomParser,
|
||||
this.versionsFromBom);
|
||||
}
|
||||
|
||||
public VersionsFromBom retrieveFromBom() {
|
||||
File thisProjectRoot = thisProjectRoot();
|
||||
CustomBomParser bomParser = parser(thisProjectRoot);
|
||||
VersionsFromBom versionsFromBom = versionsFromBom(bomParser);
|
||||
VersionsFromBom customParsing = customParsing(thisProjectRoot, this.projects);
|
||||
return new VersionsFromBom(this.releaserProperties, bomParser, versionsFromBom,
|
||||
customParsing);
|
||||
}
|
||||
|
||||
private File thisProjectRoot() {
|
||||
return this.thisProjectRoot != null ? this.thisProjectRoot
|
||||
: new File(this.releaserProperties.getWorkingDir());
|
||||
}
|
||||
|
||||
private CustomBomParser parser(File thisProjectRoot) {
|
||||
return 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) {
|
||||
@@ -79,16 +106,15 @@ public class VersionsFromBomBuilder {
|
||||
|
||||
private VersionsFromBom customParsing(File thisProjectRoot, Set<Project> projects) {
|
||||
return this.parsers.stream()
|
||||
.filter(p -> p.isApplicable(thisProjectRoot, this.releaserProperties, projects))
|
||||
.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())
|
||||
.parsers(this.parsers).thisProjectRoot(thisProjectRoot)
|
||||
.releaserProperties(this.releaserProperties)
|
||||
.projects(versionsFromBom, versionsFromBom2).merged())
|
||||
.orElse(VersionsFromBom.EMPTY_VERSION);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -30,25 +30,26 @@ import org.springframework.cloud.release.internal.template.TemplateGenerator;
|
||||
*/
|
||||
public class DocumentationUpdater implements ReleaserPropertiesAware {
|
||||
|
||||
private final DefaultProjectDocumentationUpdater defaultProjectDocumentationUpdater;
|
||||
private final ProjectDocumentationUpdater projectDocumentationUpdater;
|
||||
|
||||
private final ReleaseTrainContentsUpdater releaseTrainContentsUpdater;
|
||||
|
||||
private ReleaserProperties properties;
|
||||
|
||||
public DocumentationUpdater(ProjectGitHandler gitHandler,
|
||||
ReleaserProperties properties, TemplateGenerator templateGenerator, DefaultProjectDocumentationUpdater updater) {
|
||||
ReleaserProperties properties, TemplateGenerator templateGenerator,
|
||||
ProjectDocumentationUpdater updater) {
|
||||
this.properties = properties;
|
||||
this.defaultProjectDocumentationUpdater = updater;
|
||||
this.projectDocumentationUpdater = updater;
|
||||
this.releaseTrainContentsUpdater = new ReleaseTrainContentsUpdater(
|
||||
this.properties, gitHandler, templateGenerator);
|
||||
}
|
||||
|
||||
DocumentationUpdater(ReleaserProperties properties,
|
||||
DefaultProjectDocumentationUpdater updater,
|
||||
ProjectDocumentationUpdater updater,
|
||||
ReleaseTrainContentsUpdater contentsUpdater) {
|
||||
this.properties = properties;
|
||||
this.defaultProjectDocumentationUpdater = updater;
|
||||
this.projectDocumentationUpdater = updater;
|
||||
this.releaseTrainContentsUpdater = contentsUpdater;
|
||||
}
|
||||
|
||||
@@ -61,7 +62,7 @@ public class DocumentationUpdater implements ReleaserPropertiesAware {
|
||||
* used
|
||||
*/
|
||||
public File updateDocsRepo(ProjectVersion currentProject, String bomReleaseBranch) {
|
||||
return this.defaultProjectDocumentationUpdater.updateDocsRepo(currentProject,
|
||||
return this.projectDocumentationUpdater.updateDocsRepo(currentProject,
|
||||
bomReleaseBranch);
|
||||
}
|
||||
|
||||
@@ -92,7 +93,7 @@ public class DocumentationUpdater implements ReleaserPropertiesAware {
|
||||
public void setReleaserProperties(ReleaserProperties properties) {
|
||||
this.properties = properties;
|
||||
this.releaseTrainContentsUpdater.setReleaserProperties(properties);
|
||||
this.defaultProjectDocumentationUpdater.setReleaserProperties(properties);
|
||||
this.projectDocumentationUpdater.setReleaserProperties(properties);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.cloud.release.internal.docs;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@@ -31,10 +30,10 @@ import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
class DefaultProjectDocumentationUpdater implements ReleaserPropertiesAware {
|
||||
public class ProjectDocumentationUpdater implements ReleaserPropertiesAware {
|
||||
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(DefaultProjectDocumentationUpdater.class);
|
||||
.getLogger(ProjectDocumentationUpdater.class);
|
||||
|
||||
private final ProjectGitHandler gitHandler;
|
||||
|
||||
@@ -42,7 +41,7 @@ class DefaultProjectDocumentationUpdater implements ReleaserPropertiesAware {
|
||||
|
||||
private final List<CustomProjectDocumentationUpdater> updaters;
|
||||
|
||||
DefaultProjectDocumentationUpdater(ReleaserProperties properties,
|
||||
public ProjectDocumentationUpdater(ReleaserProperties properties,
|
||||
ProjectGitHandler gitHandler,
|
||||
List<CustomProjectDocumentationUpdater> updaters) {
|
||||
this.gitHandler = gitHandler;
|
||||
@@ -50,13 +49,6 @@ class DefaultProjectDocumentationUpdater implements ReleaserPropertiesAware {
|
||||
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(
|
||||
@@ -79,6 +79,10 @@ public class ProjectGitHandler implements ReleaserPropertiesAware {
|
||||
}
|
||||
}
|
||||
|
||||
static void clearCache() {
|
||||
CACHE.clear();
|
||||
}
|
||||
|
||||
public void commitAfterBumpingVersions(File project, ProjectVersion bumpedVersion) {
|
||||
if (bumpedVersion.isSnapshot()) {
|
||||
log.info("Snapshot version [{}] found. Will only commit the changed poms",
|
||||
|
||||
@@ -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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
@@ -21,6 +21,9 @@ import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import edu.emory.mathcs.backport.java.util.Collections;
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@@ -31,6 +34,7 @@ import org.mockito.BDDMockito;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.buildsystem.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.buildsystem.TestUtils;
|
||||
import org.springframework.cloud.release.internal.docs.ProjectDocumentationUpdater;
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
@@ -78,11 +82,8 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
|
||||
file("/projects/spring-cloud-release/").toURI().toString());
|
||||
|
||||
BDDAssertions
|
||||
.thenThrownBy(
|
||||
() -> new SpringCloudCustomProjectDocumentationUpdater(properties,
|
||||
new ProjectGitHandler(properties)).updateDocsRepo(
|
||||
this.clonedDocProject, releaseTrainVersion,
|
||||
"vAngel.SR33"))
|
||||
.thenThrownBy(() -> projectDocumentationUpdaterWithNoIndexHtml(properties)
|
||||
.updateDocsRepo(releaseTrainVersion, "vAngel.SR33"))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("index.html is not present");
|
||||
}
|
||||
@@ -96,15 +97,18 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
|
||||
properties.getGit().setDocumentationUrl(
|
||||
file("/projects/spring-cloud-static/").toURI().toString());
|
||||
|
||||
BDDAssertions.thenThrownBy(
|
||||
() -> new SpringCloudCustomProjectDocumentationUpdater(properties,
|
||||
new ProjectGitHandler(properties)) {
|
||||
@Override
|
||||
String readIndexHtmlContents(File indexHtml) {
|
||||
return "";
|
||||
}
|
||||
}.updateDocsRepo(this.clonedDocProject, releaseTrainVersion,
|
||||
"vAngel.SR33"))
|
||||
SpringCloudCustomProjectDocumentationUpdater customUpdater = new SpringCloudCustomProjectDocumentationUpdater(
|
||||
new ProjectGitHandler(properties)) {
|
||||
@Override
|
||||
String readIndexHtmlContents(File indexHtml) {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
BDDAssertions
|
||||
.thenThrownBy(() -> new ProjectDocumentationUpdater(properties,
|
||||
this.handler, Collections.singletonList(customUpdater))
|
||||
.updateDocsRepo(releaseTrainVersion, "vAngel.SR33"))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("The URL to the documentation repo not found");
|
||||
}
|
||||
@@ -115,13 +119,47 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
|
||||
"2.0.0.BUILD-SNAPSHOT");
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
|
||||
File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(properties,
|
||||
new ProjectGitHandler(properties)).updateDocsRepo(this.clonedDocProject,
|
||||
releaseTrainVersion, "vAngel.M7");
|
||||
File updatedDocs = projectDocumentationUpdater(properties)
|
||||
.updateDocsRepo(releaseTrainVersion, "vAngel.M7");
|
||||
|
||||
then(updatedDocs).isNull();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private ProjectDocumentationUpdater projectDocumentationUpdater(
|
||||
ReleaserProperties properties) {
|
||||
return new ProjectDocumentationUpdater(properties, this.handler,
|
||||
Collections.singletonList(
|
||||
new SpringCloudCustomProjectDocumentationUpdater(this.handler) {
|
||||
@Override
|
||||
boolean isNewerOrEqualReleaseTrain(String storedReleaseTrain,
|
||||
String firstLetterOfReleaseTrain,
|
||||
String currentReleaseTrainVersion,
|
||||
String firstLetterOfCurrentReleaseTrain) {
|
||||
return true;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private ProjectDocumentationUpdater projectDocumentationUpdaterWithNoIndexHtml(
|
||||
ReleaserProperties properties) {
|
||||
return new ProjectDocumentationUpdater(properties, this.handler,
|
||||
Collections.singletonList(
|
||||
new SpringCloudCustomProjectDocumentationUpdater(this.handler) {
|
||||
@Override
|
||||
File indexHtml(File clonedDocumentationProject,
|
||||
String pathToIndexHtml) {
|
||||
return new File("non/existent/file");
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private ProjectGitHandler projectGitHandler(ReleaserProperties properties) {
|
||||
return new ProjectGitHandler(properties);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_not_update_current_version_in_the_docs_if_current_release_starts_with_v_and_then_lower_letter_than_the_stored_release()
|
||||
throws URISyntaxException, IOException {
|
||||
@@ -131,7 +169,7 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
|
||||
properties.getGit().setDocumentationUrl(
|
||||
file("/projects/spring-cloud-static/").toURI().toString());
|
||||
|
||||
File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(properties,
|
||||
File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(
|
||||
new ProjectGitHandler(properties)).updateDocsRepo(this.clonedDocProject,
|
||||
releaseTrainVersion, "vAngel.SR33");
|
||||
|
||||
@@ -149,9 +187,8 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
|
||||
properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString());
|
||||
ProjectGitHandler handler = BDDMockito.spy(new ProjectGitHandler(properties));
|
||||
|
||||
new SpringCloudCustomProjectDocumentationUpdater(properties, handler)
|
||||
.updateDocsRepo(this.clonedDocProject, releaseTrainVersion,
|
||||
"vDalston.SR3");
|
||||
new SpringCloudCustomProjectDocumentationUpdater(handler).updateDocsRepo(
|
||||
this.clonedDocProject, releaseTrainVersion, "vDalston.SR3");
|
||||
|
||||
BDDMockito.then(handler).should(BDDMockito.never())
|
||||
.commit(BDDMockito.any(File.class), BDDMockito.anyString());
|
||||
@@ -165,7 +202,7 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString());
|
||||
|
||||
File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(properties,
|
||||
File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(
|
||||
new ProjectGitHandler(properties)).updateDocsRepo(this.clonedDocProject,
|
||||
releaseTrainVersion, "Angel.SR33");
|
||||
|
||||
@@ -183,9 +220,8 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString());
|
||||
|
||||
File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(properties,
|
||||
new ProjectGitHandler(properties)).updateDocsRepo(this.clonedDocProject,
|
||||
releaseTrainVersion, "vFinchley.SR33");
|
||||
File updatedDocs = projectDocumentationUpdater(properties)
|
||||
.updateDocsRepo(releaseTrainVersion, "vFinchley.SR33");
|
||||
|
||||
String indexHtmlContent = new String(
|
||||
Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath()));
|
||||
@@ -201,9 +237,8 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString());
|
||||
|
||||
File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(properties,
|
||||
new ProjectGitHandler(properties)).updateDocsRepo(this.clonedDocProject,
|
||||
releaseTrainVersion, "Finchley.SR33");
|
||||
File updatedDocs = projectDocumentationUpdater(properties)
|
||||
.updateDocsRepo(releaseTrainVersion, "Finchley.SR33");
|
||||
|
||||
String indexHtmlContent = new String(
|
||||
Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath()));
|
||||
@@ -219,9 +254,8 @@ public class SpringCloudCustomProjectDocumentationUpdaterTests {
|
||||
properties.getGit().setDocumentationUrl(this.clonedDocProject.toURI().toString());
|
||||
properties.getGit().setUpdateDocumentationRepo(false);
|
||||
|
||||
File updatedDocs = new SpringCloudCustomProjectDocumentationUpdater(properties,
|
||||
new ProjectGitHandler(properties)).updateDocsRepo(this.clonedDocProject,
|
||||
releaseTrainVersion, "Finchley.SR33");
|
||||
File updatedDocs = projectDocumentationUpdater(properties)
|
||||
.updateDocsRepo(releaseTrainVersion, "Finchley.SR33");
|
||||
|
||||
then(updatedDocs).isNull();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
@@ -29,6 +29,7 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import org.springframework.cloud.release.internal.buildsystem.MavenBomParserAccessor;
|
||||
import org.springframework.cloud.release.internal.buildsystem.PomReader;
|
||||
import org.springframework.cloud.release.internal.buildsystem.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.buildsystem.ProjectVersion;
|
||||
@@ -59,7 +60,9 @@ 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, new ArrayList<>());
|
||||
ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties,
|
||||
Collections.singletonList(
|
||||
MavenBomParserAccessor.cloudMavenBomParser(releaserProperties)));
|
||||
Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom();
|
||||
File project = new File(this.temporaryFolder, "/spring-cloud-sleuth");
|
||||
|
||||
@@ -91,7 +94,9 @@ 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, new ArrayList<>());
|
||||
ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties,
|
||||
Collections.singletonList(
|
||||
MavenBomParserAccessor.cloudMavenBomParser(releaserProperties)));
|
||||
Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom();
|
||||
projects.add(new ProjectVersion("spring-cloud-sleuth-samples", "0.0.5.RELEASE"));
|
||||
File project = new File(this.temporaryFolder,
|
||||
@@ -113,7 +118,9 @@ 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, new ArrayList<>());
|
||||
ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties,
|
||||
Collections.singletonList(
|
||||
MavenBomParserAccessor.cloudMavenBomParser(releaserProperties)));
|
||||
Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom();
|
||||
File project = new File(this.temporaryFolder,
|
||||
"/spring-cloud-sleuth-with-unmatched-property");
|
||||
@@ -129,7 +136,9 @@ 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, new ArrayList<>());
|
||||
ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties,
|
||||
Collections.singletonList(
|
||||
MavenBomParserAccessor.cloudMavenBomParser(releaserProperties)));
|
||||
Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom();
|
||||
projects.removeIf(projectVersion -> projectVersion.projectName
|
||||
.contains("spring-cloud-build"));
|
||||
@@ -145,7 +154,9 @@ 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, new ArrayList<>());
|
||||
ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties,
|
||||
Collections.singletonList(
|
||||
MavenBomParserAccessor.cloudMavenBomParser(releaserProperties)));
|
||||
File beforeProcessing = pom("/projects/project/");
|
||||
Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom();
|
||||
File project = tmpFile("/project/");
|
||||
|
||||
@@ -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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* 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,
|
||||
@@ -31,7 +31,8 @@ class GradleBomParserTests {
|
||||
|
||||
@Test
|
||||
void should_read_versions_from_bom_from_properties() {
|
||||
GradleBomParser parser = new GradleBomParser(new ReleaserProperties(), new ArrayList<>()) {
|
||||
GradleBomParser parser = new GradleBomParser(new ReleaserProperties(),
|
||||
new ArrayList<>()) {
|
||||
@Override
|
||||
public boolean isApplicable(File clonedBom) {
|
||||
return true;
|
||||
@@ -62,7 +63,8 @@ class GradleBomParserTests {
|
||||
gradleSubstitution.put("verifierVersion", "spring-cloud-contract");
|
||||
ReleaserProperties releaserProperties = new ReleaserProperties();
|
||||
releaserProperties.getGradle().setGradlePropsSubstitution(gradleSubstitution);
|
||||
GradleBomParser parser = new GradleBomParser(releaserProperties, new ArrayList<>()) {
|
||||
GradleBomParser parser = new GradleBomParser(releaserProperties,
|
||||
new ArrayList<>()) {
|
||||
@Override
|
||||
public boolean isApplicable(File clonedBom) {
|
||||
return true;
|
||||
@@ -89,14 +91,16 @@ class GradleBomParserTests {
|
||||
|
||||
@Test
|
||||
void should_be_not_applicable_when_no_build_gradle_is_present() {
|
||||
GradleBomParser parser = new GradleBomParser(new ReleaserProperties(), new ArrayList<>());
|
||||
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(), new ArrayList<>()) {
|
||||
GradleBomParser parser = new GradleBomParser(new ReleaserProperties(),
|
||||
new ArrayList<>()) {
|
||||
@Override
|
||||
File file(File clonedBom, String child) {
|
||||
return clonedBom;
|
||||
@@ -108,7 +112,8 @@ class GradleBomParserTests {
|
||||
|
||||
@Test
|
||||
void should_return_empty_version_when_no_gradle_properties_is_present() {
|
||||
GradleBomParser parser = new GradleBomParser(new ReleaserProperties(), new ArrayList<>());
|
||||
GradleBomParser parser = new GradleBomParser(new ReleaserProperties(),
|
||||
new ArrayList<>());
|
||||
|
||||
VersionsFromBom versionsFromBom = parser.versionsFromBom(new File("."));
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.buildsystem;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.cloud.release.cloud.buildsystem.SpringCloudMavenBomParser;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
|
||||
public class MavenBomParserAccessor {
|
||||
|
||||
public static BomParser cloudMavenBomParser(ReleaserProperties properties) {
|
||||
return new MavenBomParser(properties,
|
||||
Collections.singletonList(new SpringCloudMavenBomParser()));
|
||||
}
|
||||
|
||||
public static BomParser testCloudBomParser(ReleaserProperties properties) {
|
||||
return new MavenBomParser(properties,
|
||||
Collections.singletonList(new SpringCloudMavenBomParser() {
|
||||
@Override
|
||||
public boolean isApplicable(File root, ReleaserProperties properties,
|
||||
Set<Project> projects) {
|
||||
return true;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,6 @@ 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;
|
||||
@@ -46,7 +45,7 @@ public class MavenBomParserTests {
|
||||
|
||||
@Test
|
||||
public void should_throw_exception_when_boot_pom_is_missing() {
|
||||
MavenBomParser parser = new MavenBomParser(this.properties, new ArrayList<>());
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
File file = new File(".");
|
||||
|
||||
thenThrownBy(() -> parser.versionsFromBom(file))
|
||||
@@ -58,7 +57,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, new ArrayList<>());
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
|
||||
thenThrownBy(() -> parser.versionsFromBom(this.springCloudReleaseProject))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
@@ -68,7 +67,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, new ArrayList<>());
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
|
||||
thenThrownBy(() -> parser.versionsFromBom(this.springCloudReleaseProject))
|
||||
.isInstanceOf(IllegalStateException.class).hasMessageContaining(
|
||||
@@ -77,7 +76,7 @@ public class MavenBomParserTests {
|
||||
|
||||
@Test
|
||||
public void should_populate_sc_release_version() {
|
||||
MavenBomParser parser = new MavenBomParser(this.properties, new ArrayList<>());
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
|
||||
String scReleaseVersion = parser.versionsFromBom(this.springCloudReleaseProject)
|
||||
.versionForProject("spring-cloud-release");
|
||||
@@ -87,7 +86,7 @@ public class MavenBomParserTests {
|
||||
|
||||
@Test
|
||||
public void should_populate_boot_version() {
|
||||
MavenBomParser parser = new MavenBomParser(this.properties, new ArrayList<>());
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
|
||||
String bootVersion = parser.versionsFromBom(this.springCloudReleaseProject)
|
||||
.versionForProject("spring-boot");
|
||||
@@ -97,7 +96,7 @@ public class MavenBomParserTests {
|
||||
|
||||
@Test
|
||||
public void should_throw_exception_when_cloud_pom_is_missing() {
|
||||
MavenBomParser parser = new MavenBomParser(this.properties, new ArrayList<>());
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
|
||||
thenThrownBy(() -> parser.versionsFromBom(new File(".")))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
@@ -108,7 +107,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, new ArrayList<>());
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
|
||||
thenThrownBy(() -> parser.versionsFromBom(this.springCloudReleaseProject))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
@@ -119,7 +118,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, new ArrayList<>());
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
|
||||
thenThrownBy(() -> parser.versionsFromBom(this.springCloudReleaseProject))
|
||||
.isInstanceOf(IllegalStateException.class).hasMessageContaining(
|
||||
@@ -128,7 +127,7 @@ public class MavenBomParserTests {
|
||||
|
||||
@Test
|
||||
public void should_populate_cloud_version() {
|
||||
MavenBomParser parser = new MavenBomParser(this.properties, new ArrayList<>());
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
|
||||
VersionsFromBom cloudVersionsFromBom = parser
|
||||
.versionsFromBom(this.springCloudReleaseProject);
|
||||
@@ -140,7 +139,7 @@ public class MavenBomParserTests {
|
||||
|
||||
@Test
|
||||
public void should_populate_boot_and_cloud_version() {
|
||||
MavenBomParser parser = new MavenBomParser(this.properties, new ArrayList<>());
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
|
||||
VersionsFromBom cloudVersionsFromBom = parser
|
||||
.versionsFromBom(this.springCloudReleaseProject);
|
||||
|
||||
@@ -46,8 +46,11 @@ public class PomUpdaterTests {
|
||||
@Rule
|
||||
public TemporaryFolder tmp = new TemporaryFolder();
|
||||
|
||||
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder().releaserProperties(new ReleaserProperties())
|
||||
.projects(projects()).versionsFromBom();
|
||||
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder()
|
||||
.releaserProperties(new ReleaserProperties()).projects(projects())
|
||||
.parsers(MavenBomParserAccessor.cloudMavenBomParser(new ReleaserProperties())
|
||||
.customBomParsers())
|
||||
.retrieveFromBom();
|
||||
|
||||
PomUpdater pomUpdater = new PomUpdater();
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.cloud.release.internal.buildsystem;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -66,7 +66,8 @@ 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, new ArrayList<>());
|
||||
ProjectPomUpdater updater = new ProjectPomUpdater(properties, Collections
|
||||
.singletonList(MavenBomParserAccessor.cloudMavenBomParser(properties)));
|
||||
|
||||
Map<String, String> fixedVersions = updater.fixedVersions().stream()
|
||||
.collect(Collectors.toMap(projectVersion -> projectVersion.projectName,
|
||||
@@ -76,7 +77,8 @@ public class ProjectPomUpdaterTests {
|
||||
.containsEntry("spring-boot-dependencies", "2.0.3.RELEASE")
|
||||
.containsEntry("spring-boot-starter", "2.0.3.RELEASE")
|
||||
.containsEntry("spring-cloud-build", "2.0.3.BUILD-SNAPSHOT")
|
||||
.containsEntry("spring-cloud-dependencies", "2.0.3.BUILD-SNAPSHOT")
|
||||
.containsEntry("spring-cloud-dependencies-parent", "2.0.3.BUILD-SNAPSHOT")
|
||||
.containsEntry("spring-cloud-dependencies", "Finchley.BUILD-SNAPSHOT")
|
||||
.containsEntry("spring-cloud-release", "Finchley.BUILD-SNAPSHOT")
|
||||
.containsEntry("spring-cloud", "Finchley.BUILD-SNAPSHOT");
|
||||
}
|
||||
@@ -85,7 +87,8 @@ 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, new ArrayList<>());
|
||||
ProjectPomUpdater updater = new ProjectPomUpdater(properties, Collections
|
||||
.singletonList(MavenBomParserAccessor.cloudMavenBomParser(properties)));
|
||||
|
||||
updater.updateProjectFromReleaseTrain(new File("target"), new Projects(),
|
||||
new ProjectVersion("foo", "1.0.0.RELEASE"), false);
|
||||
|
||||
@@ -49,14 +49,6 @@ public class ProjectVersionTests {
|
||||
this.springCloudContract = new File(scContract.getPath(), "pom.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_build_version_from_text_when_parent_suffix_is_present() {
|
||||
ProjectVersion projectVersion = new ProjectVersion("foo-parent", "1.0.0");
|
||||
|
||||
then(projectVersion.version).isEqualTo("1.0.0");
|
||||
then(projectVersion.projectName).isEqualTo("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_build_version_from_text() {
|
||||
ProjectVersion projectVersion = new ProjectVersion("foo", "1.0.0");
|
||||
|
||||
@@ -78,8 +78,8 @@ public class PropertyVersionChangerTests {
|
||||
}
|
||||
|
||||
VersionsFromBom versions() {
|
||||
return new VersionsFromBomBuilder().releaserProperties(new ReleaserProperties()).projects(allProjects())
|
||||
.versionsFromBom();
|
||||
return new VersionsFromBomBuilder().releaserProperties(new ReleaserProperties())
|
||||
.projects(allProjects()).retrieveFromBom();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.cloud.release.cloud.buildsystem.SpringCloudMavenBomParser;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
@@ -32,13 +33,16 @@ import static org.assertj.core.api.BDDAssertions.then;
|
||||
*/
|
||||
public class VersionsFromBomTests {
|
||||
|
||||
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder().releaserProperties(new ReleaserProperties())
|
||||
.projects(projects()).versionsFromBom();
|
||||
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder()
|
||||
.releaserProperties(new ReleaserProperties()).projects(projects())
|
||||
.retrieveFromBom();
|
||||
|
||||
@Test
|
||||
public void should_add_boot_to_versions_when_version_is_created() {
|
||||
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder().releaserProperties(new ReleaserProperties())
|
||||
.versionsFromBom();
|
||||
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder()
|
||||
.releaserProperties(new ReleaserProperties())
|
||||
.parsers(Collections.singletonList(new SpringCloudMavenBomParser()))
|
||||
.retrieveFromBom();
|
||||
versionsFromBom.setVersion("spring-boot", "1.2.3.RELEASE");
|
||||
|
||||
then(versionsFromBom.projects).contains(
|
||||
@@ -241,13 +245,14 @@ public class VersionsFromBomTests {
|
||||
}
|
||||
|
||||
private VersionsFromBom mixedVersions() {
|
||||
return new VersionsFromBomBuilder().releaserProperties(new ReleaserProperties()).projects(mixedProjects())
|
||||
.versionsFromBom();
|
||||
return new VersionsFromBomBuilder().releaserProperties(new ReleaserProperties())
|
||||
.parsers(Collections.singletonList(new SpringCloudMavenBomParser()))
|
||||
.projects(mixedProjects()).merged();
|
||||
}
|
||||
|
||||
private VersionsFromBom mixedVersions(ReleaserProperties properties) {
|
||||
return new VersionsFromBomBuilder().releaserProperties(properties).projects(mixedProjects())
|
||||
.versionsFromBom();
|
||||
return new VersionsFromBomBuilder().releaserProperties(properties)
|
||||
.projects(mixedProjects()).retrieveFromBom();
|
||||
}
|
||||
|
||||
private ReleaserProperties customBom() {
|
||||
|
||||
@@ -22,12 +22,14 @@ import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.buildsystem.MavenBomParserAccessor;
|
||||
import org.springframework.cloud.release.internal.buildsystem.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.buildsystem.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.buildsystem.TestUtils;
|
||||
@@ -59,7 +61,8 @@ class VersionsFromBomFetcherTests {
|
||||
properties.getVersions().setAllVersionsFileUrl(initilizrUri.toString());
|
||||
properties.getGit().setReleaseTrainBomUrl(
|
||||
file("/projects/spring-cloud-release/").toURI().toString() + "/");
|
||||
ProjectPomUpdater updater = new ProjectPomUpdater(properties, new ArrayList<>());
|
||||
ProjectPomUpdater updater = new ProjectPomUpdater(properties, Collections
|
||||
.singletonList(MavenBomParserAccessor.cloudMavenBomParser(properties)));
|
||||
VersionsFetcher versionsFetcher = new VersionsFetcher(properties, updater);
|
||||
|
||||
boolean latestGa = versionsFetcher.isLatestGa(projectVersion);
|
||||
@@ -78,7 +81,8 @@ class VersionsFromBomFetcherTests {
|
||||
properties.getVersions().setAllVersionsFileUrl(initilizrUri.toString());
|
||||
properties.getGit().setReleaseTrainBomUrl(
|
||||
file("/projects/spring-cloud-release/").toURI().toString() + "/");
|
||||
ProjectPomUpdater updater = new ProjectPomUpdater(properties, new ArrayList<>());
|
||||
ProjectPomUpdater updater = new ProjectPomUpdater(properties, Collections
|
||||
.singletonList(MavenBomParserAccessor.cloudMavenBomParser(properties)));
|
||||
VersionsFetcher versionsFetcher = new VersionsFetcher(properties, updater);
|
||||
|
||||
boolean latestGa = versionsFetcher.isLatestGa(projectVersion);
|
||||
|
||||
@@ -252,7 +252,7 @@ public class SpringReleaser {
|
||||
if (this.properties.getGit().isFetchVersionsFromGit()
|
||||
&& !this.properties.getMetaRelease().isEnabled()) {
|
||||
printVersionRetrieval();
|
||||
projectsToUpdate = this.releaser.retrieveVersionsFromSCRelease();
|
||||
projectsToUpdate = this.releaser.retrieveVersionsFromBom();
|
||||
versionFromBom = assertNoSnapshotsForANonSnapshotProject(project,
|
||||
projectsToUpdate);
|
||||
}
|
||||
|
||||
@@ -710,8 +710,8 @@ public class AcceptanceTests {
|
||||
this.releaserProperties);
|
||||
DocumentationUpdater documentationUpdater = new TestDocumentationUpdater(
|
||||
properties,
|
||||
new TestDocumentationUpdater.TestCustomProjectDocumentationUpdater(properties,
|
||||
gitHandler, "Brixton.SR1"),
|
||||
new TestDocumentationUpdater.TestCustomProjectDocumentationUpdater(
|
||||
properties, gitHandler, "Brixton.SR1"),
|
||||
new TestDocumentationUpdater.TestReleaseContentsUpdater(properties,
|
||||
gitHandler, templateGenerator)) {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user