Refactoring:
- Allows hooking in of bom parsers and documentation updaters - Can read from gradle.properties - Abstracted bom parsing - Refactord buildsystem - Added the buildsystem abstraction
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
|
||||
*
|
||||
* https://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,
|
||||
@@ -14,22 +14,32 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.cloud.buildsystem;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
final class SpringCloudConstants {
|
||||
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";
|
||||
|
||||
private SpringCloudConstants() {
|
||||
// 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");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* 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.cloud.buildsystem;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.buildsystem.CustomBomParser;
|
||||
import org.springframework.cloud.release.internal.buildsystem.VersionsFromBom;
|
||||
import org.springframework.cloud.release.internal.buildsystem.VersionsFromBomBuilder;
|
||||
import org.springframework.cloud.release.internal.project.Project;
|
||||
import org.springframework.cloud.release.internal.tech.PomReader;
|
||||
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;
|
||||
|
||||
class SpringCloudMavenBomParser implements CustomBomParser {
|
||||
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(SpringCloudMavenBomParser.class);
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(File root, ReleaserProperties properties,
|
||||
Set<Project> projects) {
|
||||
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);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Added Spring Cloud Build [{}] and boot versions [{}]",
|
||||
springCloudBuild, boot);
|
||||
}
|
||||
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 [{}]",
|
||||
CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildArtifact);
|
||||
if (!CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID.equals(buildArtifact)) {
|
||||
throw new IllegalStateException(
|
||||
"The pom doesn't have a [spring-cloud-dependencies-parent] artifact id");
|
||||
}
|
||||
buildVersion = model.getParent().getVersion();
|
||||
log.debug("Spring Cloud Build version is equal to [{}]", buildVersion);
|
||||
return buildVersion;
|
||||
}
|
||||
|
||||
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 "";
|
||||
}
|
||||
String bootArtifactId = model.getParent().getArtifactId();
|
||||
log.debug("Boot artifact id is equal to [{}]", 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");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
return model.getParent().getVersion();
|
||||
}
|
||||
|
||||
VersionsFromBom bootVersion(File root, ReleaserProperties properties) {
|
||||
String bootVersion = boot(root, properties);
|
||||
if (StringUtils.isEmpty(bootVersion)) {
|
||||
return VersionsFromBom.EMPTY_VERSION;
|
||||
}
|
||||
log.debug("Boot version is equal to [{}]", bootVersion);
|
||||
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder()
|
||||
.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);
|
||||
return versionsFromBom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Project> setVersion(Set<Project> projects, String projectName,
|
||||
String version) {
|
||||
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);
|
||||
break;
|
||||
case BUILD_ARTIFACT_ID:
|
||||
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_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);
|
||||
}
|
||||
|
||||
private void updateBuildVersions(Set<Project> newProjects, String version) {
|
||||
remove(newProjects, BUILD_ARTIFACT_ID);
|
||||
remove(newProjects, CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID);
|
||||
add(newProjects, BUILD_ARTIFACT_ID, version);
|
||||
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));
|
||||
}
|
||||
|
||||
private void remove(Set<Project> projects, String expectedProjectName) {
|
||||
projects.removeIf(project -> expectedProjectName.equals(project.name));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* 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.cloud.docs;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.release.internal.docs.CustomProjectDocumentationUpdater;
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
class SpringCloudCustomProjectDocumentationUpdater
|
||||
implements CustomProjectDocumentationUpdater {
|
||||
|
||||
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(SpringCloudCustomProjectDocumentationUpdater.class);
|
||||
|
||||
private final ProjectGitHandler gitHandler;
|
||||
|
||||
SpringCloudCustomProjectDocumentationUpdater(ProjectGitHandler gitHandler) {
|
||||
this.gitHandler = gitHandler;
|
||||
}
|
||||
|
||||
@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.
|
||||
* @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
|
||||
*/
|
||||
@Override
|
||||
public File updateDocsRepo(File clonedDocumentationProject,
|
||||
ProjectVersion currentProject, String bomBranch) {
|
||||
log.debug("Cloning the doc project to [{}]", clonedDocumentationProject);
|
||||
String pathToIndexHtml = "current/index.html";
|
||||
File indexHtml = indexHtml(clonedDocumentationProject, pathToIndexHtml);
|
||||
if (!indexHtml.exists()) {
|
||||
throw new IllegalStateException(
|
||||
"index.html is not present at [" + pathToIndexHtml + "]");
|
||||
}
|
||||
return updateTheDocsRepo(bomBranch, clonedDocumentationProject, indexHtml);
|
||||
}
|
||||
|
||||
File indexHtml(File clonedDocumentationProject, String pathToIndexHtml) {
|
||||
return new File(clonedDocumentationProject, pathToIndexHtml);
|
||||
}
|
||||
|
||||
private File updateTheDocsRepo(String springCloudReleaseBranch,
|
||||
File documentationProject, File indexHtml) {
|
||||
try {
|
||||
String indexHtmlText = readIndexHtmlContents(indexHtml);
|
||||
int httpIndex = indexHtmlText.indexOf(HTTP_SC_STATIC_URL);
|
||||
int httpsIndex = indexHtmlText.indexOf(HTTPS_SC_STATIC_URL);
|
||||
if (httpIndex == -1 && httpsIndex == -1) {
|
||||
throw new IllegalStateException(
|
||||
"The URL to the documentation repo not found in the index.html file");
|
||||
}
|
||||
int beginIndex = beginIndex(httpIndex, httpsIndex);
|
||||
String storedReleaseTrainLine = indexHtmlText.substring(beginIndex);
|
||||
String storedReleaseTrain = storedReleaseTrainLine.substring(0,
|
||||
storedReleaseTrainLine.indexOf("/"));
|
||||
String firstLetterOfReleaseTrain = String
|
||||
.valueOf(storedReleaseTrain.charAt(0));
|
||||
String currentReleaseTrainVersion = branchToReleaseVersion(
|
||||
springCloudReleaseBranch);
|
||||
String firstLetterOfCurrentReleaseTrain = String
|
||||
.valueOf(currentReleaseTrainVersion.charAt(0));
|
||||
boolean newerOrEqualReleaseTrain = isNewerOrEqualReleaseTrain(
|
||||
storedReleaseTrain, firstLetterOfReleaseTrain,
|
||||
currentReleaseTrainVersion, firstLetterOfCurrentReleaseTrain);
|
||||
if (!newerOrEqualReleaseTrain) {
|
||||
log.info(
|
||||
"Current release train [{}] is not newer than the stored one [{}]",
|
||||
currentReleaseTrainVersion, storedReleaseTrain);
|
||||
return documentationProject;
|
||||
}
|
||||
return pushCommitedChanges(currentReleaseTrainVersion, documentationProject,
|
||||
indexHtml, indexHtmlText, storedReleaseTrain);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
return httpsIndex + HTTPS_SC_STATIC_URL.length();
|
||||
}
|
||||
|
||||
private String branchToReleaseVersion(String springCloudReleaseBranch) {
|
||||
if (springCloudReleaseBranch.startsWith("v")) {
|
||||
return springCloudReleaseBranch.substring(1);
|
||||
}
|
||||
return springCloudReleaseBranch;
|
||||
}
|
||||
|
||||
private File pushCommitedChanges(String currentReleaseTrainVersion,
|
||||
File documentationProject, File indexHtml, String indexHtmlText,
|
||||
String storedReleaseTrain) throws IOException {
|
||||
String replacedIndexHtml = indexHtmlText.replace(storedReleaseTrain,
|
||||
currentReleaseTrainVersion);
|
||||
Files.write(indexHtml.toPath(), replacedIndexHtml.getBytes());
|
||||
log.info("Stored the release train [{}] in [{}]", currentReleaseTrainVersion,
|
||||
indexHtml.getAbsolutePath());
|
||||
this.gitHandler.commit(documentationProject,
|
||||
"Updating the link to the current version to ["
|
||||
+ currentReleaseTrainVersion + "]");
|
||||
this.gitHandler.pushCurrentBranch(documentationProject);
|
||||
log.info("Committed and pushed changes to the documentation project");
|
||||
return documentationProject;
|
||||
}
|
||||
|
||||
String readIndexHtmlContents(File indexHtml) throws IOException {
|
||||
return new String(Files.readAllBytes(indexHtml.toPath()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,15 +22,16 @@ import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.release.internal.buildsystem.GradleUpdater;
|
||||
import org.springframework.cloud.release.internal.buildsystem.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.docs.DocumentationUpdater;
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.cloud.release.internal.gradle.GradleUpdater;
|
||||
import org.springframework.cloud.release.internal.pom.ProcessedProject;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.post.PostReleaseActions;
|
||||
import org.springframework.cloud.release.internal.project.ProjectBuilder;
|
||||
import org.springframework.cloud.release.internal.github.ProjectGitHubHandler;
|
||||
import org.springframework.cloud.release.internal.postrelease.PostReleaseActions;
|
||||
import org.springframework.cloud.release.internal.project.ProcessedProject;
|
||||
import org.springframework.cloud.release.internal.project.ProjectCommandExecutor;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
import org.springframework.cloud.release.internal.sagan.SaganUpdater;
|
||||
import org.springframework.cloud.release.internal.tech.MakeBuildUnstableException;
|
||||
import org.springframework.cloud.release.internal.template.TemplateGenerator;
|
||||
@@ -47,14 +48,14 @@ public class Releaser implements ReleaserPropertiesAware {
|
||||
|
||||
private static boolean SKIP_SNAPSHOT_ASSERTION = false;
|
||||
|
||||
private ReleaserProperties releaserProperties;
|
||||
|
||||
private final ProjectPomUpdater projectPomUpdater;
|
||||
|
||||
private final ProjectBuilder projectBuilder;
|
||||
private final ProjectCommandExecutor projectCommandExecutor;
|
||||
|
||||
private final ProjectGitHandler projectGitHandler;
|
||||
|
||||
private final ProjectGitHubHandler projectGitHubHandler;
|
||||
|
||||
private final TemplateGenerator templateGenerator;
|
||||
|
||||
private final GradleUpdater gradleUpdater;
|
||||
@@ -65,16 +66,21 @@ public class Releaser implements ReleaserPropertiesAware {
|
||||
|
||||
private final PostReleaseActions postReleaseActions;
|
||||
|
||||
private ReleaserProperties releaserProperties;
|
||||
|
||||
public Releaser(ReleaserProperties releaserProperties,
|
||||
ProjectPomUpdater projectPomUpdater, ProjectBuilder projectBuilder,
|
||||
ProjectGitHandler projectGitHandler, TemplateGenerator templateGenerator,
|
||||
GradleUpdater gradleUpdater, SaganUpdater saganUpdater,
|
||||
DocumentationUpdater documentationUpdater,
|
||||
ProjectPomUpdater projectPomUpdater,
|
||||
ProjectCommandExecutor projectCommandExecutor,
|
||||
ProjectGitHandler projectGitHandler,
|
||||
ProjectGitHubHandler projectGitHubHandler,
|
||||
TemplateGenerator templateGenerator, GradleUpdater gradleUpdater,
|
||||
SaganUpdater saganUpdater, DocumentationUpdater documentationUpdater,
|
||||
PostReleaseActions postReleaseActions) {
|
||||
this.releaserProperties = releaserProperties;
|
||||
this.projectPomUpdater = projectPomUpdater;
|
||||
this.projectBuilder = projectBuilder;
|
||||
this.projectCommandExecutor = projectCommandExecutor;
|
||||
this.projectGitHandler = projectGitHandler;
|
||||
this.projectGitHubHandler = projectGitHubHandler;
|
||||
this.templateGenerator = templateGenerator;
|
||||
this.gradleUpdater = gradleUpdater;
|
||||
this.saganUpdater = saganUpdater;
|
||||
@@ -86,7 +92,7 @@ public class Releaser implements ReleaserPropertiesAware {
|
||||
return this.projectGitHandler.cloneProjectFromOrg(projectName);
|
||||
}
|
||||
|
||||
public Projects retrieveVersionsFromSCRelease() {
|
||||
public Projects retrieveVersionsFromBom() {
|
||||
return this.projectPomUpdater.retrieveVersionsFromReleaseTrainBom();
|
||||
}
|
||||
|
||||
@@ -110,7 +116,7 @@ public class Releaser implements ReleaserPropertiesAware {
|
||||
}
|
||||
|
||||
public void buildProject(ProjectVersion versionFromScRelease) {
|
||||
this.projectBuilder.build(versionFromScRelease);
|
||||
this.projectCommandExecutor.build(versionFromScRelease);
|
||||
log.info("\nProject was successfully built");
|
||||
}
|
||||
|
||||
@@ -120,12 +126,12 @@ public class Releaser implements ReleaserPropertiesAware {
|
||||
}
|
||||
|
||||
public void deploy(ProjectVersion versionFromScRelease) {
|
||||
this.projectBuilder.deploy(versionFromScRelease);
|
||||
this.projectCommandExecutor.deploy(versionFromScRelease);
|
||||
log.info("\nThe artifact was deployed successfully");
|
||||
}
|
||||
|
||||
public void publishDocs(ProjectVersion changedVersion) {
|
||||
this.projectBuilder.publishDocs(changedVersion.version);
|
||||
this.projectCommandExecutor.publishDocs(changedVersion.version);
|
||||
log.info("\nThe docs were published successfully");
|
||||
}
|
||||
|
||||
@@ -181,7 +187,7 @@ public class Releaser implements ReleaserPropertiesAware {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.projectGitHandler.closeMilestone(releaseVersion);
|
||||
this.projectGitHubHandler.closeMilestone(releaseVersion);
|
||||
log.info("\nSuccessfully closed milestone");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
@@ -267,7 +273,7 @@ public class Releaser implements ReleaserPropertiesAware {
|
||||
private Exception createIssueInSpringGuides(ProjectVersion releaseVersion,
|
||||
Projects projects) {
|
||||
try {
|
||||
this.projectGitHandler.createIssueInSpringGuides(projects, releaseVersion);
|
||||
this.projectGitHubHandler.createIssueInSpringGuides(projects, releaseVersion);
|
||||
log.info("\nSuccessfully created an issue in Spring Guides");
|
||||
return null;
|
||||
}
|
||||
@@ -281,7 +287,8 @@ public class Releaser implements ReleaserPropertiesAware {
|
||||
private Exception createIssueInStartSpringIo(ProjectVersion releaseVersion,
|
||||
Projects projects) {
|
||||
try {
|
||||
this.projectGitHandler.createIssueInStartSpringIo(projects, releaseVersion);
|
||||
this.projectGitHubHandler.createIssueInStartSpringIo(projects,
|
||||
releaseVersion);
|
||||
log.info("\nSuccessfully created an issue in start.spring.io");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import org.apache.commons.lang.SerializationUtils;
|
||||
|
||||
@@ -55,6 +56,8 @@ public class ReleaserProperties implements Serializable {
|
||||
|
||||
private Maven maven = new Maven();
|
||||
|
||||
private Bash bash = new Bash();
|
||||
|
||||
private Gradle gradle = new Gradle();
|
||||
|
||||
private Sagan sagan = new Sagan();
|
||||
@@ -64,8 +67,8 @@ public class ReleaserProperties implements Serializable {
|
||||
private Versions versions = new Versions();
|
||||
|
||||
/**
|
||||
* Project name to its version - overrides all versions retrieved from a repository
|
||||
* like Spring Cloud Release.
|
||||
* Project name to its version - overrides all versions retrieved from a release train
|
||||
* repository like Spring Cloud Release.
|
||||
*/
|
||||
private Map<String, String> fixedVersions = new LinkedHashMap<>();
|
||||
|
||||
@@ -112,6 +115,14 @@ public class ReleaserProperties implements Serializable {
|
||||
this.gradle = gradle;
|
||||
}
|
||||
|
||||
public Bash getBash() {
|
||||
return bash;
|
||||
}
|
||||
|
||||
public void setBash(Bash bash) {
|
||||
this.bash = bash;
|
||||
}
|
||||
|
||||
public Map<String, String> getFixedVersions() {
|
||||
return this.fixedVersions;
|
||||
}
|
||||
@@ -262,7 +273,7 @@ public class ReleaserProperties implements Serializable {
|
||||
public static class Git implements Serializable {
|
||||
|
||||
/**
|
||||
* URL to Spring Cloud Release Git repository.
|
||||
* URL to a release train repository.
|
||||
*/
|
||||
private String releaseTrainBomUrl = "https://github.com/spring-cloud/spring-cloud-release";
|
||||
|
||||
@@ -272,7 +283,7 @@ public class ReleaserProperties implements Serializable {
|
||||
private String documentationUrl = "https://github.com/spring-cloud/spring-cloud-static";
|
||||
|
||||
/**
|
||||
* URL to main release train project repository.
|
||||
* URL to the release train project page repository.
|
||||
*/
|
||||
private String springProjectUrl = "https://github.com/spring-projects/spring-cloud";
|
||||
|
||||
@@ -318,8 +329,8 @@ public class ReleaserProperties implements Serializable {
|
||||
private String releaseTrainWikiPagePrefix = "Spring-Cloud";
|
||||
|
||||
/**
|
||||
* Where should the Spring Cloud Release repo get cloned to. If {@code null}
|
||||
* defaults to a temporary directory.
|
||||
* Where should the release train repo get cloned to. If {@code null} defaults to
|
||||
* a temporary directory.
|
||||
*/
|
||||
private String cloneDestinationDir;
|
||||
|
||||
@@ -840,8 +851,128 @@ public class ReleaserProperties implements Serializable {
|
||||
|
||||
}
|
||||
|
||||
public static class Bash implements Serializable {
|
||||
|
||||
/**
|
||||
* Placeholder for system properties.
|
||||
*/
|
||||
public static final String SYSTEM_PROPS_PLACEHOLDER = "{{systemProps}}";
|
||||
|
||||
/**
|
||||
* Command to be executed to build the project.
|
||||
*/
|
||||
private String buildCommand = "echo \"{{systemProps}}\"";
|
||||
|
||||
/**
|
||||
* Command to be executed to deploy a built project.
|
||||
*/
|
||||
private String deployCommand = "echo \"{{systemProps}}\"";
|
||||
|
||||
/**
|
||||
* Command to be executed to build and deploy guides project only.
|
||||
*/
|
||||
private String deployGuidesCommand = "echo \"{{systemProps}}\"";
|
||||
|
||||
/**
|
||||
* Command to be executed to publish documentation. If present "{{version}}" will
|
||||
* be replaced by the provided version.
|
||||
*/
|
||||
private String[] publishDocsCommands = { "mkdir -p target",
|
||||
"echo \"{{version}}\"" };
|
||||
|
||||
/**
|
||||
* Command to be executed to generate release train documentation.
|
||||
*/
|
||||
private String generateReleaseTrainDocsCommand = "echo \"{{version}}\"";
|
||||
|
||||
/**
|
||||
* Additional system properties that should be passed to the build / deploy
|
||||
* commands. If present in other commands "{{systemProps}}" will be substituted
|
||||
* with this property.
|
||||
*/
|
||||
private String systemProperties = "";
|
||||
|
||||
/**
|
||||
* Max wait time in minutes for the process to finish.
|
||||
*/
|
||||
private long waitTimeInMinutes = 20;
|
||||
|
||||
public String getBuildCommand() {
|
||||
return this.buildCommand;
|
||||
}
|
||||
|
||||
public void setBuildCommand(String buildCommand) {
|
||||
this.buildCommand = buildCommand;
|
||||
}
|
||||
|
||||
public long getWaitTimeInMinutes() {
|
||||
return this.waitTimeInMinutes;
|
||||
}
|
||||
|
||||
public void setWaitTimeInMinutes(long waitTimeInMinutes) {
|
||||
this.waitTimeInMinutes = waitTimeInMinutes;
|
||||
}
|
||||
|
||||
public String getDeployCommand() {
|
||||
return this.deployCommand;
|
||||
}
|
||||
|
||||
public void setDeployCommand(String deployCommand) {
|
||||
this.deployCommand = deployCommand;
|
||||
}
|
||||
|
||||
public String getDeployGuidesCommand() {
|
||||
return this.deployGuidesCommand;
|
||||
}
|
||||
|
||||
public void setDeployGuidesCommand(String deployGuidesCommand) {
|
||||
this.deployGuidesCommand = deployGuidesCommand;
|
||||
}
|
||||
|
||||
public String[] getPublishDocsCommands() {
|
||||
return this.publishDocsCommands;
|
||||
}
|
||||
|
||||
public void setPublishDocsCommands(String[] publishDocsCommands) {
|
||||
this.publishDocsCommands = publishDocsCommands;
|
||||
}
|
||||
|
||||
public String getGenerateReleaseTrainDocsCommand() {
|
||||
return this.generateReleaseTrainDocsCommand;
|
||||
}
|
||||
|
||||
public void setGenerateReleaseTrainDocsCommand(
|
||||
String generateReleaseTrainDocsCommand) {
|
||||
this.generateReleaseTrainDocsCommand = generateReleaseTrainDocsCommand;
|
||||
}
|
||||
|
||||
public String getSystemProperties() {
|
||||
return this.systemProperties;
|
||||
}
|
||||
|
||||
public void setSystemProperties(String systemProperties) {
|
||||
this.systemProperties = systemProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Maven{" + "buildCommand='" + this.buildCommand + '\''
|
||||
+ ", deployCommand='" + this.deployCommand + '\''
|
||||
+ ", publishDocsCommands=" + Arrays.toString(this.publishDocsCommands)
|
||||
+ "generateReleaseTrainDocsCommand='"
|
||||
+ this.generateReleaseTrainDocsCommand + '\'' + ", waitTimeInMinutes="
|
||||
+ this.waitTimeInMinutes + '}';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Gradle implements Serializable {
|
||||
|
||||
/**
|
||||
* Placeholder for system properties.
|
||||
*/
|
||||
public static final String SYSTEM_PROPS_PLACEHOLDER = "{{systemProps}}";
|
||||
|
||||
/**
|
||||
* A mapping that should be applied to {@code gradle.properties} in order to
|
||||
* perform a substitution of properties. The mapping is from a property inside
|
||||
@@ -872,6 +1003,101 @@ public class ReleaserProperties implements Serializable {
|
||||
"^.*spring-cloud-contract-maven-plugin/target/.*$",
|
||||
"^.*samples/standalone/[a-z]+/.*$");
|
||||
|
||||
/**
|
||||
* Command to be executed to build the project.
|
||||
*/
|
||||
private String buildCommand = "./gradlew clean build publishToMavenLocal {{systemProps}}";
|
||||
|
||||
/**
|
||||
* Command to be executed to deploy a built project.
|
||||
*/
|
||||
private String deployCommand = "./gradlew clean build publish {{systemProps}}";
|
||||
|
||||
/**
|
||||
* Command to be executed to build and deploy guides project only.
|
||||
*/
|
||||
private String deployGuidesCommand = "./gradlew clean build deployGuides {{systemProps}}";
|
||||
|
||||
/**
|
||||
* Command to be executed to publish documentation. If present "{{version}}" will
|
||||
* be replaced by the provided version.
|
||||
*/
|
||||
private String[] publishDocsCommands = { "echo 'TODO'" };
|
||||
|
||||
/**
|
||||
* Command to be executed to generate release train documentation.
|
||||
*/
|
||||
private String generateReleaseTrainDocsCommand = "echo 'TODO'";
|
||||
|
||||
/**
|
||||
* Additional system properties that should be passed to the build / deploy
|
||||
* commands. If present in other commands "{{systemProps}}" will be substituted
|
||||
* with this property.
|
||||
*/
|
||||
private String systemProperties = "";
|
||||
|
||||
/**
|
||||
* Max wait time in minutes for the process to finish.
|
||||
*/
|
||||
private long waitTimeInMinutes = 20;
|
||||
|
||||
public String getBuildCommand() {
|
||||
return this.buildCommand;
|
||||
}
|
||||
|
||||
public void setBuildCommand(String buildCommand) {
|
||||
this.buildCommand = buildCommand;
|
||||
}
|
||||
|
||||
public long getWaitTimeInMinutes() {
|
||||
return this.waitTimeInMinutes;
|
||||
}
|
||||
|
||||
public void setWaitTimeInMinutes(long waitTimeInMinutes) {
|
||||
this.waitTimeInMinutes = waitTimeInMinutes;
|
||||
}
|
||||
|
||||
public String getDeployCommand() {
|
||||
return this.deployCommand;
|
||||
}
|
||||
|
||||
public void setDeployCommand(String deployCommand) {
|
||||
this.deployCommand = deployCommand;
|
||||
}
|
||||
|
||||
public String getDeployGuidesCommand() {
|
||||
return this.deployGuidesCommand;
|
||||
}
|
||||
|
||||
public void setDeployGuidesCommand(String deployGuidesCommand) {
|
||||
this.deployGuidesCommand = deployGuidesCommand;
|
||||
}
|
||||
|
||||
public String[] getPublishDocsCommands() {
|
||||
return this.publishDocsCommands;
|
||||
}
|
||||
|
||||
public void setPublishDocsCommands(String[] publishDocsCommands) {
|
||||
this.publishDocsCommands = publishDocsCommands;
|
||||
}
|
||||
|
||||
public String getGenerateReleaseTrainDocsCommand() {
|
||||
return this.generateReleaseTrainDocsCommand;
|
||||
}
|
||||
|
||||
public void setGenerateReleaseTrainDocsCommand(
|
||||
String generateReleaseTrainDocsCommand) {
|
||||
this.generateReleaseTrainDocsCommand = generateReleaseTrainDocsCommand;
|
||||
}
|
||||
|
||||
public String getSystemProperties() {
|
||||
return this.systemProperties;
|
||||
}
|
||||
|
||||
public void setSystemProperties(String systemProperties) {
|
||||
this.systemProperties = systemProperties;
|
||||
}
|
||||
|
||||
public Map<String, String> getGradlePropsSubstitution() {
|
||||
return this.gradlePropsSubstitution;
|
||||
}
|
||||
@@ -891,8 +1117,17 @@ public class ReleaserProperties implements Serializable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Gradle{" + "gradlePropsSubstitution=" + this.gradlePropsSubstitution
|
||||
+ ", ignoredGradleRegex=" + this.ignoredGradleRegex + '}';
|
||||
return new StringJoiner(", ", Gradle.class.getSimpleName() + "[", "]")
|
||||
.add("gradlePropsSubstitution=" + gradlePropsSubstitution)
|
||||
.add("ignoredGradleRegex=" + ignoredGradleRegex)
|
||||
.add("buildCommand='" + buildCommand + "'")
|
||||
.add("deployCommand='" + deployCommand + "'")
|
||||
.add("deployGuidesCommand='" + deployGuidesCommand + "'")
|
||||
.add("publishDocsCommands=" + Arrays.toString(publishDocsCommands))
|
||||
.add("generateReleaseTrainDocsCommand='"
|
||||
+ generateReleaseTrainDocsCommand + "'")
|
||||
.add("systemProperties='" + systemProperties + "'")
|
||||
.add("waitTimeInMinutes=" + waitTimeInMinutes).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.List;
|
||||
|
||||
/**
|
||||
* Parses the bom and returns all parsed versions.
|
||||
*/
|
||||
public interface BomParser {
|
||||
|
||||
/**
|
||||
* @param clonedBom - location of the cloned BOM repository
|
||||
* @return {@code true} - when this BOM parser can be applied
|
||||
*/
|
||||
boolean isApplicable(File clonedBom);
|
||||
|
||||
/**
|
||||
* @param thisProjectRoot - root of the clone project
|
||||
* @return versions from BOM
|
||||
*/
|
||||
VersionsFromBom versionsFromBom(File thisProjectRoot);
|
||||
|
||||
/**
|
||||
* @return a list of available custom bom parsers
|
||||
*/
|
||||
List<CustomBomParser> customBomParsers();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class CompositeBomParser implements BomParser {
|
||||
|
||||
private final List<BomParser> parsers;
|
||||
|
||||
CompositeBomParser(List<BomParser> parsers) {
|
||||
this.parsers = parsers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(File clonedBom) {
|
||||
return this.parsers.stream().anyMatch(b -> b.isApplicable(clonedBom));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionsFromBom versionsFromBom(File thisProjectRoot) {
|
||||
return firstMatching(thisProjectRoot).versionsFromBom(thisProjectRoot);
|
||||
}
|
||||
|
||||
private BomParser firstMatching(File thisProjectRoot) {
|
||||
return this.parsers.stream().filter(b -> b.isApplicable(thisProjectRoot))
|
||||
.findFirst().orElseThrow(
|
||||
() -> 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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.project.Project;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Allows to pass in some additional gradle files parser.
|
||||
*/
|
||||
public interface CustomBomParser {
|
||||
|
||||
CustomBomParser NO_OP = new CustomBomParser() {
|
||||
@Override
|
||||
public boolean isApplicable(File thisProjectRoot, ReleaserProperties properties,
|
||||
Set<Project> projects) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionsFromBom parseBom(File thisProjectRoot,
|
||||
ReleaserProperties properties) {
|
||||
return VersionsFromBom.EMPTY_VERSION;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* 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,
|
||||
@Nullable Set<Project> 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<Project> setVersion(Set<Project> projects, String projectName,
|
||||
String version) {
|
||||
return new LinkedHashSet<>(projects);
|
||||
}
|
||||
|
||||
default boolean isMaven(File thisProjectRoot) {
|
||||
return new File(thisProjectRoot, "pom.xml").exists();
|
||||
}
|
||||
|
||||
default boolean isGradle(File thisProjectRoot) {
|
||||
return new File(thisProjectRoot, "build.gradle").exists();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
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;
|
||||
|
||||
private final List<CustomBomParser> customParsers;
|
||||
|
||||
GradleBomParser(ReleaserProperties releaserProperties,
|
||||
List<CustomBomParser> customParsers) {
|
||||
this.properties = releaserProperties;
|
||||
this.customParsers = customParsers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(File clonedBom) {
|
||||
return file(clonedBom, "build.gradle").exists();
|
||||
}
|
||||
|
||||
File file(File clonedBom, String child) {
|
||||
return new File(clonedBom, child);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VersionsFromBom versionsFromBom(File thisProjectRoot) {
|
||||
File gradleProperties = file(thisProjectRoot, "gradle.properties");
|
||||
if (!gradleProperties.exists()) {
|
||||
return VersionsFromBom.EMPTY_VERSION;
|
||||
}
|
||||
Properties properties = loadProps(gradleProperties);
|
||||
final Map<String, String> substitution = this.properties.getGradle()
|
||||
.getGradlePropsSubstitution();
|
||||
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());
|
||||
});
|
||||
return versionsFromBom;
|
||||
}
|
||||
|
||||
private String projectName(Map<String, String> substitution, Object key) {
|
||||
String projectName = key.toString();
|
||||
if (substitution.containsKey(key)) {
|
||||
projectName = substitution.get(key);
|
||||
}
|
||||
else {
|
||||
Matcher matcher = VERSION_PATTERN.matcher(projectName);
|
||||
boolean versionMatches = matcher.matches();
|
||||
if (versionMatches) {
|
||||
projectName = matcher.group(1);
|
||||
}
|
||||
}
|
||||
projectName = projectName.replaceAll("([A-Z])", "-$1").toLowerCase();
|
||||
return projectName;
|
||||
}
|
||||
|
||||
Properties loadProps(File file) {
|
||||
Properties props = new Properties();
|
||||
try {
|
||||
props.load(new FileInputStream(file));
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CustomBomParser> customBomParsers() {
|
||||
return this.customParsers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.gradle;
|
||||
package org.springframework.cloud.release.internal.buildsystem;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -37,8 +37,8 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.ReleaserPropertiesAware;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
@@ -69,10 +69,10 @@ public class GradleUpdater implements ReleaserPropertiesAware {
|
||||
}
|
||||
|
||||
private void processAllGradleProps(File projectRoot, Projects projects,
|
||||
ProjectVersion versionFromScRelease, boolean assertVersions) {
|
||||
ProjectVersion versionFromBom, boolean assertVersions) {
|
||||
try {
|
||||
Files.walkFileTree(projectRoot.toPath(), new GradlePropertiesWalker(
|
||||
this.properties, projects, versionFromScRelease, assertVersions));
|
||||
this.properties, projects, versionFromBom, assertVersions));
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
@@ -175,6 +175,12 @@ public class GradleUpdater implements ReleaserPropertiesAware {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean pathIgnored(File file) {
|
||||
String path = file.getPath();
|
||||
return this.assertVersions && this.properties.getGradle()
|
||||
.getIgnoredGradleRegex().stream().anyMatch(path::matches);
|
||||
}
|
||||
|
||||
private Properties loadProps(File file) {
|
||||
Properties props = new Properties();
|
||||
try {
|
||||
@@ -186,12 +192,6 @@ public class GradleUpdater implements ReleaserPropertiesAware {
|
||||
return props;
|
||||
}
|
||||
|
||||
private boolean pathIgnored(File file) {
|
||||
String path = file.getPath();
|
||||
return this.assertVersions && this.properties.getGradle()
|
||||
.getIgnoredGradleRegex().stream().anyMatch(path::matches);
|
||||
}
|
||||
|
||||
private String asString(Path path) {
|
||||
try {
|
||||
return new String(Files.readAllBytes(path));
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.project.Project;
|
||||
import org.springframework.cloud.release.internal.tech.PomReader;
|
||||
|
||||
/**
|
||||
* Parses the poms for a given project and populates versions from a release train.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
class MavenBomParser implements BomParser {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MavenBomParser.class);
|
||||
|
||||
private final String thisTrainBomLocation;
|
||||
|
||||
private final Pattern versionPattern;
|
||||
|
||||
private final ReleaserProperties properties;
|
||||
|
||||
private final List<CustomBomParser> customParsers;
|
||||
|
||||
MavenBomParser(ReleaserProperties properties, List<CustomBomParser> customParsers) {
|
||||
this.thisTrainBomLocation = properties.getPom().getThisTrainBom();
|
||||
this.versionPattern = Pattern.compile(properties.getPom().getBomVersionPattern());
|
||||
this.properties = properties;
|
||||
this.customParsers = customParsers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(File clonedBom) {
|
||||
return new File(clonedBom, "pom.xml").exists();
|
||||
}
|
||||
|
||||
// the BOM contains all versions of projects and its parent MUST be Spring Cloud
|
||||
// Dependencies Parent
|
||||
@Override
|
||||
public VersionsFromBom versionsFromBom(File thisProjectRoot) {
|
||||
Model model = PomReader.pom(thisProjectRoot, this.thisTrainBomLocation);
|
||||
if (model == null) {
|
||||
return VersionsFromBom.EMPTY_VERSION;
|
||||
}
|
||||
Set<Project> projects = model.getProperties().entrySet().stream()
|
||||
.filter(propertyMatchesVersionPattern()).map(toProject())
|
||||
.collect(Collectors.toSet());
|
||||
String releaseTrainProjectVersion = model.getVersion();
|
||||
projects.add(
|
||||
new Project(this.properties.getMetaRelease().getReleaseTrainProjectName(),
|
||||
releaseTrainProjectVersion));
|
||||
// @formatter:off
|
||||
return new VersionsFromBomBuilder()
|
||||
.thisProjectRoot(thisProjectRoot)
|
||||
.releaserProperties(this.properties)
|
||||
.parsers(this.customParsers)
|
||||
.projects(projects)
|
||||
.retrieveFromBom();
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
private Predicate<Map.Entry<Object, Object>> propertyMatchesVersionPattern() {
|
||||
return entry -> this.versionPattern.matcher(entry.getKey().toString()).matches();
|
||||
}
|
||||
|
||||
private Function<Map.Entry<Object, Object>, Project> toProject() {
|
||||
return entry -> {
|
||||
Matcher matcher = this.versionPattern.matcher(entry.getKey().toString());
|
||||
// you have to first match to get info about the group
|
||||
matcher.matches();
|
||||
String name = matcher.group(1);
|
||||
return new Project(name, entry.getValue().toString());
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CustomBomParser> customBomParsers() {
|
||||
return this.customParsers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.internal.buildsystem;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
@@ -40,6 +40,8 @@ import org.codehaus.stax2.XMLInputFactory2;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.release.internal.project.Project;
|
||||
import org.springframework.cloud.release.internal.tech.PomReader;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static org.springframework.util.StringUtils.hasText;
|
||||
@@ -52,29 +54,27 @@ class PomUpdater {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PomUpdater.class);
|
||||
|
||||
private final PomReader pomReader = new PomReader();
|
||||
|
||||
private final PomWriter pomWriter = new PomWriter();
|
||||
|
||||
/**
|
||||
* Basing on the contents of the root pom and the versions will decide whether the
|
||||
* project should be updated or not.
|
||||
* @param rootFolder - root folder of the project
|
||||
* @param versions - list of dependencies to be updated
|
||||
* @param versionsFromBom - list of dependencies to be updated
|
||||
* @return {@code true} if the project is on the list of projects to be updated
|
||||
*/
|
||||
boolean shouldProjectBeUpdated(File rootFolder, Versions versions) {
|
||||
boolean shouldProjectBeUpdated(File rootFolder, VersionsFromBom versionsFromBom) {
|
||||
File rootPom = rootPom(rootFolder);
|
||||
if (!rootPom.exists()) {
|
||||
return false;
|
||||
}
|
||||
Model model = this.pomReader.readPom(rootPom);
|
||||
Model model = PomReader.readPom(rootPom);
|
||||
if (model == null) {
|
||||
log.info("Failed to read the model");
|
||||
return false;
|
||||
}
|
||||
String artifactId = artifactId(model);
|
||||
if (!versions.shouldBeUpdated(artifactId)) {
|
||||
if (!versionsFromBom.shouldBeUpdated(artifactId)) {
|
||||
log.info(
|
||||
"Skipping project [{}] since it's not on the list of projects to update",
|
||||
model.getArtifactId());
|
||||
@@ -136,22 +136,25 @@ class PomUpdater {
|
||||
}
|
||||
|
||||
ModelWrapper readModel(File pom) {
|
||||
return new ModelWrapper(this.pomReader.readPom(pom));
|
||||
return new ModelWrapper(PomReader.readPom(pom), pom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the root / child module model.
|
||||
* @param rootPom - root project model
|
||||
* @param pom - file with the pom
|
||||
* @param versions - versions to update
|
||||
* @param versionsFromBom - versions to update
|
||||
* @return updated model
|
||||
*/
|
||||
ModelWrapper updateModel(ModelWrapper rootPom, File pom, Versions versions) {
|
||||
Model model = this.pomReader.readPom(pom);
|
||||
ModelWrapper updateModel(ModelWrapper rootPom, File pom,
|
||||
VersionsFromBom versionsFromBom) {
|
||||
Model model = PomReader.readPom(pom);
|
||||
List<VersionChange> sourceChanges = new ArrayList<>();
|
||||
sourceChanges = updateParentIfPossible(rootPom, versions, model, sourceChanges);
|
||||
sourceChanges = updateVersionIfPossible(rootPom, versions, model, sourceChanges);
|
||||
return new ModelWrapper(model, sourceChanges, versions);
|
||||
sourceChanges = updateParentIfPossible(rootPom, versionsFromBom, model,
|
||||
sourceChanges);
|
||||
sourceChanges = updateVersionIfPossible(rootPom, versionsFromBom, model,
|
||||
sourceChanges);
|
||||
return new ModelWrapper(model, sourceChanges, versionsFromBom, pom);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,17 +162,19 @@ class PomUpdater {
|
||||
* changes in the model.
|
||||
* @return - the pom file
|
||||
*/
|
||||
File overwritePomIfDirty(ModelWrapper updatedPomModel, Versions versions, File pom) {
|
||||
File overwritePomIfDirty(ModelWrapper updatedPomModel,
|
||||
VersionsFromBom versionsFromBom, File pom) {
|
||||
if (updatedPomModel.isDirty()) {
|
||||
log.debug("There were changes in the pom so file will be overridden");
|
||||
this.pomWriter.write(updatedPomModel, versions, pom);
|
||||
this.pomWriter.write(updatedPomModel, versionsFromBom, pom);
|
||||
log.info("Successfully stored [{}]", pom);
|
||||
}
|
||||
return pom;
|
||||
}
|
||||
|
||||
private List<VersionChange> updateParentIfPossible(ModelWrapper wrapper,
|
||||
Versions versions, Model model, List<VersionChange> sourceChanges) {
|
||||
VersionsFromBom versionsFromBom, Model model,
|
||||
List<VersionChange> sourceChanges) {
|
||||
String rootProjectName = wrapper.projectName();
|
||||
List<VersionChange> changes = new ArrayList<>(sourceChanges);
|
||||
if (model.getParent() == null || isEmpty(model.getParent().getVersion())) {
|
||||
@@ -181,11 +186,11 @@ class PomUpdater {
|
||||
log.debug("Searching for a version of parent [{}:{}]", parentGroupId,
|
||||
parentArtifactId);
|
||||
String oldVersion = model.getParent().getVersion();
|
||||
String version = versions.versionForProject(parentArtifactId);
|
||||
String version = versionsFromBom.versionForProject(parentArtifactId);
|
||||
log.debug("Found version is [{}]", version);
|
||||
if (isEmpty(version)) {
|
||||
if (hasText(model.getParent().getRelativePath())) {
|
||||
version = versions.versionForProject(rootProjectName);
|
||||
version = versionsFromBom.versionForProject(rootProjectName);
|
||||
}
|
||||
else {
|
||||
log.warn("There is no info on the [{}:{}] version", parentGroupId,
|
||||
@@ -209,7 +214,8 @@ class PomUpdater {
|
||||
}
|
||||
|
||||
private List<VersionChange> updateVersionIfPossible(ModelWrapper wrapper,
|
||||
Versions versions, Model model, List<VersionChange> sourceChanges) {
|
||||
VersionsFromBom versionsFromBom, Model model,
|
||||
List<VersionChange> sourceChanges) {
|
||||
String rootProjectName = wrapper.projectName();
|
||||
String rootProjectGroupId = wrapper.groupId();
|
||||
List<VersionChange> changes = new ArrayList<>(sourceChanges);
|
||||
@@ -224,7 +230,7 @@ class PomUpdater {
|
||||
}
|
||||
log.debug("Searching for a version [{}:{}]", groupId, artifactId);
|
||||
String oldVersion = model.getVersion();
|
||||
String version = versions.versionForProject(rootProjectName);
|
||||
String version = versionsFromBom.versionForProject(rootProjectName);
|
||||
log.debug("Found version is [{}]", version);
|
||||
if (isEmpty(version) || isEmpty(model.getVersion())) {
|
||||
log.debug(
|
||||
@@ -259,19 +265,30 @@ class ModelWrapper {
|
||||
|
||||
final Model model;
|
||||
|
||||
final Versions versions;
|
||||
final VersionsFromBom versionsFromBom;
|
||||
|
||||
final List<VersionChange> sourceChanges = new ArrayList<>();
|
||||
|
||||
ModelWrapper(Model model, List<VersionChange> sourceChanges, Versions versions) {
|
||||
final File rootFile;
|
||||
|
||||
ModelWrapper(Model model, List<VersionChange> sourceChanges,
|
||||
VersionsFromBom versionsFromBom, File rootFile) {
|
||||
this.model = model;
|
||||
this.versions = versions;
|
||||
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.versions = Versions.EMPTY_VERSION;
|
||||
this.versionsFromBom = VersionsFromBom.EMPTY_VERSION;
|
||||
this.rootFile = null;
|
||||
}
|
||||
|
||||
String projectName() {
|
||||
@@ -287,7 +304,7 @@ class ModelWrapper {
|
||||
|
||||
boolean isDirty() {
|
||||
return !this.sourceChanges.isEmpty()
|
||||
|| this.versions.shouldSetProperty(this.model.getProperties());
|
||||
|| this.versionsFromBom.shouldSetProperty(this.model.getProperties());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -296,7 +313,7 @@ class PomWriter {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PomWriter.class);
|
||||
|
||||
void write(ModelWrapper wrapper, Versions versions, File pom) {
|
||||
void write(ModelWrapper wrapper, VersionsFromBom versionsFromBom, File pom) {
|
||||
try {
|
||||
VersionChangerFactory versionChangerFactory = new VersionChangerFactory();
|
||||
StringBuilder input = PomHelper.readXmlFile(pom);
|
||||
@@ -314,8 +331,8 @@ class PomWriter {
|
||||
changer.apply(versionChange);
|
||||
}
|
||||
log.debug("Applying properties changes to the pom [{}]", pom);
|
||||
new PropertyVersionChanger(wrapper, versions, parsedPom, loggerToMavenLog)
|
||||
.apply(null);
|
||||
new PropertyVersionChanger(wrapper, versionsFromBom, parsedPom,
|
||||
loggerToMavenLog).apply(null);
|
||||
try (BufferedWriter bw = new BufferedWriter(new FileWriter(pom))) {
|
||||
bw.write(input.toString());
|
||||
}
|
||||
@@ -349,27 +366,27 @@ class PomWriter {
|
||||
|
||||
class PropertyVersionChanger extends AbstractVersionChanger {
|
||||
|
||||
private final Versions versions;
|
||||
private final VersionsFromBom versionsFromBom;
|
||||
|
||||
private final PropertyStorer propertyStorer;
|
||||
|
||||
PropertyVersionChanger(ModelWrapper wrapper, Versions versions,
|
||||
PropertyVersionChanger(ModelWrapper wrapper, VersionsFromBom versionsFromBom,
|
||||
ModifiedPomXMLEventReader pom, Log log) {
|
||||
super(wrapper.model, pom, log);
|
||||
this.versions = versions;
|
||||
this.versionsFromBom = versionsFromBom;
|
||||
this.propertyStorer = new PropertyStorer(log, pom);
|
||||
}
|
||||
|
||||
PropertyVersionChanger(ModelWrapper wrapper, Versions versions,
|
||||
PropertyVersionChanger(ModelWrapper wrapper, VersionsFromBom versionsFromBom,
|
||||
ModifiedPomXMLEventReader pom, Log log, PropertyStorer propertyStorer) {
|
||||
super(wrapper.model, pom, log);
|
||||
this.versions = versions;
|
||||
this.versionsFromBom = versionsFromBom;
|
||||
this.propertyStorer = propertyStorer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(final VersionChange versionChange) {
|
||||
this.versions.projects.stream().filter(project -> {
|
||||
this.versionsFromBom.projects.stream().filter(project -> {
|
||||
Properties properties = getModel().getProperties();
|
||||
String projectVersionKey = propertyName(project);
|
||||
if (!properties.containsKey(projectVersionKey)) {
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.internal.buildsystem;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -38,6 +38,9 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.ReleaserPropertiesAware;
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.cloud.release.internal.project.Project;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
@@ -53,22 +56,20 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
|
||||
|
||||
private static final boolean UPDATE_FIXED_VERSIONS = true;
|
||||
|
||||
private static final Map<String, Versions> CACHE = new ConcurrentHashMap<>();
|
||||
private static final Map<String, VersionsFromBom> CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
private final ProjectGitHandler gitRepo;
|
||||
|
||||
private final PomUpdater pomUpdater = new PomUpdater();
|
||||
|
||||
private final List<BomParser> bomParsers;
|
||||
|
||||
private ReleaserProperties properties;
|
||||
|
||||
public ProjectPomUpdater(ReleaserProperties properties) {
|
||||
public ProjectPomUpdater(ReleaserProperties properties, List<BomParser> bomParsers) {
|
||||
this.properties = properties;
|
||||
this.gitRepo = new ProjectGitHandler(properties);
|
||||
}
|
||||
|
||||
ProjectPomUpdater(ReleaserProperties properties, ProjectGitHandler gitRepo) {
|
||||
this.properties = properties;
|
||||
this.gitRepo = gitRepo;
|
||||
this.bomParsers = bomParsers;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,34 +93,41 @@ 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) {
|
||||
Versions versions = CACHE.computeIfAbsent(branch, s -> {
|
||||
File clonedScRelease = this.gitRepo.cloneReleaseTrainProject();
|
||||
this.gitRepo.checkout(clonedScRelease, branch);
|
||||
BomParser sCReleasePomParser = new BomParser(this.properties,
|
||||
clonedScRelease);
|
||||
return sCReleasePomParser.allVersions();
|
||||
});
|
||||
VersionsFromBom versionsFromBom = cachedVersionFromBom(branch);
|
||||
if (updateFixedVersions) {
|
||||
log.info("Will update the following versions manually [{}]",
|
||||
this.properties.getFixedVersions());
|
||||
this.properties.getFixedVersions().forEach(versions::setVersion);
|
||||
this.properties.getFixedVersions().forEach(versionsFromBom::setVersion);
|
||||
}
|
||||
log.info("Retrieved the following versions\n{}", versions);
|
||||
return versions.toProjectVersions();
|
||||
log.info("Retrieved the following versions\n{}", versionsFromBom);
|
||||
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
|
||||
*/
|
||||
public Projects fixedVersions() {
|
||||
Set<ProjectVersion> projectVersions = this.properties.getFixedVersions()
|
||||
.entrySet().stream()
|
||||
.map(entry -> new ProjectVersion(entry.getKey(), entry.getValue()))
|
||||
Set<Project> projects = this.properties.getFixedVersions().entrySet().stream()
|
||||
.map(entry -> new Project(entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.toSet());
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Will apply the following fixed versions {}", projectVersions);
|
||||
log.debug("Will apply the following fixed versions {}", projects);
|
||||
}
|
||||
return new Versions(projectVersions, this.properties).toProjectVersions();
|
||||
return new VersionsFromBomBuilder().releaserProperties(this.properties)
|
||||
.parsers(compositeBomParser().customBomParsers()).projects(projects)
|
||||
.merged().toProjectVersions();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,15 +142,17 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
|
||||
*/
|
||||
public void updateProjectFromReleaseTrain(File projectRoot, Projects projects,
|
||||
ProjectVersion versionFromReleaseTrain, boolean assertVersions) {
|
||||
Versions versions = new Versions(projects, this.properties);
|
||||
if (!this.pomUpdater.shouldProjectBeUpdated(projectRoot, versions)) {
|
||||
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder()
|
||||
.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()) {
|
||||
@@ -174,7 +184,7 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
|
||||
|
||||
private final ModelWrapper rootPom;
|
||||
|
||||
private final Versions versions;
|
||||
private final VersionsFromBom versionsFromBom;
|
||||
|
||||
private final PomUpdater pomUpdater;
|
||||
|
||||
@@ -186,11 +196,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.versions = new Versions(projects, properties);
|
||||
this.versionsFromBom = projects;
|
||||
this.pomUpdater = pomUpdater;
|
||||
this.properties = properties;
|
||||
List<Pattern> unacceptableVersionPatterns = versionFromScRelease
|
||||
@@ -212,13 +222,14 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
ModelWrapper model = this.pomUpdater.updateModel(this.rootPom, file,
|
||||
this.versions);
|
||||
this.pomUpdater.overwritePomIfDirty(model, this.versions, file);
|
||||
this.versionsFromBom);
|
||||
this.pomUpdater.overwritePomIfDirty(model, this.versionsFromBom, file);
|
||||
if (this.assertVersions && !this.skipVersionAssert
|
||||
&& !this.pomUpdater.hasSkipDeployment(model.model)) {
|
||||
log.debug(
|
||||
"Update is a non-snapshot one. Checking if no snapshot versions remained in the pom");
|
||||
Scanner scanner = new Scanner(asString(path));
|
||||
String text = asString(path);
|
||||
Scanner scanner = new Scanner(text);
|
||||
int lineNumber = 0;
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
@@ -230,6 +241,9 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
|
||||
&& pattern.matcher(line).matches())
|
||||
.findFirst().orElse(null);
|
||||
if (matchingPattern != null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("File text \n" + text);
|
||||
}
|
||||
throw new IllegalStateException("The file [" + path
|
||||
+ "] matches the [ " + matchingPattern.pattern()
|
||||
+ "] pattern in line number [" + lineNumber + "]\n\n"
|
||||
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* 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.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.project.Project;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
|
||||
/**
|
||||
* Represents versions taken out from a release train POM.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class VersionsFromBom {
|
||||
|
||||
public static final VersionsFromBom EMPTY_VERSION = new VersionsFromBom();
|
||||
|
||||
Set<Project> projects = new HashSet<>();
|
||||
|
||||
ReleaserProperties properties;
|
||||
|
||||
CustomBomParser parser;
|
||||
|
||||
private VersionsFromBom() {
|
||||
this.properties = new ReleaserProperties();
|
||||
}
|
||||
|
||||
VersionsFromBom(ReleaserProperties releaserProperties, CustomBomParser parser) {
|
||||
this.properties = releaserProperties;
|
||||
this.parser = parser;
|
||||
}
|
||||
|
||||
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) {
|
||||
this.properties = releaserProperties;
|
||||
this.parser = parser;
|
||||
Arrays.stream(projects).forEach(p -> this.projects.addAll(p.projects));
|
||||
}
|
||||
|
||||
private String bomProjectName() {
|
||||
return this.properties.getMetaRelease().getReleaseTrainProjectName();
|
||||
}
|
||||
|
||||
private String dependenciesArtifactId() {
|
||||
String artifactId = this.properties.getPom().getThisTrainBom();
|
||||
return artifactId.split(File.separator)[0];
|
||||
}
|
||||
|
||||
private String dependenciesParentArtifactId() {
|
||||
return dependenciesArtifactId() + "-parent";
|
||||
}
|
||||
|
||||
public String versionForProject(String projectName) {
|
||||
return this.projects.stream().filter(project -> nameMatches(projectName, project))
|
||||
.findFirst().orElse(Project.EMPTY_PROJECT).version;
|
||||
}
|
||||
|
||||
public boolean shouldBeUpdated(String projectName) {
|
||||
return this.projects.stream()
|
||||
.anyMatch(project -> nameMatches(projectName, project));
|
||||
}
|
||||
|
||||
public boolean shouldSetProperty(Properties properties) {
|
||||
return this.projects.stream()
|
||||
.anyMatch(project -> properties.containsKey(project.name + ".version"));
|
||||
}
|
||||
|
||||
public Projects toProjectVersions() {
|
||||
return this.projects.stream()
|
||||
.map(project -> new ProjectVersion(project.name, project.version))
|
||||
.collect(Collectors.toCollection(Projects::new));
|
||||
}
|
||||
|
||||
/**
|
||||
* The only exception is spring-cloud-dependencies (e.g. Greenwich.RELEASE) and
|
||||
* spring-cloud-dependencies-parent (e.g. 2.1.0.RELEASE)
|
||||
*/
|
||||
private boolean nameMatches(String projectName, Project project) {
|
||||
if (project.name.equals(projectName)) {
|
||||
return true;
|
||||
}
|
||||
boolean parent = matchesNameWithSuffix(projectName, "-parent", project);
|
||||
boolean bomArtifactId = comparisonOfBomArtifactAndParent(projectName, project);
|
||||
return !bomArtifactId && (parent
|
||||
|| matchesNameWithSuffix(projectName, "-dependencies", project));
|
||||
}
|
||||
|
||||
private boolean comparisonOfBomArtifactAndParent(String projectName,
|
||||
Project project) {
|
||||
return artifactOrParent(projectName, project.name)
|
||||
|| artifactOrParent(project.name, projectName);
|
||||
}
|
||||
|
||||
private boolean artifactOrParent(String projectName, String otherProjectName) {
|
||||
return projectName.equals(dependenciesArtifactId())
|
||||
&& otherProjectName.equals(dependenciesParentArtifactId());
|
||||
}
|
||||
|
||||
private boolean matchesNameWithSuffix(String projectName, String suffix,
|
||||
Project project) {
|
||||
boolean containsSuffix = projectName.endsWith(suffix);
|
||||
if (!containsSuffix) {
|
||||
return false;
|
||||
}
|
||||
String withoutSuffix = projectName.substring(0, projectName.indexOf(suffix));
|
||||
return project.name.equals(withoutSuffix);
|
||||
}
|
||||
|
||||
public VersionsFromBom setVersion(String projectName, String version) {
|
||||
Set<Project> projects = parser.setVersion(this.projects, projectName, version);
|
||||
if (!projects.equals(this.projects)) {
|
||||
this.projects.clear();
|
||||
this.projects.addAll(projects);
|
||||
return this;
|
||||
}
|
||||
if (bomVersionProjectNames().contains(projectName)) {
|
||||
updateBomVersions(version);
|
||||
}
|
||||
else {
|
||||
remove(projectName);
|
||||
add(projectName, version);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private List<String> bomVersionProjectNames() {
|
||||
List<String> names = new ArrayList<>(
|
||||
this.properties.getMetaRelease().getReleaseTrainDependencyNames());
|
||||
names.add(this.properties.getMetaRelease().getReleaseTrainProjectName());
|
||||
return names;
|
||||
}
|
||||
|
||||
private void updateBomVersions(String version) {
|
||||
remove(bomProjectName());
|
||||
bomVersionProjectNames().forEach(this::remove);
|
||||
add(bomProjectName(), version);
|
||||
bomVersionProjectNames().forEach(s -> add(s, version));
|
||||
}
|
||||
|
||||
public void add(String key, String value) {
|
||||
this.projects.add(new Project(key, value));
|
||||
}
|
||||
|
||||
public void remove(String expectedProjectName) {
|
||||
this.projects.removeIf(project -> expectedProjectName.equals(project.name));
|
||||
}
|
||||
|
||||
public Set<Project> projects() {
|
||||
return this.projects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Projects=\n\t" + this.projects.stream().map(Object::toString)
|
||||
.collect(Collectors.joining("\n\t"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.project.Project;
|
||||
|
||||
public class VersionsFromBomBuilder {
|
||||
|
||||
private ReleaserProperties releaserProperties;
|
||||
|
||||
private Set<Project> projects = new HashSet<>();
|
||||
|
||||
private VersionsFromBom[] versionsFromBom = new VersionsFromBom[0];
|
||||
|
||||
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;
|
||||
return this;
|
||||
}
|
||||
|
||||
public VersionsFromBomBuilder projects(Set<Project> projects) {
|
||||
this.projects = projects;
|
||||
return this;
|
||||
}
|
||||
|
||||
public VersionsFromBomBuilder projects(VersionsFromBom... versionsFromBom) {
|
||||
this.versionsFromBom = versionsFromBom;
|
||||
return this;
|
||||
}
|
||||
|
||||
public VersionsFromBomBuilder parsers(List<CustomBomParser> parsers) {
|
||||
this.parsers = parsers;
|
||||
return this;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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<Project> 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).thisProjectRoot(thisProjectRoot)
|
||||
.releaserProperties(this.releaserProperties)
|
||||
.projects(versionsFromBom, versionsFromBom2).merged())
|
||||
.orElse(VersionsFromBom.EMPTY_VERSION);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.project.ProjectVersion;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public interface CustomProjectDocumentationUpdater {
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
@@ -17,12 +17,13 @@
|
||||
package org.springframework.cloud.release.internal.docs;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.ReleaserPropertiesAware;
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
import org.springframework.cloud.release.internal.template.TemplateGenerator;
|
||||
|
||||
/**
|
||||
@@ -37,10 +38,11 @@ public class DocumentationUpdater implements ReleaserPropertiesAware {
|
||||
private ReleaserProperties properties;
|
||||
|
||||
public DocumentationUpdater(ProjectGitHandler gitHandler,
|
||||
ReleaserProperties properties, TemplateGenerator templateGenerator) {
|
||||
ReleaserProperties properties, TemplateGenerator templateGenerator,
|
||||
List<CustomProjectDocumentationUpdater> updaters) {
|
||||
this.properties = properties;
|
||||
this.projectDocumentationUpdater = new ProjectDocumentationUpdater(
|
||||
this.properties, gitHandler);
|
||||
this.projectDocumentationUpdater = new ProjectDocumentationUpdater(properties,
|
||||
gitHandler, updaters);
|
||||
this.releaseTrainContentsUpdater = new ReleaseTrainContentsUpdater(
|
||||
this.properties, gitHandler, templateGenerator);
|
||||
}
|
||||
@@ -92,8 +94,8 @@ public class DocumentationUpdater implements ReleaserPropertiesAware {
|
||||
@Override
|
||||
public void setReleaserProperties(ReleaserProperties properties) {
|
||||
this.properties = properties;
|
||||
this.projectDocumentationUpdater.setReleaserProperties(properties);
|
||||
this.releaseTrainContentsUpdater.setReleaserProperties(properties);
|
||||
this.projectDocumentationUpdater.setReleaserProperties(properties);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
package org.springframework.cloud.release.internal.docs;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -26,39 +25,31 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.ReleaserPropertiesAware;
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
class ProjectDocumentationUpdater implements 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);
|
||||
|
||||
private final ProjectGitHandler gitHandler;
|
||||
|
||||
private final List<CustomProjectDocumentationUpdater> updaters;
|
||||
|
||||
private ReleaserProperties properties;
|
||||
|
||||
ProjectDocumentationUpdater(ReleaserProperties properties,
|
||||
ProjectGitHandler gitHandler) {
|
||||
ProjectGitHandler gitHandler,
|
||||
List<CustomProjectDocumentationUpdater> updaters) {
|
||||
this.gitHandler = gitHandler;
|
||||
this.properties = properties;
|
||||
this.updaters = updaters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the documentation repository if current release train version is greater or
|
||||
* equal than the one stored in the repo.
|
||||
* @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(ProjectVersion currentProject, String bomBranch) {
|
||||
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 "
|
||||
@@ -73,85 +64,10 @@ class ProjectDocumentationUpdater implements ReleaserPropertiesAware {
|
||||
}
|
||||
File documentationProject = this.gitHandler.cloneDocumentationProject();
|
||||
log.debug("Cloning the doc project to [{}]", documentationProject);
|
||||
String pathToIndexHtml = "current/index.html";
|
||||
File indexHtml = new File(documentationProject, pathToIndexHtml);
|
||||
if (!indexHtml.exists()) {
|
||||
throw new IllegalStateException(
|
||||
"index.html is not present at [" + pathToIndexHtml + "]");
|
||||
}
|
||||
return updateTheDocsRepo(bomBranch, documentationProject, indexHtml);
|
||||
}
|
||||
|
||||
private File updateTheDocsRepo(String springCloudReleaseBranch,
|
||||
File documentationProject, File indexHtml) {
|
||||
try {
|
||||
String indexHtmlText = readIndexHtmlContents(indexHtml);
|
||||
int httpIndex = indexHtmlText.indexOf(HTTP_SC_STATIC_URL);
|
||||
int httpsIndex = indexHtmlText.indexOf(HTTPS_SC_STATIC_URL);
|
||||
if (httpIndex == -1 && httpsIndex == -1) {
|
||||
throw new IllegalStateException(
|
||||
"The URL to the documentation repo not found in the index.html file");
|
||||
}
|
||||
int beginIndex = beginIndex(httpIndex, httpsIndex);
|
||||
String storedReleaseTrainLine = indexHtmlText.substring(beginIndex);
|
||||
String storedReleaseTrain = storedReleaseTrainLine.substring(0,
|
||||
storedReleaseTrainLine.indexOf("/"));
|
||||
String firstLetterOfReleaseTrain = String
|
||||
.valueOf(storedReleaseTrain.charAt(0));
|
||||
String currentReleaseTrainVersion = branchToReleaseVersion(
|
||||
springCloudReleaseBranch);
|
||||
String firstLetterOfCurrentReleaseTrain = String
|
||||
.valueOf(currentReleaseTrainVersion.charAt(0));
|
||||
boolean newerOrEqualReleaseTrain = (!storedReleaseTrain
|
||||
.equals(currentReleaseTrainVersion))
|
||||
&& firstLetterOfCurrentReleaseTrain
|
||||
.compareToIgnoreCase(firstLetterOfReleaseTrain) >= 0;
|
||||
if (!newerOrEqualReleaseTrain) {
|
||||
log.info(
|
||||
"Current release train [{}] is not newer than the stored one [{}]",
|
||||
currentReleaseTrainVersion, storedReleaseTrain);
|
||||
return documentationProject;
|
||||
}
|
||||
return pushCommitedChanges(currentReleaseTrainVersion, documentationProject,
|
||||
indexHtml, indexHtmlText, storedReleaseTrain);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private int beginIndex(int httpIndex, int httpsIndex) {
|
||||
if (httpIndex != -1) {
|
||||
return httpIndex + HTTP_SC_STATIC_URL.length();
|
||||
}
|
||||
return httpsIndex + HTTPS_SC_STATIC_URL.length();
|
||||
}
|
||||
|
||||
private String branchToReleaseVersion(String springCloudReleaseBranch) {
|
||||
if (springCloudReleaseBranch.startsWith("v")) {
|
||||
return springCloudReleaseBranch.substring(1);
|
||||
}
|
||||
return springCloudReleaseBranch;
|
||||
}
|
||||
|
||||
private File pushCommitedChanges(String currentReleaseTrainVersion,
|
||||
File documentationProject, File indexHtml, String indexHtmlText,
|
||||
String storedReleaseTrain) throws IOException {
|
||||
String replacedIndexHtml = indexHtmlText.replace(storedReleaseTrain,
|
||||
currentReleaseTrainVersion);
|
||||
Files.write(indexHtml.toPath(), replacedIndexHtml.getBytes());
|
||||
log.info("Stored the release train [{}] in [{}]", currentReleaseTrainVersion,
|
||||
indexHtml.getAbsolutePath());
|
||||
this.gitHandler.commit(documentationProject,
|
||||
"Updating the link to the current version to ["
|
||||
+ currentReleaseTrainVersion + "]");
|
||||
this.gitHandler.pushCurrentBranch(documentationProject);
|
||||
log.info("Committed and pushed changes to the documentation project");
|
||||
return documentationProject;
|
||||
}
|
||||
|
||||
String readIndexHtmlContents(File indexHtml) throws IOException {
|
||||
return new String(Files.readAllBytes(indexHtml.toPath()));
|
||||
CustomProjectDocumentationUpdater updater = this.updaters.stream().filter(
|
||||
u -> u.isApplicable(documentationProject, currentProject, bomBranch))
|
||||
.findFirst().orElse(CustomProjectDocumentationUpdater.NO_OP);
|
||||
return updater.updateDocsRepo(documentationProject, currentProject, bomBranch);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,8 +33,8 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.ReleaserPropertiesAware;
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
import org.springframework.cloud.release.internal.tech.HandlebarsHelper;
|
||||
import org.springframework.cloud.release.internal.template.TemplateGenerator;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -42,6 +42,7 @@ import org.springframework.util.StringUtils;
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
// TODO: [SPRING-CLOUD]
|
||||
class ReleaseTrainContentsUpdater implements ReleaserPropertiesAware {
|
||||
|
||||
private static final Logger log = LoggerFactory
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
|
||||
@@ -27,13 +27,12 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.ReleaserPropertiesAware;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.tech.TemporaryFileStorage;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Contains business logic around Git & Github operations.
|
||||
* Contains business logic around Git operations.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
@@ -51,19 +50,17 @@ public class ProjectGitHandler implements ReleaserPropertiesAware {
|
||||
|
||||
private static final String POST_RELEASE_BUMP_MSG = "Bumping versions to %s after release";
|
||||
|
||||
private final GithubMilestones githubMilestones;
|
||||
|
||||
private final GithubIssues githubIssues;
|
||||
|
||||
private ReleaserProperties properties;
|
||||
|
||||
public ProjectGitHandler(ReleaserProperties properties) {
|
||||
this.properties = properties;
|
||||
this.githubMilestones = new GithubMilestones(properties);
|
||||
this.githubIssues = new GithubIssues(properties);
|
||||
registerShutdownHook();
|
||||
}
|
||||
|
||||
static void clearCache() {
|
||||
CACHE.clear();
|
||||
}
|
||||
|
||||
private void registerShutdownHook() {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(TemporaryFileStorage::cleanup));
|
||||
}
|
||||
@@ -267,22 +264,6 @@ public class ProjectGitHandler implements ReleaserPropertiesAware {
|
||||
gitRepo(project).pushCurrentBranch();
|
||||
}
|
||||
|
||||
public void closeMilestone(ProjectVersion releaseVersion) {
|
||||
this.githubMilestones.closeMilestone(releaseVersion);
|
||||
}
|
||||
|
||||
public void createIssueInSpringGuides(Projects projects, ProjectVersion version) {
|
||||
this.githubIssues.fileIssueInSpringGuides(projects, version);
|
||||
}
|
||||
|
||||
public void createIssueInStartSpringIo(Projects projects, ProjectVersion version) {
|
||||
this.githubIssues.fileIssueInStartSpringIo(projects, version);
|
||||
}
|
||||
|
||||
public String milestoneUrl(ProjectVersion releaseVersion) {
|
||||
return this.githubMilestones.milestoneUrl(releaseVersion);
|
||||
}
|
||||
|
||||
public String currentBranch(File project) {
|
||||
return gitRepo(project).currentBranch();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.git;
|
||||
package org.springframework.cloud.release.internal.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.git;
|
||||
package org.springframework.cloud.release.internal.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
@@ -30,8 +30,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.git;
|
||||
package org.springframework.cloud.release.internal.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
@@ -32,7 +32,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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.github;
|
||||
|
||||
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.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
import org.springframework.cloud.release.internal.tech.TemporaryFileStorage;
|
||||
|
||||
/**
|
||||
* Contains business logic around Github operations.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class ProjectGitHubHandler implements ReleaserPropertiesAware {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ProjectGitHubHandler.class);
|
||||
|
||||
private final GithubMilestones githubMilestones;
|
||||
|
||||
private final GithubIssues githubIssues;
|
||||
|
||||
private ReleaserProperties properties;
|
||||
|
||||
public ProjectGitHubHandler(ReleaserProperties properties) {
|
||||
this.properties = properties;
|
||||
this.githubMilestones = new GithubMilestones(properties);
|
||||
this.githubIssues = new GithubIssues(properties);
|
||||
registerShutdownHook();
|
||||
}
|
||||
|
||||
private void registerShutdownHook() {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(TemporaryFileStorage::cleanup));
|
||||
}
|
||||
|
||||
public void closeMilestone(ProjectVersion releaseVersion) {
|
||||
this.githubMilestones.closeMilestone(releaseVersion);
|
||||
}
|
||||
|
||||
public void createIssueInSpringGuides(Projects projects, ProjectVersion version) {
|
||||
this.githubIssues.fileIssueInSpringGuides(projects, version);
|
||||
}
|
||||
|
||||
public void createIssueInStartSpringIo(Projects projects, ProjectVersion version) {
|
||||
this.githubIssues.fileIssueInStartSpringIo(projects, version);
|
||||
}
|
||||
|
||||
public String milestoneUrl(ProjectVersion releaseVersion) {
|
||||
return this.githubMilestones.milestoneUrl(releaseVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReleaserProperties(ReleaserProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,149 +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
|
||||
*
|
||||
* 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.pom;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
|
||||
import static org.springframework.cloud.release.internal.pom.SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID;
|
||||
|
||||
/**
|
||||
* Parses the poms for a given project and populates versions from a release train.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
class BomParser {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(BomParser.class);
|
||||
|
||||
private final File thisProjectRoot;
|
||||
|
||||
private final String pomWithBootStarterParent;
|
||||
|
||||
private final String thisTrainBom;
|
||||
|
||||
private final PomReader pomReader = new PomReader();
|
||||
|
||||
private final Pattern versionPattern;
|
||||
|
||||
private final ReleaserProperties properties;
|
||||
|
||||
BomParser(ReleaserProperties properties, File thisProjectRoot) {
|
||||
this.thisProjectRoot = thisProjectRoot;
|
||||
this.pomWithBootStarterParent = properties.getPom().getPomWithBootStarterParent();
|
||||
this.thisTrainBom = properties.getPom().getThisTrainBom();
|
||||
this.versionPattern = Pattern.compile(properties.getPom().getBomVersionPattern());
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
Versions allVersions() {
|
||||
Versions boot = bootVersion();
|
||||
Versions cloud = versionsFromBom();
|
||||
return new Versions(boot.bootVersion, cloud.scBuildVersion,
|
||||
allProjects(boot, cloud));
|
||||
}
|
||||
|
||||
private Set<Project> allProjects(Versions boot, Versions cloud) {
|
||||
Set<Project> allProjects = new HashSet<>();
|
||||
allProjects.addAll(boot.projects);
|
||||
allProjects.addAll(cloud.projects);
|
||||
return allProjects;
|
||||
}
|
||||
|
||||
Versions bootVersion() {
|
||||
Model model = pom(this.pomWithBootStarterParent);
|
||||
if (model == null) {
|
||||
return Versions.EMPTY_VERSION;
|
||||
}
|
||||
String bootArtifactId = model.getParent().getArtifactId();
|
||||
log.debug("Boot artifact id is equal to [{}]", bootArtifactId);
|
||||
if (!SpringCloudConstants.BOOT_STARTER_PARENT_ARTIFACT_ID
|
||||
.equals(bootArtifactId)) {
|
||||
throw new IllegalStateException("The pom doesn't have a ["
|
||||
+ SpringCloudConstants.BOOT_STARTER_PARENT_ARTIFACT_ID
|
||||
+ "] artifact id");
|
||||
}
|
||||
String bootVersion = model.getParent().getVersion();
|
||||
log.debug("Boot version is equal to [{}]", bootVersion);
|
||||
return new Versions(bootVersion);
|
||||
}
|
||||
|
||||
private Model pom(String pom) {
|
||||
if (pom == null) {
|
||||
throw new IllegalStateException("Pom is not present");
|
||||
}
|
||||
File pomFile = new File(this.thisProjectRoot, pom);
|
||||
if (!pomFile.exists()) {
|
||||
throw new IllegalStateException("Pom is not present");
|
||||
}
|
||||
return this.pomReader.readPom(pomFile);
|
||||
}
|
||||
|
||||
// the BOM contains all versions of projects and its parent MUST be Spring Cloud
|
||||
// Dependencies Parent
|
||||
Versions versionsFromBom() {
|
||||
Model model = pom(this.thisTrainBom);
|
||||
if (model == null) {
|
||||
return Versions.EMPTY_VERSION;
|
||||
}
|
||||
String buildArtifact = model.getParent().getArtifactId();
|
||||
log.debug("[{}] artifact id is equal to [{}]",
|
||||
CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildArtifact);
|
||||
if (!CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID.equals(buildArtifact)) {
|
||||
throw new IllegalStateException("The pom doesn't have a ["
|
||||
+ CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID + "] artifact id");
|
||||
}
|
||||
String buildVersion = model.getParent().getVersion();
|
||||
log.debug("Spring Cloud Build version is equal to [{}]", buildVersion);
|
||||
Set<Project> projects = model.getProperties().entrySet().stream()
|
||||
.filter(propertyMatchesSCPattern()).map(toProject())
|
||||
.collect(Collectors.toSet());
|
||||
String releaseTrainProjectVersion = model.getVersion();
|
||||
projects.add(
|
||||
new Project(this.properties.getMetaRelease().getReleaseTrainProjectName(),
|
||||
releaseTrainProjectVersion));
|
||||
return new Versions(buildVersion, projects);
|
||||
}
|
||||
|
||||
private Predicate<Map.Entry<Object, Object>> propertyMatchesSCPattern() {
|
||||
return entry -> this.versionPattern.matcher(entry.getKey().toString()).matches();
|
||||
}
|
||||
|
||||
private Function<Map.Entry<Object, Object>, Project> toProject() {
|
||||
return entry -> {
|
||||
Matcher matcher = this.versionPattern.matcher(entry.getKey().toString());
|
||||
// you have to first match to get info about the group
|
||||
matcher.matches();
|
||||
String name = matcher.group(1);
|
||||
return new Project(name, entry.getValue().toString());
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,286 +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
|
||||
*
|
||||
* 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.pom;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
|
||||
import static org.springframework.cloud.release.internal.pom.SpringCloudConstants.BOOT_DEPENDENCIES_ARTIFACT_ID;
|
||||
import static org.springframework.cloud.release.internal.pom.SpringCloudConstants.BOOT_STARTER_PARENT_ARTIFACT_ID;
|
||||
import static org.springframework.cloud.release.internal.pom.SpringCloudConstants.BUILD_ARTIFACT_ID;
|
||||
import static org.springframework.cloud.release.internal.pom.SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID;
|
||||
|
||||
/**
|
||||
* Represents versions taken out from Spring Cloud Release pom.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
class Versions {
|
||||
|
||||
static final Versions EMPTY_VERSION = new Versions("");
|
||||
|
||||
private static final String SPRING_BOOT_PROJECT_NAME = "spring-boot";
|
||||
|
||||
String bootVersion;
|
||||
|
||||
String scBuildVersion;
|
||||
|
||||
Set<Project> projects = new HashSet<>();
|
||||
|
||||
ReleaserProperties properties;
|
||||
|
||||
Versions(String bootVersion) {
|
||||
this.bootVersion = bootVersion;
|
||||
add(SPRING_BOOT_PROJECT_NAME, bootVersion);
|
||||
add(BOOT_STARTER_PARENT_ARTIFACT_ID, bootVersion);
|
||||
add(BOOT_DEPENDENCIES_ARTIFACT_ID, bootVersion);
|
||||
this.properties = new ReleaserProperties();
|
||||
}
|
||||
|
||||
Versions(String scBuildVersion, Set<Project> projects) {
|
||||
this.scBuildVersion = scBuildVersion;
|
||||
add(BUILD_ARTIFACT_ID, scBuildVersion);
|
||||
add(CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, scBuildVersion);
|
||||
this.projects.addAll(projects);
|
||||
this.properties = new ReleaserProperties();
|
||||
}
|
||||
|
||||
Versions(String bootVersion, String scBuildVersion, Set<Project> projects) {
|
||||
this(new ReleaserProperties(), bootVersion, scBuildVersion, projects);
|
||||
}
|
||||
|
||||
Versions(ReleaserProperties properties, String bootVersion, String scBuildVersion,
|
||||
Set<Project> projects) {
|
||||
this.properties = properties;
|
||||
this.bootVersion = bootVersion;
|
||||
this.scBuildVersion = scBuildVersion;
|
||||
add(SPRING_BOOT_PROJECT_NAME, bootVersion);
|
||||
add(BOOT_STARTER_PARENT_ARTIFACT_ID, bootVersion);
|
||||
add(BOOT_DEPENDENCIES_ARTIFACT_ID, bootVersion);
|
||||
add(BUILD_ARTIFACT_ID, scBuildVersion);
|
||||
add(dependenciesParentArtifactId(), scBuildVersion);
|
||||
this.projects.addAll(projects);
|
||||
}
|
||||
|
||||
Versions(Set<ProjectVersion> versions, ReleaserProperties properties) {
|
||||
this.properties = properties;
|
||||
this.bootVersion = versions.stream()
|
||||
.filter(projectVersion -> SPRING_BOOT_PROJECT_NAME
|
||||
.equals(projectVersion.projectName))
|
||||
.findFirst()
|
||||
.orElse(new ProjectVersion(SPRING_BOOT_PROJECT_NAME, "")).version;
|
||||
this.scBuildVersion = versions.stream().filter(
|
||||
projectVersion -> BUILD_ARTIFACT_ID.equals(projectVersion.projectName))
|
||||
.findFirst().orElse(new ProjectVersion(BUILD_ARTIFACT_ID, "")).version;
|
||||
versions.forEach(projectVersion -> setVersion(projectVersion.projectName,
|
||||
projectVersion.version));
|
||||
}
|
||||
|
||||
private String bomProjectName() {
|
||||
return this.properties.getMetaRelease().getReleaseTrainProjectName();
|
||||
}
|
||||
|
||||
private String dependenciesArtifactId() {
|
||||
String artifactId = this.properties.getPom().getThisTrainBom();
|
||||
return artifactId.split(File.separator)[0];
|
||||
}
|
||||
|
||||
private String dependenciesParentArtifactId() {
|
||||
return dependenciesArtifactId() + "-parent";
|
||||
}
|
||||
|
||||
String versionForProject(String projectName) {
|
||||
return this.projects.stream().filter(project -> nameMatches(projectName, project))
|
||||
.findFirst().orElse(Project.EMPTY_PROJECT).version;
|
||||
}
|
||||
|
||||
boolean shouldBeUpdated(String projectName) {
|
||||
return this.projects.stream()
|
||||
.anyMatch(project -> nameMatches(projectName, project));
|
||||
}
|
||||
|
||||
boolean shouldSetProperty(Properties properties) {
|
||||
return this.projects.stream()
|
||||
.anyMatch(project -> properties.containsKey(project.name + ".version"));
|
||||
}
|
||||
|
||||
Projects toProjectVersions() {
|
||||
return this.projects.stream()
|
||||
.map(project -> new ProjectVersion(project.name, project.version))
|
||||
.collect(Collectors.toCollection(Projects::new));
|
||||
}
|
||||
|
||||
/**
|
||||
* The only exception is spring-cloud-dependencies (e.g. Greenwich.RELEASE) and
|
||||
* spring-cloud-dependencies-parent (e.g. 2.1.0.RELEASE)
|
||||
*/
|
||||
private boolean nameMatches(String projectName, Project project) {
|
||||
if (project.name.equals(projectName)) {
|
||||
return true;
|
||||
}
|
||||
boolean parent = matchesNameWithSuffix(projectName, "-parent", project);
|
||||
boolean bomArtifactId = comparisonOfBomArtifactAndParent(projectName, project);
|
||||
return !bomArtifactId && (parent
|
||||
|| matchesNameWithSuffix(projectName, "-dependencies", project));
|
||||
}
|
||||
|
||||
private boolean comparisonOfBomArtifactAndParent(String projectName,
|
||||
Project project) {
|
||||
return artifactOrParent(projectName, project.name)
|
||||
|| artifactOrParent(project.name, projectName);
|
||||
}
|
||||
|
||||
private boolean artifactOrParent(String projectName, String otherProjectName) {
|
||||
return projectName.equals(dependenciesArtifactId())
|
||||
&& otherProjectName.equals(dependenciesParentArtifactId());
|
||||
}
|
||||
|
||||
private boolean matchesNameWithSuffix(String projectName, String suffix,
|
||||
Project project) {
|
||||
boolean containsSuffix = projectName.endsWith(suffix);
|
||||
if (!containsSuffix) {
|
||||
return false;
|
||||
}
|
||||
String withoutSuffix = projectName.substring(0, projectName.indexOf(suffix));
|
||||
return project.name.equals(withoutSuffix);
|
||||
}
|
||||
|
||||
Versions setVersion(String projectName, String version) {
|
||||
switch (projectName) {
|
||||
case SPRING_BOOT_PROJECT_NAME:
|
||||
case BOOT_STARTER_PARENT_ARTIFACT_ID:
|
||||
case BOOT_DEPENDENCIES_ARTIFACT_ID:
|
||||
updateBootVersions(version);
|
||||
break;
|
||||
case BUILD_ARTIFACT_ID:
|
||||
case CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID:
|
||||
updateBuildVersions(version);
|
||||
break;
|
||||
default:
|
||||
if (bomVersionProjectNames().contains(projectName)) {
|
||||
updateBomVersions(version);
|
||||
}
|
||||
else {
|
||||
remove(projectName);
|
||||
add(projectName, version);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private List<String> bomVersionProjectNames() {
|
||||
List<String> names = new ArrayList<>(
|
||||
this.properties.getMetaRelease().getReleaseTrainDependencyNames());
|
||||
names.add(this.properties.getMetaRelease().getReleaseTrainProjectName());
|
||||
return names;
|
||||
}
|
||||
|
||||
private void updateBuildVersions(String version) {
|
||||
this.scBuildVersion = version;
|
||||
remove(BUILD_ARTIFACT_ID);
|
||||
remove(CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID);
|
||||
add(BUILD_ARTIFACT_ID, version);
|
||||
add(CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, version);
|
||||
}
|
||||
|
||||
private void updateBootVersions(String version) {
|
||||
this.bootVersion = version;
|
||||
remove(SPRING_BOOT_PROJECT_NAME);
|
||||
remove(BOOT_DEPENDENCIES_ARTIFACT_ID);
|
||||
remove(BOOT_STARTER_PARENT_ARTIFACT_ID);
|
||||
add(SPRING_BOOT_PROJECT_NAME, version);
|
||||
add(BOOT_STARTER_PARENT_ARTIFACT_ID, version);
|
||||
add(BOOT_DEPENDENCIES_ARTIFACT_ID, version);
|
||||
}
|
||||
|
||||
private void updateBomVersions(String version) {
|
||||
remove(bomProjectName());
|
||||
bomVersionProjectNames().forEach(this::remove);
|
||||
add(bomProjectName(), version);
|
||||
bomVersionProjectNames().forEach(s -> add(s, version));
|
||||
}
|
||||
|
||||
private void add(String key, String value) {
|
||||
this.projects.add(new Project(key, value));
|
||||
}
|
||||
|
||||
private void remove(String expectedProjectName) {
|
||||
this.projects.removeIf(project -> expectedProjectName.equals(project.name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Spring Boot Version=[" + this.bootVersion + ']'
|
||||
+ "\nSpring Cloud Build Version=[" + this.scBuildVersion + ']'
|
||||
+ "\nProjects=\n\t" + this.projects.stream().map(Object::toString)
|
||||
.collect(Collectors.joining("\n\t"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
class Project {
|
||||
|
||||
static Project EMPTY_PROJECT = new Project("", "");
|
||||
|
||||
final String name;
|
||||
|
||||
final String version;
|
||||
|
||||
Project(String name, String version) {
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Project project = (Project) o;
|
||||
if (this.name != null ? !this.name.equals(project.name) : project.name != null) {
|
||||
return false;
|
||||
}
|
||||
return this.version != null ? this.version.equals(project.version)
|
||||
: project.version == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.name != null ? this.name.hashCode() : 0;
|
||||
result = 31 * result + (this.version != null ? this.version.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "name=[" + this.name + "], version=[" + this.version + ']';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.post;
|
||||
package org.springframework.cloud.release.internal.postrelease;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
@@ -32,13 +32,13 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.buildsystem.GradleUpdater;
|
||||
import org.springframework.cloud.release.internal.buildsystem.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.cloud.release.internal.gradle.GradleUpdater;
|
||||
import org.springframework.cloud.release.internal.pom.ProcessedProject;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.project.ProjectBuilder;
|
||||
import org.springframework.cloud.release.internal.project.ProcessedProject;
|
||||
import org.springframework.cloud.release.internal.project.ProjectCommandExecutor;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
import org.springframework.cloud.release.internal.versions.VersionsFetcher;
|
||||
import org.springframework.core.NestedExceptionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -58,7 +58,7 @@ public class PostReleaseActions implements Closeable {
|
||||
|
||||
private final GradleUpdater gradleUpdater;
|
||||
|
||||
private final ProjectBuilder projectBuilder;
|
||||
private final ProjectCommandExecutor projectCommandExecutor;
|
||||
|
||||
private final ReleaserProperties properties;
|
||||
|
||||
@@ -66,12 +66,12 @@ public class PostReleaseActions implements Closeable {
|
||||
|
||||
public PostReleaseActions(ProjectGitHandler projectGitHandler,
|
||||
ProjectPomUpdater projectPomUpdater, GradleUpdater gradleUpdater,
|
||||
ProjectBuilder projectBuilder, ReleaserProperties properties,
|
||||
ProjectCommandExecutor projectCommandExecutor, ReleaserProperties properties,
|
||||
VersionsFetcher versionsFetcher) {
|
||||
this.projectGitHandler = projectGitHandler;
|
||||
this.projectPomUpdater = projectPomUpdater;
|
||||
this.gradleUpdater = gradleUpdater;
|
||||
this.projectBuilder = projectBuilder;
|
||||
this.projectCommandExecutor = projectCommandExecutor;
|
||||
this.properties = properties;
|
||||
this.versionsFetcher = versionsFetcher;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class PostReleaseActions implements Closeable {
|
||||
Projects newProjects = addVersionForTestsProject(projects, projectVersion,
|
||||
releaseTrainVersion);
|
||||
updateWithVersions(file, newProjects);
|
||||
this.projectBuilder.build(projectVersion, file.getAbsolutePath());
|
||||
this.projectCommandExecutor.build(projectVersion, file.getAbsolutePath());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,8 +177,8 @@ public class PostReleaseActions implements Closeable {
|
||||
.map(this::getSingleResult).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
ProjectBuilder projectBuilder(ProcessedProject processedProject) {
|
||||
return new ProjectBuilder(processedProject.propertiesForProject);
|
||||
ProjectCommandExecutor projectBuilder(ProcessedProject processedProject) {
|
||||
return new ProjectCommandExecutor(processedProject.propertiesForProject);
|
||||
}
|
||||
|
||||
private Future<List<ProjectUrlAndException>> updateAllProjects(Projects projects,
|
||||
@@ -296,7 +296,7 @@ public class PostReleaseActions implements Closeable {
|
||||
Projects newProjects = addVersionForTestsProject(projects, projectVersion,
|
||||
releaseTrainVersion);
|
||||
updateWithVersions(file, newProjects);
|
||||
this.projectBuilder.generateReleaseTrainDocs(releaseTrainVersion,
|
||||
this.projectCommandExecutor.generateReleaseTrainDocs(releaseTrainVersion,
|
||||
file.getAbsolutePath());
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.internal.project;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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.project;
|
||||
|
||||
/**
|
||||
* Represents a single project.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class Project {
|
||||
|
||||
/**
|
||||
* An empty project.
|
||||
*/
|
||||
public static Project EMPTY_PROJECT = new Project("", "");
|
||||
|
||||
/**
|
||||
* Project name.
|
||||
*/
|
||||
public final String name;
|
||||
|
||||
/**
|
||||
* Project version.
|
||||
*/
|
||||
public final String version;
|
||||
|
||||
public Project(String name, String version) {
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Project project = (Project) o;
|
||||
if (this.name != null ? !this.name.equals(project.name) : project.name != null) {
|
||||
return false;
|
||||
}
|
||||
return this.version != null ? this.version.equals(project.version)
|
||||
: project.version == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.name != null ? this.name.hashCode() : 0;
|
||||
result = 31 * result + (this.version != null ? this.version.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "name=[" + this.name + "], version=[" + this.version + ']';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package org.springframework.cloud.release.internal.project;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@@ -27,77 +28,75 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
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.pom.ProjectVersion;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class ProjectBuilder implements ReleaserPropertiesAware {
|
||||
public class ProjectCommandExecutor implements ReleaserPropertiesAware {
|
||||
|
||||
/**
|
||||
* Enumeration over commonly used Maven profiles.
|
||||
*/
|
||||
private enum Profile {
|
||||
|
||||
/**
|
||||
* Profile used for milestone versions.
|
||||
*/
|
||||
MILESTONE,
|
||||
|
||||
/**
|
||||
* Profile used for ga versions.
|
||||
*/
|
||||
CENTRAL,
|
||||
|
||||
/**
|
||||
* Profile used to run integration tests.
|
||||
*/
|
||||
INTEGRATION,
|
||||
|
||||
/**
|
||||
* Profile used to run guides publishing.
|
||||
*/
|
||||
GUIDES;
|
||||
|
||||
/**
|
||||
* Converts the profile to lowercase, maven command line property.
|
||||
* @return profile with prepended -P
|
||||
*/
|
||||
public String asMavenProfile() {
|
||||
return "-P" + this.name().toLowerCase();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ProjectBuilder.class);
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(ProjectCommandExecutor.class);
|
||||
|
||||
private static final String VERSION_MUSTACHE = "{{version}}";
|
||||
|
||||
private ReleaserProperties properties;
|
||||
|
||||
public ProjectBuilder(ReleaserProperties properties) {
|
||||
public ProjectCommandExecutor(ReleaserProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
// If you want to call commands that are not parameterized via the props
|
||||
public ProjectCommandExecutor() {
|
||||
this.properties = new ReleaserProperties();
|
||||
}
|
||||
|
||||
public void build(ProjectVersion versionFromReleaseTrain) {
|
||||
build(versionFromReleaseTrain, this.properties.getWorkingDir());
|
||||
}
|
||||
|
||||
public String version() {
|
||||
return executeCommand(
|
||||
new CommandPicker(this.properties, this.properties.getWorkingDir())
|
||||
.version());
|
||||
}
|
||||
|
||||
public String groupId() {
|
||||
return executeCommand(
|
||||
new CommandPicker(this.properties, this.properties.getWorkingDir())
|
||||
.groupId());
|
||||
}
|
||||
|
||||
private String executeCommand(String command) {
|
||||
try {
|
||||
String projectRoot = this.properties.getWorkingDir();
|
||||
String[] commands = command.split(" ");
|
||||
return runCommand(projectRoot, commands);
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void build(ProjectVersion versionFromReleaseTrain, String projectRoot) {
|
||||
try {
|
||||
String[] commands = commandWithSystemProps(
|
||||
this.properties.getMaven().getBuildCommand(), versionFromReleaseTrain)
|
||||
.split(" ");
|
||||
String[] commands = new CommandPicker(this.properties, projectRoot)
|
||||
.buildCommand(versionFromReleaseTrain).split(" ");
|
||||
runCommand(projectRoot, commands);
|
||||
assertNoHtmlFilesInDocsContainUnresolvedTags(projectRoot);
|
||||
log.info("No HTML files from docs contain unresolved tags");
|
||||
@@ -109,8 +108,9 @@ public class ProjectBuilder implements ReleaserPropertiesAware {
|
||||
|
||||
public void generateReleaseTrainDocs(String version, String projectRoot) {
|
||||
try {
|
||||
String updatedCommand = this.properties.getMaven()
|
||||
.getGenerateReleaseTrainDocsCommand()
|
||||
String updatedCommand = new CommandPicker(properties, projectRoot)
|
||||
.generateReleaseTrainDocsCommand(
|
||||
new ProjectVersion(new File(projectRoot)))
|
||||
.replace(VERSION_MUSTACHE, version);
|
||||
runCommand(projectRoot, updatedCommand.split(" "));
|
||||
assertNoHtmlFilesInDocsContainUnresolvedTags(this.properties.getWorkingDir());
|
||||
@@ -121,39 +121,6 @@ public class ProjectBuilder implements ReleaserPropertiesAware {
|
||||
}
|
||||
}
|
||||
|
||||
private String commandWithSystemProps(String command, ProjectVersion version,
|
||||
Profile... profiles) {
|
||||
if (command.contains(ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER)) {
|
||||
return appendProfile(command, version, profiles);
|
||||
}
|
||||
return appendProfile(command, version, profiles) + " "
|
||||
+ ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER;
|
||||
}
|
||||
|
||||
private String appendProfile(String command, ProjectVersion version,
|
||||
Profile... profiles) {
|
||||
String trimmedCommand = command.trim();
|
||||
if (version.isMilestone() || version.isRc()) {
|
||||
log.info("Adding the milestone profile to the Maven build");
|
||||
return trimmedCommand + " " + Profile.MILESTONE.asMavenProfile()
|
||||
+ profilesToString(profiles);
|
||||
}
|
||||
else if (version.isRelease() || version.isServiceRelease()) {
|
||||
log.info("Adding the central profile to the Maven build");
|
||||
return trimmedCommand + " " + Profile.CENTRAL.asMavenProfile()
|
||||
+ profilesToString(profiles);
|
||||
}
|
||||
else {
|
||||
log.info("The build is a snapshot one - will not add any profiles");
|
||||
}
|
||||
return trimmedCommand;
|
||||
}
|
||||
|
||||
private String profilesToString(Profile... profiles) {
|
||||
return Arrays.stream(profiles).map(profile -> "-P" + profile)
|
||||
.collect(Collectors.joining(" "));
|
||||
}
|
||||
|
||||
private void assertNoHtmlFilesInDocsContainUnresolvedTags(String workingDir) {
|
||||
try {
|
||||
File docs = new File(workingDir, "docs");
|
||||
@@ -168,18 +135,18 @@ public class ProjectBuilder implements ReleaserPropertiesAware {
|
||||
}
|
||||
|
||||
public void deploy(ProjectVersion version) {
|
||||
doDeploy(version, this.properties.getMaven().getDeployCommand());
|
||||
doDeploy(new CommandPicker(properties, this.properties.getWorkingDir())
|
||||
.deployCommand(version));
|
||||
}
|
||||
|
||||
public void deployGuides(ProjectVersion version) {
|
||||
doDeploy(version, this.properties.getMaven().getDeployGuidesCommand(),
|
||||
Profile.GUIDES, Profile.INTEGRATION);
|
||||
doDeploy(new CommandPicker(properties, this.properties.getWorkingDir())
|
||||
.deployGuidesCommand(version));
|
||||
}
|
||||
|
||||
private void doDeploy(ProjectVersion version, String command, Profile... profiles) {
|
||||
private void doDeploy(String command) {
|
||||
try {
|
||||
String[] commands = commandWithSystemProps(command, version, profiles)
|
||||
.split(" ");
|
||||
String[] commands = command.split(" ");
|
||||
runCommand(commands);
|
||||
log.info("The project has successfully been deployed");
|
||||
}
|
||||
@@ -192,10 +159,11 @@ public class ProjectBuilder implements ReleaserPropertiesAware {
|
||||
runCommand(this.properties.getWorkingDir(), commands);
|
||||
}
|
||||
|
||||
private void runCommand(String projectRoot, String[] commands) {
|
||||
private String runCommand(String projectRoot, String[] commands) {
|
||||
String[] substitutedCommands = substituteSystemProps(commands);
|
||||
long waitTimeInMinutes = this.properties.getMaven().getWaitTimeInMinutes();
|
||||
executor(projectRoot).runCommand(substitutedCommands, waitTimeInMinutes);
|
||||
long waitTimeInMinutes = new CommandPicker(properties, projectRoot)
|
||||
.waitTimeInMinutes();
|
||||
return executor(projectRoot).runCommand(substitutedCommands, waitTimeInMinutes);
|
||||
}
|
||||
|
||||
ProcessExecutor executor(String workDir) {
|
||||
@@ -204,7 +172,7 @@ public class ProjectBuilder implements ReleaserPropertiesAware {
|
||||
|
||||
public void publishDocs(String version) {
|
||||
try {
|
||||
for (String command : this.properties.getMaven().getPublishDocsCommands()) {
|
||||
for (String command : new CommandPicker(properties).publishDocsCommands()) {
|
||||
command = command.replace(VERSION_MUSTACHE, version);
|
||||
String[] commands = command.split(" ");
|
||||
runCommand(commands);
|
||||
@@ -221,10 +189,12 @@ public class ProjectBuilder implements ReleaserPropertiesAware {
|
||||
* just pasting the String that contains these values.
|
||||
*/
|
||||
private String[] substituteSystemProps(String... commands) {
|
||||
boolean containsSystemProps = this.properties.getMaven().getSystemProperties()
|
||||
.contains("-D");
|
||||
String[] splitSystemProps = StringUtils.delimitedListToStringArray(
|
||||
this.properties.getMaven().getSystemProperties(), "-D");
|
||||
String systemProperties = new CommandPicker(this.properties).systemProperties();
|
||||
String systemPropertiesPlaceholder = new CommandPicker(this.properties)
|
||||
.systemPropertiesPlaceholder();
|
||||
boolean containsSystemProps = systemProperties.contains("-D");
|
||||
String[] splitSystemProps = StringUtils
|
||||
.delimitedListToStringArray(systemProperties, "-D");
|
||||
// first element might be empty even though the second one contains values
|
||||
if (splitSystemProps.length > 1) {
|
||||
splitSystemProps = StringUtils.isEmpty(splitSystemProps[0])
|
||||
@@ -237,7 +207,7 @@ public class ProjectBuilder implements ReleaserPropertiesAware {
|
||||
: splitSystemProps;
|
||||
final AtomicInteger index = new AtomicInteger(-1);
|
||||
for (int i = 0; i < commands.length; i++) {
|
||||
if (commands[i].contains(ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER)) {
|
||||
if (commands[i].contains(systemPropertiesPlaceholder)) {
|
||||
index.set(i);
|
||||
break;
|
||||
}
|
||||
@@ -282,7 +252,7 @@ class ProcessExecutor implements ReleaserPropertiesAware {
|
||||
this.workingDir = workingDir;
|
||||
}
|
||||
|
||||
void runCommand(String[] commands, long waitTimeInMinutes) {
|
||||
String runCommand(String[] commands, long waitTimeInMinutes) {
|
||||
try {
|
||||
String workingDir = this.workingDir;
|
||||
log.info(
|
||||
@@ -302,12 +272,18 @@ class ProcessExecutor implements ReleaserPropertiesAware {
|
||||
throw new IllegalStateException("The process has exited with exit code ["
|
||||
+ process.exitValue() + "]");
|
||||
}
|
||||
return convertStreamToString(process.getInputStream());
|
||||
}
|
||||
catch (InterruptedException | IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String convertStreamToString(InputStream is) {
|
||||
Scanner scanner = new Scanner(is).useDelimiter("\\A");
|
||||
return scanner.hasNext() ? scanner.next() : "";
|
||||
}
|
||||
|
||||
Process startProcess(ProcessBuilder builder) throws IOException {
|
||||
return builder.start();
|
||||
}
|
||||
@@ -323,6 +299,238 @@ class ProcessExecutor implements ReleaserPropertiesAware {
|
||||
|
||||
}
|
||||
|
||||
class CommandPicker {
|
||||
|
||||
private static final Log log = LogFactory.getLog(CommandPicker.class);
|
||||
|
||||
private final ReleaserProperties releaserProperties;
|
||||
|
||||
private final ProjectType projectType;
|
||||
|
||||
CommandPicker(ReleaserProperties releaserProperties, String projectRoot) {
|
||||
this.releaserProperties = releaserProperties;
|
||||
this.projectType = guessProjectType(projectRoot);
|
||||
}
|
||||
|
||||
CommandPicker(ReleaserProperties releaserProperties) {
|
||||
this.releaserProperties = releaserProperties;
|
||||
String projectRoot = releaserProperties.getWorkingDir();
|
||||
this.projectType = guessProjectType(projectRoot);
|
||||
}
|
||||
|
||||
private ProjectType guessProjectType(String projectRoot) {
|
||||
if (new File(projectRoot, "pom.xml").exists()) {
|
||||
return ProjectType.MAVEN;
|
||||
}
|
||||
else if (new File(projectRoot, "build.gradle").exists()) {
|
||||
return ProjectType.GRADLE;
|
||||
}
|
||||
return ProjectType.BASH;
|
||||
}
|
||||
|
||||
String systemProperties() {
|
||||
if (projectType == ProjectType.GRADLE) {
|
||||
return releaserProperties.getGradle().getSystemProperties();
|
||||
}
|
||||
else if (projectType == ProjectType.MAVEN) {
|
||||
return releaserProperties.getMaven().getSystemProperties();
|
||||
}
|
||||
return releaserProperties.getBash().getSystemProperties();
|
||||
}
|
||||
|
||||
public String[] publishDocsCommands() {
|
||||
if (projectType == ProjectType.GRADLE) {
|
||||
return releaserProperties.getGradle().getPublishDocsCommands();
|
||||
}
|
||||
else if (projectType == ProjectType.MAVEN) {
|
||||
return releaserProperties.getMaven().getPublishDocsCommands();
|
||||
}
|
||||
return releaserProperties.getBash().getPublishDocsCommands();
|
||||
}
|
||||
|
||||
String systemPropertiesPlaceholder() {
|
||||
if (projectType == ProjectType.GRADLE) {
|
||||
return ReleaserProperties.Gradle.SYSTEM_PROPS_PLACEHOLDER;
|
||||
}
|
||||
else if (projectType == ProjectType.MAVEN) {
|
||||
return ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER;
|
||||
}
|
||||
return ReleaserProperties.Bash.SYSTEM_PROPS_PLACEHOLDER;
|
||||
}
|
||||
|
||||
String buildCommand(ProjectVersion version) {
|
||||
if (projectType == ProjectType.GRADLE) {
|
||||
return gradleCommandWithSystemProps(
|
||||
releaserProperties.getGradle().getBuildCommand());
|
||||
}
|
||||
else if (projectType == ProjectType.MAVEN) {
|
||||
return mavenCommandWithSystemProps(
|
||||
releaserProperties.getMaven().getBuildCommand(), version);
|
||||
}
|
||||
return bashCommandWithSystemProps(releaserProperties.getBash().getBuildCommand());
|
||||
}
|
||||
|
||||
String version() {
|
||||
// makes more sense to use PomReader
|
||||
if (projectType == ProjectType.GRADLE) {
|
||||
return "./gradlew properties | grep version: | awk '{print $2}'";
|
||||
}
|
||||
return "./mvnw -q" + " -Dexec.executable=\"echo\""
|
||||
+ " -Dexec.args=\"\\${project.version}\"" + " --non-recursive"
|
||||
+ " org.codehaus.mojo:exec-maven-plugin:1.3.1:exec | tail -1";
|
||||
}
|
||||
|
||||
String groupId() {
|
||||
// makes more sense to use PomReader
|
||||
if (projectType == ProjectType.GRADLE) {
|
||||
return "./gradlew groupId | tail -1";
|
||||
}
|
||||
return "./mvnw -q" + " -Dexec.executable=\"echo\""
|
||||
+ " -Dexec.args=\"\\${project.groupId}\"" + " --non-recursive"
|
||||
+ " org.codehaus.mojo:exec-maven-plugin:1.3.1:exec | tail -1";
|
||||
}
|
||||
|
||||
String generateReleaseTrainDocsCommand(ProjectVersion version) {
|
||||
if (projectType == ProjectType.GRADLE) {
|
||||
return gradleCommandWithSystemProps(
|
||||
releaserProperties.getGradle().getGenerateReleaseTrainDocsCommand());
|
||||
}
|
||||
else if (projectType == ProjectType.MAVEN) {
|
||||
return mavenCommandWithSystemProps(
|
||||
releaserProperties.getMaven().getGenerateReleaseTrainDocsCommand(),
|
||||
version);
|
||||
}
|
||||
return bashCommandWithSystemProps(
|
||||
releaserProperties.getBash().getGenerateReleaseTrainDocsCommand());
|
||||
}
|
||||
|
||||
String deployCommand(ProjectVersion version) {
|
||||
if (projectType == ProjectType.GRADLE) {
|
||||
return gradleCommandWithSystemProps(
|
||||
releaserProperties.getGradle().getDeployCommand());
|
||||
}
|
||||
else if (projectType == ProjectType.MAVEN) {
|
||||
return mavenCommandWithSystemProps(
|
||||
releaserProperties.getMaven().getDeployCommand(), version);
|
||||
}
|
||||
return bashCommandWithSystemProps(
|
||||
releaserProperties.getBash().getDeployCommand());
|
||||
}
|
||||
|
||||
String deployGuidesCommand(ProjectVersion version) {
|
||||
if (projectType == ProjectType.GRADLE) {
|
||||
return gradleCommandWithSystemProps(
|
||||
releaserProperties.getGradle().getDeployGuidesCommand());
|
||||
}
|
||||
else if (projectType == ProjectType.MAVEN) {
|
||||
return mavenCommandWithSystemProps(
|
||||
releaserProperties.getMaven().getDeployGuidesCommand(), version,
|
||||
MavenProfile.GUIDES, MavenProfile.INTEGRATION);
|
||||
}
|
||||
return bashCommandWithSystemProps(
|
||||
releaserProperties.getBash().getDeployGuidesCommand());
|
||||
}
|
||||
|
||||
long waitTimeInMinutes() {
|
||||
if (projectType == ProjectType.GRADLE) {
|
||||
return releaserProperties.getGradle().getWaitTimeInMinutes();
|
||||
}
|
||||
else if (projectType == ProjectType.MAVEN) {
|
||||
return releaserProperties.getMaven().getWaitTimeInMinutes();
|
||||
}
|
||||
return releaserProperties.getBash().getWaitTimeInMinutes();
|
||||
}
|
||||
|
||||
private String gradleCommandWithSystemProps(String command) {
|
||||
if (command.contains(ReleaserProperties.Gradle.SYSTEM_PROPS_PLACEHOLDER)) {
|
||||
return command;
|
||||
}
|
||||
return command + " " + ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER;
|
||||
}
|
||||
|
||||
private String mavenCommandWithSystemProps(String command, ProjectVersion version,
|
||||
MavenProfile... profiles) {
|
||||
if (command.contains(ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER)) {
|
||||
return appendMavenProfile(command, version, profiles);
|
||||
}
|
||||
return appendMavenProfile(command, version, profiles) + " "
|
||||
+ ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER;
|
||||
}
|
||||
|
||||
private String bashCommandWithSystemProps(String command) {
|
||||
if (command.contains(ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER)) {
|
||||
return command;
|
||||
}
|
||||
return command + " " + ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER;
|
||||
}
|
||||
|
||||
private String appendMavenProfile(String command, ProjectVersion version,
|
||||
MavenProfile... profiles) {
|
||||
String trimmedCommand = command.trim();
|
||||
if (version.isMilestone() || version.isRc()) {
|
||||
log.info("Adding the milestone profile to the Maven build");
|
||||
return trimmedCommand + " " + MavenProfile.MILESTONE.asMavenProfile()
|
||||
+ profilesToString(profiles);
|
||||
}
|
||||
else if (version.isRelease() || version.isServiceRelease()) {
|
||||
log.info("Adding the central profile to the Maven build");
|
||||
return trimmedCommand + " " + MavenProfile.CENTRAL.asMavenProfile()
|
||||
+ profilesToString(profiles);
|
||||
}
|
||||
else {
|
||||
log.info("The build is a snapshot one - will not add any profiles");
|
||||
}
|
||||
return trimmedCommand;
|
||||
}
|
||||
|
||||
private String profilesToString(MavenProfile... profiles) {
|
||||
return Arrays.stream(profiles).map(profile -> "-P" + profile)
|
||||
.collect(Collectors.joining(" "));
|
||||
}
|
||||
|
||||
private enum ProjectType {
|
||||
|
||||
MAVEN, GRADLE, BASH;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumeration over commonly used Maven profiles.
|
||||
*/
|
||||
private enum MavenProfile {
|
||||
|
||||
/**
|
||||
* Profile used for milestone versions.
|
||||
*/
|
||||
MILESTONE,
|
||||
|
||||
/**
|
||||
* Profile used for ga versions.
|
||||
*/
|
||||
CENTRAL,
|
||||
|
||||
/**
|
||||
* Profile used to run integration tests.
|
||||
*/
|
||||
INTEGRATION,
|
||||
|
||||
/**
|
||||
* Profile used to run guides publishing.
|
||||
*/
|
||||
GUIDES;
|
||||
|
||||
/**
|
||||
* Converts the profile to lowercase, maven command line property.
|
||||
* @return profile with prepended -P
|
||||
*/
|
||||
public String asMavenProfile() {
|
||||
return "-P" + this.name().toLowerCase();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class HtmlFileWalker extends SimpleFileVisitor<Path> {
|
||||
|
||||
private static final String HTML_EXTENSION = ".html";
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.internal.project;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
@@ -25,6 +25,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
import org.springframework.cloud.release.internal.tech.PomReader;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -60,27 +61,40 @@ public class ProjectVersion implements Comparable<ProjectVersion> {
|
||||
*/
|
||||
public final String version;
|
||||
|
||||
private final Model model;
|
||||
private final String groupId;
|
||||
|
||||
private final String artifactId;
|
||||
|
||||
public ProjectVersion(String projectName, String version) {
|
||||
this.projectName = nameWithoutParent(projectName);
|
||||
this.projectName = projectName;
|
||||
this.version = version;
|
||||
this.model = null;
|
||||
this.groupId = "";
|
||||
this.artifactId = "";
|
||||
}
|
||||
|
||||
public ProjectVersion(File project) {
|
||||
if (new File(project, "build.gradle").exists()) {
|
||||
ProjectVersion projectVersion = notMavenProject(project);
|
||||
ProjectVersion projectVersion = gradleProject(project);
|
||||
this.projectName = projectVersion.projectName;
|
||||
this.version = projectVersion.version;
|
||||
this.model = null;
|
||||
this.groupId = new ProjectCommandExecutor().groupId();
|
||||
this.artifactId = projectName;
|
||||
}
|
||||
else {
|
||||
PomReader pomReader = new PomReader();
|
||||
Model model = pomReader.readPom(project);
|
||||
this.projectName = nameWithoutParent(model.getArtifactId());
|
||||
this.version = model.getVersion();
|
||||
this.model = model;
|
||||
Model model = PomReader.readPom(project);
|
||||
if (model != null) {
|
||||
this.projectName = nameWithoutParent(model.getArtifactId());
|
||||
this.version = model.getVersion();
|
||||
this.groupId = groupId(model);
|
||||
this.artifactId = model.getArtifactId();
|
||||
}
|
||||
else {
|
||||
ProjectVersion projectVersion = notMavenProject(project);
|
||||
this.projectName = projectVersion.projectName;
|
||||
this.version = projectVersion.version;
|
||||
this.groupId = projectVersion.groupId;
|
||||
this.artifactId = projectVersion.artifactId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +105,13 @@ public class ProjectVersion implements Comparable<ProjectVersion> {
|
||||
return new ProjectVersion(nameWithoutParent(name), version);
|
||||
}
|
||||
|
||||
public static ProjectVersion gradleProject(File file) {
|
||||
File parentFolder = file.getParentFile() != null ? file.getParentFile() : file;
|
||||
String name = parentFolder.getName();
|
||||
String version = new ProjectCommandExecutor().version();
|
||||
return new ProjectVersion(nameWithoutParent(name), version);
|
||||
}
|
||||
|
||||
private static String nameWithoutParent(String projectName) {
|
||||
boolean containsParent = projectName.endsWith("-parent");
|
||||
if (!containsParent) {
|
||||
@@ -99,6 +120,20 @@ public class ProjectVersion implements Comparable<ProjectVersion> {
|
||||
return projectName.substring(0, projectName.indexOf("-parent"));
|
||||
}
|
||||
|
||||
private String groupId(Model model) {
|
||||
if (model == null) {
|
||||
return "";
|
||||
}
|
||||
if (StringUtils.hasText(model.getGroupId())) {
|
||||
return model.getGroupId();
|
||||
}
|
||||
if (model.getParent() != null
|
||||
&& StringUtils.hasText(model.getParent().getGroupId())) {
|
||||
return model.getParent().getGroupId();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public String bumpedVersion() {
|
||||
return bumpedVersion(assertVersion()).print();
|
||||
}
|
||||
@@ -192,17 +227,7 @@ public class ProjectVersion implements Comparable<ProjectVersion> {
|
||||
}
|
||||
|
||||
public String groupId() {
|
||||
if (this.model == null) {
|
||||
return "";
|
||||
}
|
||||
if (StringUtils.hasText(this.model.getGroupId())) {
|
||||
return this.model.getGroupId();
|
||||
}
|
||||
if (this.model.getParent() != null
|
||||
&& StringUtils.hasText(this.model.getParent().getGroupId())) {
|
||||
return this.model.getParent().getGroupId();
|
||||
}
|
||||
return "";
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
@@ -363,13 +388,6 @@ public class ProjectVersion implements Comparable<ProjectVersion> {
|
||||
assertIfValid();
|
||||
}
|
||||
|
||||
private void assertIfValid() {
|
||||
if (isInvalid()) {
|
||||
throw new IllegalStateException(
|
||||
"Version is invalid. Should be of format [1.2.3.A] / [1.2.3-A] or [A.B] / [A-B]");
|
||||
}
|
||||
}
|
||||
|
||||
// Hoxton.RELEASE
|
||||
// Hoxton-RELEASE
|
||||
private SplitVersion(String major, String delimiter, String suffix) {
|
||||
@@ -385,6 +403,39 @@ public class ProjectVersion implements Comparable<ProjectVersion> {
|
||||
assertIfValid();
|
||||
}
|
||||
|
||||
private static String orDefault(String[] args, int argIndex) {
|
||||
return args.length > argIndex ? args[argIndex] : "";
|
||||
}
|
||||
|
||||
static SplitVersion hyphen(String major, String suffix) {
|
||||
return new SplitVersion(major, HYPHEN, suffix);
|
||||
}
|
||||
|
||||
static SplitVersion hyphen(String[] args) {
|
||||
return version(args, HYPHEN);
|
||||
}
|
||||
|
||||
static SplitVersion dot(String[] args) {
|
||||
return version(args, DOT);
|
||||
}
|
||||
|
||||
private static SplitVersion version(String[] args, String delimiter) {
|
||||
if (args.length == 2) {
|
||||
return new SplitVersion(args[0], "", "", delimiter, args[1]);
|
||||
}
|
||||
else if (args.length == 3) {
|
||||
return new SplitVersion(args[0], args[1], "", delimiter, args[2]);
|
||||
}
|
||||
return new SplitVersion(args, delimiter);
|
||||
}
|
||||
|
||||
private void assertIfValid() {
|
||||
if (isInvalid()) {
|
||||
throw new IllegalStateException(
|
||||
"Version is invalid. Should be of format [1.2.3.A] / [1.2.3-A] or [A.B] / [A-B]");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInvalid() {
|
||||
return wrongReleaseTrainVersion() || wrongLibraryVersion() || wrongDelimiter()
|
||||
|| noSuffix();
|
||||
@@ -442,32 +493,6 @@ public class ProjectVersion implements Comparable<ProjectVersion> {
|
||||
BUILD_SNAPSHOT_SUFFIX);
|
||||
}
|
||||
|
||||
private static String orDefault(String[] args, int argIndex) {
|
||||
return args.length > argIndex ? args[argIndex] : "";
|
||||
}
|
||||
|
||||
static SplitVersion hyphen(String major, String suffix) {
|
||||
return new SplitVersion(major, HYPHEN, suffix);
|
||||
}
|
||||
|
||||
static SplitVersion hyphen(String[] args) {
|
||||
return version(args, HYPHEN);
|
||||
}
|
||||
|
||||
static SplitVersion dot(String[] args) {
|
||||
return version(args, DOT);
|
||||
}
|
||||
|
||||
private static SplitVersion version(String[] args, String delimiter) {
|
||||
if (args.length == 2) {
|
||||
return new SplitVersion(args[0], "", "", delimiter, args[1]);
|
||||
}
|
||||
else if (args.length == 3) {
|
||||
return new SplitVersion(args[0], args[1], "", delimiter, args[2]);
|
||||
}
|
||||
return new SplitVersion(args, delimiter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.internal.project;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
@@ -151,6 +151,11 @@ public class Projects extends HashSet<ProjectVersion> {
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
public Set<Project> asProjects() {
|
||||
return this.stream().map(projectVersion -> new Project(projectVersion.projectName,
|
||||
projectVersion.version)).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return stream().map(v -> "[" + v.projectName + "=>" + v.version + "]")
|
||||
@@ -28,7 +28,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.internal.tech;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
@@ -27,14 +27,22 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Class that reads poms as {@link Model}.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
class PomReader {
|
||||
public final class PomReader {
|
||||
|
||||
private PomReader() {
|
||||
throw new IllegalStateException("Shouldn't instantiate a utility class");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a parsed POM.
|
||||
* @param file location to the pom
|
||||
* @return parsed model
|
||||
*/
|
||||
Model readPom(File file) {
|
||||
public static Model readPom(File file) {
|
||||
File pom = file;
|
||||
if (file.isDirectory()) {
|
||||
pom = new File(file, "pom.xml");
|
||||
@@ -60,4 +68,15 @@ class PomReader {
|
||||
}
|
||||
}
|
||||
|
||||
public static Model pom(File projectRoot, String pom) {
|
||||
if (pom == null) {
|
||||
throw new IllegalStateException("Pom is not present");
|
||||
}
|
||||
File pomFile = new File(projectRoot, pom);
|
||||
if (!pomFile.exists()) {
|
||||
throw new IllegalStateException("Pom is not present");
|
||||
}
|
||||
return PomReader.readPom(pomFile);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,8 +27,8 @@ import com.google.common.collect.ImmutableMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.github.ProjectGitHubHandler;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
@@ -55,7 +55,7 @@ class BlogTemplateGenerator {
|
||||
private final NotesGenerator notesGenerator;
|
||||
|
||||
BlogTemplateGenerator(Template template, String releaseVersion, File blogOutput,
|
||||
Projects projects, ProjectGitHandler handler) {
|
||||
Projects projects, ProjectGitHubHandler handler) {
|
||||
this.template = template;
|
||||
this.releaseVersion = releaseVersion;
|
||||
this.blogOutput = blogOutput;
|
||||
|
||||
@@ -20,8 +20,8 @@ import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.github.ProjectGitHubHandler;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -29,9 +29,9 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
class NotesGenerator {
|
||||
|
||||
private final ProjectGitHandler handler;
|
||||
private final ProjectGitHubHandler handler;
|
||||
|
||||
NotesGenerator(ProjectGitHandler handler) {
|
||||
NotesGenerator(ProjectGitHubHandler handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,20 +25,15 @@ import java.util.Map;
|
||||
|
||||
import com.github.jknack.handlebars.Template;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.github.ProjectGitHubHandler;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
class ReleaseNotesTemplateGenerator {
|
||||
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(ReleaseNotesTemplateGenerator.class);
|
||||
|
||||
private final Template template;
|
||||
|
||||
private final String releaseVersion;
|
||||
@@ -50,7 +45,7 @@ class ReleaseNotesTemplateGenerator {
|
||||
private final NotesGenerator notesGenerator;
|
||||
|
||||
ReleaseNotesTemplateGenerator(Template template, String releaseVersion,
|
||||
File blogOutput, Projects projects, ProjectGitHandler handler) {
|
||||
File blogOutput, Projects projects, ProjectGitHubHandler handler) {
|
||||
this.template = template;
|
||||
this.releaseVersion = releaseVersion;
|
||||
this.blogOutput = blogOutput;
|
||||
|
||||
@@ -23,8 +23,8 @@ import com.github.jknack.handlebars.Template;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.ReleaserPropertiesAware;
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.github.ProjectGitHubHandler;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
import org.springframework.cloud.release.internal.tech.HandlebarsHelper;
|
||||
|
||||
/**
|
||||
@@ -48,11 +48,11 @@ public class TemplateGenerator implements ReleaserPropertiesAware {
|
||||
|
||||
private final File releaseNotesOutput;
|
||||
|
||||
private final ProjectGitHandler handler;
|
||||
private final ProjectGitHubHandler handler;
|
||||
|
||||
private ReleaserProperties props;
|
||||
|
||||
public TemplateGenerator(ReleaserProperties props, ProjectGitHandler handler) {
|
||||
public TemplateGenerator(ReleaserProperties props, ProjectGitHubHandler handler) {
|
||||
this.props = props;
|
||||
this.handler = handler;
|
||||
this.emailOutput = new File("target/email.txt");
|
||||
@@ -61,7 +61,8 @@ public class TemplateGenerator implements ReleaserPropertiesAware {
|
||||
this.releaseNotesOutput = new File("target/notes.md");
|
||||
}
|
||||
|
||||
TemplateGenerator(ReleaserProperties props, File output, ProjectGitHandler handler) {
|
||||
TemplateGenerator(ReleaserProperties props, File output,
|
||||
ProjectGitHubHandler handler) {
|
||||
this.props = props;
|
||||
this.emailOutput = output;
|
||||
this.blogOutput = output;
|
||||
|
||||
@@ -38,9 +38,9 @@ import org.springframework.boot.context.properties.bind.Binder;
|
||||
import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.ReleaserPropertiesAware;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.buildsystem.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -54,12 +54,12 @@ public class VersionsFetcher implements ReleaserPropertiesAware {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(VersionsFetcher.class);
|
||||
|
||||
private ReleaserProperties properties;
|
||||
|
||||
private final ProjectPomUpdater projectPomUpdater;
|
||||
|
||||
private final ToPropertiesConverter toPropertiesConverter;
|
||||
|
||||
private ReleaserProperties properties;
|
||||
|
||||
public VersionsFetcher(ReleaserProperties properties,
|
||||
ProjectPomUpdater projectPomUpdater) {
|
||||
this.properties = properties;
|
||||
|
||||
@@ -2,16 +2,17 @@ On behalf of the community, I am pleased to announce that the {{ availability }}
|
||||
|
||||
## Notable Changes in the {{ releaseName }} Release Train
|
||||
{{#each projects}}
|
||||
### {{ name }}
|
||||
### {{ name }}
|
||||
|
||||
Some text related to project
|
||||
Some text related to project
|
||||
{{/each}}
|
||||
|
||||
The following modules were updated as part of {{ releaseVersion }}:
|
||||
|
||||
| Module | Version | Issues
|
||||
|--- |--- |--- |---
|
||||
{{#each projects}}| {{name}} | {{version}} | {{#if closedMilestoneUrl}}([issues]({{{ closedMilestoneUrl }}})){{/if}}{{^closedMilestoneUrl}} {{/closedMilestoneUrl}}
|
||||
| Module | Version | Issues
|
||||
|--- |--- |--- |---
|
||||
{{#each projects}}| {{name}} | {{version}} | {{#if
|
||||
closedMilestoneUrl}}([issues]({{{ closedMilestoneUrl }}})){{/if}}{{^closedMilestoneUrl}} {{/closedMilestoneUrl}}
|
||||
{{/each}}
|
||||
|
||||
As always, we welcome feedback on [GitHub](https://github.com/spring-cloud/), on [Gitter](https://gitter.im/spring-cloud/spring-cloud), on [Stack Overflow](https://stackoverflow.com/questions/tagged/spring-cloud), or on [Twitter](https://twitter.com/SpringCloud).
|
||||
@@ -19,16 +20,17 @@ As always, we welcome feedback on [GitHub](https://github.com/spring-cloud/), on
|
||||
To get started with Maven with a BOM (dependency management only):
|
||||
|
||||
```
|
||||
{{#if nonRelease}}<repositories>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>{{/if}}
|
||||
{{#if nonRelease}}
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>{{/if}}
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@@ -57,28 +59,28 @@ or with Gradle:
|
||||
|
||||
```
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath "io.spring.gradle:dependency-management-plugin:1.0.2.RELEASE"
|
||||
}
|
||||
dependencies {
|
||||
classpath "io.spring.gradle:dependency-management-plugin:1.0.2.RELEASE"
|
||||
}
|
||||
}
|
||||
|
||||
{{#if nonRelease}}repositories {
|
||||
maven {
|
||||
url 'https://repo.spring.io/milestone'
|
||||
}
|
||||
maven {
|
||||
url 'https://repo.spring.io/milestone'
|
||||
}
|
||||
}{{/if}}
|
||||
|
||||
apply plugin: "io.spring.dependency-management"
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:{{ releaseVersion }}'
|
||||
}
|
||||
imports {
|
||||
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:{{ releaseVersion }}'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'org.springframework.cloud:spring-cloud-starter-config'
|
||||
compile 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
|
||||
...
|
||||
compile 'org.springframework.cloud:spring-cloud-starter-config'
|
||||
compile 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
@@ -5,15 +5,15 @@ title: Spring Cloud
|
||||
badges:
|
||||
|
||||
|
||||
# Customize your project's badges. Delete any entries that do not apply.
|
||||
custom:
|
||||
- name: Source (GitHub)
|
||||
url: https://github.com/spring-cloud
|
||||
icon: github
|
||||
# Customize your project's badges. Delete any entries that do not apply.
|
||||
custom:
|
||||
- name: Source (GitHub)
|
||||
url: https://github.com/spring-cloud
|
||||
icon: github
|
||||
|
||||
- name: StackOverflow
|
||||
url: https://stackoverflow.com/questions/tagged/spring-cloud
|
||||
icon: stackoverflow
|
||||
- name: StackOverflow
|
||||
url: https://stackoverflow.com/questions/tagged/spring-cloud
|
||||
icon: stackoverflow
|
||||
|
||||
|
||||
---
|
||||
@@ -42,7 +42,7 @@ Spring Cloud builds on Spring Boot by providing a bunch of libraries
|
||||
that enhance the behaviour of an application when added to the
|
||||
classpath. You can take advantage of the basic default behaviour to
|
||||
get started really quickly, and then when you need to, you can
|
||||
configure or extend to create a custom solution.
|
||||
configure or extend to create a custom solution.
|
||||
|
||||
<span id="quick-start"></span>
|
||||
|
||||
@@ -59,7 +59,8 @@ and eureka (change the artifact ids to pull in other starters):
|
||||
|
||||
## Features
|
||||
|
||||
Spring Cloud focuses on providing good out of box experience for typical use cases and extensibility mechanism to cover others.
|
||||
Spring Cloud focuses on providing good out of box experience for typical use cases and extensibility mechanism to cover
|
||||
others.
|
||||
|
||||
* Distributed/versioned configuration
|
||||
* Service registration and discovery
|
||||
@@ -79,9 +80,9 @@ annotation. Example application that is a discovery client:
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
public class Application {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -91,119 +92,160 @@ public class Application {
|
||||
|
||||
<!-- Spring Cloud Config -->
|
||||
{% capture project_description %}
|
||||
Centralized external configuration management backed by a git repository. The configuration resources map directly to Spring `Environment` but could be used by non-Spring applications if desired.
|
||||
Centralized external configuration management backed by a git repository. The configuration resources map directly to
|
||||
Spring `Environment` but could be used by non-Spring applications if desired.
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-config" repo_url="https://github.com/spring-cloud/spring-cloud-config" project_title="Spring Cloud Config" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-config"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-config" project_title="Spring Cloud Config"
|
||||
project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Netflix -->
|
||||
{% capture project_description %}
|
||||
Integration with various Netflix OSS components (Eureka, Hystrix, Zuul, Archaius, etc.).
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-netflix" repo_url="https://github.com/spring-cloud/spring-cloud-netflix" project_title="Spring Cloud Netflix" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-netflix"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-netflix" project_title="Spring Cloud Netflix"
|
||||
project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Bus -->
|
||||
{% capture project_description %}
|
||||
An event bus for linking services and service instances together with distributed messaging. Useful for propagating state changes across a cluster (e.g. config change events).
|
||||
An event bus for linking services and service instances together with distributed messaging. Useful for propagating
|
||||
state changes across a cluster (e.g. config change events).
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-bus" repo_url="https://github.com/spring-cloud/spring-cloud-bus" project_title="Spring Cloud Bus" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-bus"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-bus" project_title="Spring Cloud Bus"
|
||||
project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Cloudfoundry -->
|
||||
{% capture project_description %}
|
||||
Integrates your application with Pivotal Cloud Foundry. Provides a service discovery implementation and also makes it easy to implement SSO and OAuth2 protected resources.
|
||||
Integrates your application with Pivotal Cloud Foundry. Provides a service discovery implementation and also makes it
|
||||
easy to implement SSO and OAuth2 protected resources.
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-cloudfoundry" repo_url="https://github.com/spring-cloud/spring-cloud-cloudfoundry" project_title="Spring Cloud for Cloud Foundry" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-cloudfoundry"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-cloudfoundry" project_title="Spring Cloud for Cloud Foundry"
|
||||
project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Open Service Broker -->
|
||||
{% capture project_description %}
|
||||
Provides a starting point for building a service broker that implements the Open Service Broker API.
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-open-service-broker/" repo_url="https://github.com/spring-cloud/spring-cloud-open-service-broker" project_title="Spring Cloud Open Service Broker" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-open-service-broker/"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-open-service-broker" project_title="Spring Cloud Open Service
|
||||
Broker" project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Cluster -->
|
||||
{% capture project_description %}
|
||||
Leadership election and common stateful patterns with an abstraction and implementation for Zookeeper, Redis, Hazelcast, Consul.
|
||||
Leadership election and common stateful patterns with an abstraction and implementation for Zookeeper, Redis, Hazelcast,
|
||||
Consul.
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="/spring-cloud" repo_url="https://github.com/spring-cloud/spring-cloud-cluster" project_title="Spring Cloud Cluster" project_description=project_description %}
|
||||
{% include project_block.md site_url="/spring-cloud" repo_url="https://github.com/spring-cloud/spring-cloud-cluster"
|
||||
project_title="Spring Cloud Cluster" project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Consul -->
|
||||
{% capture project_description %}
|
||||
Service discovery and configuration management with Hashicorp Consul.
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-consul" repo_url="https://github.com/spring-cloud/spring-cloud-consul" project_title="Spring Cloud Consul" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-consul"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-consul" project_title="Spring Cloud Consul"
|
||||
project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Security -->
|
||||
{% capture project_description %}
|
||||
Provides support for load-balanced OAuth2 rest client and authentication header relays in a Zuul proxy.
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-security" repo_url="https://github.com/spring-cloud/spring-cloud-security" project_title="Spring Cloud Security" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-security"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-security" project_title="Spring Cloud Security"
|
||||
project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Sleuth -->
|
||||
{% capture project_description %}
|
||||
Distributed tracing for Spring Cloud applications, compatible with Zipkin, HTrace and log-based (e.g. ELK) tracing.
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-sleuth" repo_url="https://github.com/spring-cloud/spring-cloud-sleuth" project_title="Spring Cloud Sleuth" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-sleuth"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-sleuth" project_title="Spring Cloud Sleuth"
|
||||
project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Data Flow -->
|
||||
{% capture project_description %}
|
||||
A cloud-native orchestration service for composable microservice applications on modern runtimes. Easy-to-use DSL, drag-and-drop GUI, and REST-APIs together simplifies the overall orchestration of microservice based data pipelines.
|
||||
A cloud-native orchestration service for composable microservice applications on modern runtimes. Easy-to-use DSL,
|
||||
drag-and-drop GUI, and REST-APIs together simplifies the overall orchestration of microservice based data pipelines.
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-dataflow" repo_url="https://github.com/spring-cloud/spring-cloud-dataflow" project_title="Spring Cloud Data Flow" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-dataflow"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-dataflow" project_title="Spring Cloud Data Flow"
|
||||
project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Stream -->
|
||||
{% capture project_description %}
|
||||
A lightweight event-driven microservices framework to quickly build applications that can connect to external systems. Simple declarative model to send and receive messages using Apache Kafka or RabbitMQ between Spring Boot apps.
|
||||
A lightweight event-driven microservices framework to quickly build applications that can connect to external systems.
|
||||
Simple declarative model to send and receive messages using Apache Kafka or RabbitMQ between Spring Boot apps.
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-stream" repo_url="https://github.com/spring-cloud/spring-cloud-stream" project_title="Spring Cloud Stream" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-stream"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-stream" project_title="Spring Cloud Stream"
|
||||
project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Stream App Starters -->
|
||||
{% capture project_description %}
|
||||
Spring Cloud Stream App Starters are Spring Boot based Spring Integration applications that provide integration with external systems.
|
||||
Spring Cloud Stream App Starters are Spring Boot based Spring Integration applications that provide integration with
|
||||
external systems.
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-stream-app-starters" repo_url="https://github.com/spring-cloud/spring-cloud-stream-app-starters" project_title="Spring Cloud Stream App Starters" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-stream-app-starters"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-stream-app-starters" project_title="Spring Cloud Stream App
|
||||
Starters" project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Task -->
|
||||
{% capture project_description %}
|
||||
A short-lived microservices framework to quickly build applications that perform finite amounts of data processing. Simple declarative for adding both functional and non-functional features to Spring Boot apps.
|
||||
A short-lived microservices framework to quickly build applications that perform finite amounts of data processing.
|
||||
Simple declarative for adding both functional and non-functional features to Spring Boot apps.
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-task" repo_url="https://github.com/spring-cloud/spring-cloud-task" project_title="Spring Cloud Task" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-task"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-task" project_title="Spring Cloud Task"
|
||||
project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Task App Starters -->
|
||||
{% capture project_description %}
|
||||
Spring Cloud Task App Starters are Spring Boot applications that may be any process including Spring Batch jobs that do not run forever, and they end/stop after a finite period of data processing.
|
||||
Spring Cloud Task App Starters are Spring Boot applications that may be any process including Spring Batch jobs that do
|
||||
not run forever, and they end/stop after a finite period of data processing.
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-task-app-starters" repo_url="https://github.com/spring-cloud/spring-cloud-task-app-starters" project_title="Spring Cloud Task App Starters" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-task-app-starters"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-task-app-starters" project_title="Spring Cloud Task App Starters"
|
||||
project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Zookeeper -->
|
||||
{% capture project_description %}
|
||||
Service discovery and configuration management with Apache Zookeeper.
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-zookeeper" repo_url="https://github.com/spring-cloud/spring-cloud-zookeeper" project_title="Spring Cloud Zookeeper" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-zookeeper"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-zookeeper" project_title="Spring Cloud Zookeeper"
|
||||
project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud AWS -->
|
||||
{% capture project_description %}
|
||||
Easy integration with hosted Amazon Web Services. It offers a convenient way to interact with AWS provided services using well-known Spring idioms and APIs, such as the messaging or caching API. Developers can build their application around the hosted services without having to care about infrastructure or maintenance.
|
||||
Easy integration with hosted Amazon Web Services. It offers a convenient way to interact with AWS provided services
|
||||
using well-known Spring idioms and APIs, such as the messaging or caching API. Developers can build their application
|
||||
around the hosted services without having to care about infrastructure or maintenance.
|
||||
{% endcapture %}
|
||||
|
||||
{% capture site_url %}
|
||||
{{ site.projects_site_url }}/spring-cloud-aws
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url=site_url repo_url="https://github.com/spring-cloud/spring-cloud-aws" project_title="Spring Cloud for Amazon Web Services" project_description=project_description %}
|
||||
{% include project_block.md site_url=site_url repo_url="https://github.com/spring-cloud/spring-cloud-aws"
|
||||
project_title="Spring Cloud for Amazon Web Services" project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Connectors -->
|
||||
{% capture project_description %}
|
||||
@@ -215,57 +257,77 @@ databases and message brokers (the project formerly known as "Spring Cloud").
|
||||
{{ site.projects_site_url }}/spring-cloud-connectors
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url=site_url repo_url="https://github.com/spring-cloud/spring-cloud-connectors" project_title="Spring Cloud Connectors" project_description=project_description %}
|
||||
{% include project_block.md site_url=site_url repo_url="https://github.com/spring-cloud/spring-cloud-connectors"
|
||||
project_title="Spring Cloud Connectors" project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Starters -->
|
||||
{% capture project_description %}
|
||||
Spring Boot-style starter projects to ease dependency management for consumers of Spring Cloud. (Discontinued as a project and merged with the other projects after Angel.SR2.)
|
||||
Spring Boot-style starter projects to ease dependency management for consumers of Spring Cloud. (Discontinued as a
|
||||
project and merged with the other projects after Angel.SR2.)
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://github.com/spring-cloud/spring-cloud-starters" repo_url="https://github.com/spring-cloud/spring-cloud-starters" project_title="Spring Cloud Starters" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://github.com/spring-cloud/spring-cloud-starters"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-starters" project_title="Spring Cloud Starters"
|
||||
project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud CLI -->
|
||||
{% capture project_description %}
|
||||
Spring Boot CLI plugin for creating Spring Cloud component applications quickly in Groovy
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://github.com/spring-cloud/spring-cloud-cli" repo_url="https://github.com/spring-cloud/spring-cloud-cli" project_title="Spring Cloud CLI" project_description=project_description %}
|
||||
|
||||
{% include project_block.md site_url="https://github.com/spring-cloud/spring-cloud-cli"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-cli" project_title="Spring Cloud CLI"
|
||||
project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Contract -->
|
||||
{% capture project_description %}
|
||||
Spring Cloud Contract is an umbrella project holding solutions that help users in successfully implementing the Consumer Driven Contracts approach.
|
||||
Spring Cloud Contract is an umbrella project holding solutions that help users in successfully implementing the Consumer
|
||||
Driven Contracts approach.
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-contract" repo_url="https://github.com/spring-cloud/spring-cloud-contract" project_title="Spring Cloud Contract" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-contract"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-contract" project_title="Spring Cloud Contract"
|
||||
project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Gateway -->
|
||||
{% capture project_description %}
|
||||
Spring Cloud Gateway is an intelligent and programmable router based on Project Reactor.
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-gateway" repo_url="https://github.com/spring-cloud/spring-cloud-gateway" project_title="Spring Cloud Gateway" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-gateway"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-gateway" project_title="Spring Cloud Gateway"
|
||||
project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud OpenFeign -->
|
||||
{% capture project_description %}
|
||||
Spring Cloud OpenFeign provides integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms.
|
||||
Spring Cloud OpenFeign provides integrations for Spring Boot apps through autoconfiguration and binding to the Spring
|
||||
Environment and other Spring programming model idioms.
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-openfeign" repo_url="https://github.com/spring-cloud/spring-cloud-openfeign" project_title="Spring Cloud OpenFeign" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-openfeign"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-openfeign" project_title="Spring Cloud OpenFeign"
|
||||
project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Pipelines -->
|
||||
{% capture project_description %}
|
||||
Spring Cloud Pipelines provides an opinionated deployment pipeline with steps to ensure that your application can be deployed in zero downtime fashion and easilly rolled back of something goes wrong.
|
||||
Spring Cloud Pipelines provides an opinionated deployment pipeline with steps to ensure that your application can be
|
||||
deployed in zero downtime fashion and easilly rolled back of something goes wrong.
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-pipelines" repo_url="https://github.com/spring-cloud/spring-cloud-pipelines" project_title="Spring Cloud Pipelines" project_description=project_description %}
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-pipelines"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-pipelines" project_title="Spring Cloud Pipelines"
|
||||
project_description=project_description %}
|
||||
|
||||
<!-- Spring Cloud Function -->
|
||||
{% capture project_description %}
|
||||
Spring Cloud Function promotes the implementation of business logic via functions. It supports a uniform programming model across serverless providers, as well as the ability to run standalone (locally or in a PaaS).
|
||||
Spring Cloud Function promotes the implementation of business logic via functions. It supports a uniform programming
|
||||
model across serverless providers, as well as the ability to run standalone (locally or in a PaaS).
|
||||
{% endcapture %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-function" repo_url="https://github.com/spring-cloud/spring-cloud-function" project_title="Spring Cloud Function" project_description=project_description %}
|
||||
|
||||
{% include project_block.md site_url="https://cloud.spring.io/spring-cloud-function"
|
||||
repo_url="https://github.com/spring-cloud/spring-cloud-function" project_title="Spring Cloud Function"
|
||||
project_description=project_description %}
|
||||
|
||||
## Release Trains
|
||||
|
||||
Spring Cloud is an umbrella project consisting of independent projects with, in principle, different
|
||||
@@ -273,7 +335,7 @@ release cadences. To manage the portfolio a BOM (Bill of Materials) is published
|
||||
set of dependencies on the individual project (see below). The release trains have names, not
|
||||
versions, to avoid confusion with the sub-projects. The names are an alphabetic sequence (so
|
||||
you can sort them chronologically) with names of London Tube stations ("Angel" is the first
|
||||
release, "Brixton" is the second). When point releases of the individual projects accumulate to
|
||||
release, "Brixton" is the second). When point releases of the individual projects accumulate to
|
||||
a critical mass, or if there is a critical bug in one of them that needs to be available to everyone,
|
||||
the release train will push out "service releases" with names ending ".SRX", where "X"
|
||||
is a number.
|
||||
@@ -282,7 +344,7 @@ Release train contents:
|
||||
|
||||
<!-- BEGIN COMPONENTS -->
|
||||
|
||||
|Component |{{lastGaTrainName}}|{{currentGaTrainName}}|{{currentSnapshotTrainName}}|
|
||||
|Component |{{lastGaTrainName}}|{{currentGaTrainName}}|{{currentSnapshotTrainName}}|
|
||||
|--------------------------------------|-----------------|---------------------|------------------------|
|
||||
{{#each projects}} |{{componentName}}|{{lastGaVersion}}|{{currentGaVersion}}|{{currentSnapshotVersion}}|
|
||||
{{/each}}
|
||||
@@ -292,22 +354,26 @@ Release train contents:
|
||||
Finchley builds and works with Spring Boot 2.0.x, and is not expected
|
||||
to work with Spring Boot 1.5.x.
|
||||
|
||||
Note: The Dalston release train will [reach end-of-life](https://spring.io/blog/2018/06/19/spring-cloud-finchley-release-is-available) in December 2018. Edgware will follow the end-of-life cycle of Spring Boot 1.5.x.
|
||||
|
||||
Note: The Dalston release train will [reach
|
||||
end-of-life](https://spring.io/blog/2018/06/19/spring-cloud-finchley-release-is-available) in December 2018. Edgware
|
||||
will follow the end-of-life cycle of Spring Boot 1.5.x.
|
||||
|
||||
The Dalston and Edgware release trains build on Spring Boot 1.5.x, and
|
||||
are not expected to work with Spring Boot 2.0.x.
|
||||
|
||||
NOTE: The Camden release train was [marked end-of-life](https://spring.io/blog/2018/06/19/spring-cloud-finchley-release-is-available).
|
||||
|
||||
NOTE: The Camden release train was [marked
|
||||
end-of-life](https://spring.io/blog/2018/06/19/spring-cloud-finchley-release-is-available).
|
||||
|
||||
The Camden release train builds on Spring Boot 1.4.x, but is also
|
||||
tested with 1.5.x.
|
||||
|
||||
NOTE: The Brixton and Angel release trains were [marked end-of-life](https://spring.io/blog/2017/07/21/spring-cloud-dalston-sr2-is-available-now#end-of-life-for-angel-and-brixton-release-trains)
|
||||
NOTE: The Brixton and Angel release trains were [marked
|
||||
end-of-life](https://spring.io/blog/2017/07/21/spring-cloud-dalston-sr2-is-available-now#end-of-life-for-angel-and-brixton-release-trains)
|
||||
(EOL) in July 2017.
|
||||
|
||||
The Brixton release train builds on Spring Boot 1.3.x, but is also
|
||||
tested with 1.4.x.
|
||||
|
||||
|
||||
The Angel release train builds on Spring Boot 1.2.x, and is
|
||||
incompatible in some areas with Spring Boot 1.3.x. Brixton builds on
|
||||
Spring Boot 1.3.x and is similarly incompatible with 1.2.x. Some
|
||||
@@ -335,8 +401,9 @@ Spring dependency management plugin.
|
||||
> Spring Cloud. The opposite is not true: using the Cloud parent
|
||||
> makes it impossible, or at least unreliable, to also use the
|
||||
> Boot BOM to change the version of Spring Boot and its dependencies.
|
||||
|
||||
> NOTE: If you find anything wrong or outdated on this page, please open an issue in [this](https://github.com/spring-projects/spring-cloud) repo.
|
||||
|
||||
> NOTE: If you find anything wrong or outdated on this page, please open an issue in
|
||||
[this](https://github.com/spring-projects/spring-cloud) repo.
|
||||
|
||||
{% endcapture %}
|
||||
|
||||
|
||||
@@ -14,21 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.cloud.buildsystem;
|
||||
|
||||
import java.io.File;
|
||||
import org.springframework.cloud.release.internal.buildsystem.CustomBomParser;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
public class SpringCloudMavenBomParserAccessor {
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class TestPomReader {
|
||||
|
||||
PomReader pomReader = new PomReader();
|
||||
|
||||
public Model readPom(File pom) {
|
||||
return this.pomReader.readPom(pom);
|
||||
public static CustomBomParser cloud() {
|
||||
return new SpringCloudMavenBomParser();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,13 +14,16 @@
|
||||
* 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;
|
||||
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;
|
||||
@@ -29,9 +32,12 @@ import org.junit.rules.TemporaryFolder;
|
||||
import org.mockito.BDDMockito;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.buildsystem.TestUtils;
|
||||
import org.springframework.cloud.release.internal.docs.DocumentationUpdater;
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.TestUtils;
|
||||
import org.springframework.cloud.release.internal.github.ProjectGitHubHandler;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.template.TemplateGenerator;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
@@ -39,7 +45,7 @@ import static org.assertj.core.api.BDDAssertions.then;
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class ProjectDocumentationUpdaterTests {
|
||||
public class SpringCloudCustomProjectDocumentationUpdaterTests {
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder tmp = new TemporaryFolder();
|
||||
@@ -50,6 +56,8 @@ public class ProjectDocumentationUpdaterTests {
|
||||
|
||||
ProjectGitHandler handler;
|
||||
|
||||
ProjectGitHubHandler gitHubHandler;
|
||||
|
||||
File clonedDocProject;
|
||||
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
@@ -57,7 +65,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);
|
||||
@@ -65,6 +73,7 @@ public class ProjectDocumentationUpdaterTests {
|
||||
file("/projects/spring-cloud-static/").toURI().toString());
|
||||
this.handler = new ProjectGitHandler(this.properties);
|
||||
this.clonedDocProject = this.handler.cloneDocumentationProject();
|
||||
this.gitHubHandler = new ProjectGitHubHandler(this.properties);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,9 +87,8 @@ public class ProjectDocumentationUpdaterTests {
|
||||
file("/projects/spring-cloud-release/").toURI().toString());
|
||||
|
||||
BDDAssertions
|
||||
.thenThrownBy(() -> new ProjectDocumentationUpdater(properties,
|
||||
new ProjectGitHandler(properties))
|
||||
.updateDocsRepo(releaseTrainVersion, "vAngel.SR33"))
|
||||
.thenThrownBy(() -> projectDocumentationUpdaterWithNoIndexHtml(properties)
|
||||
.updateDocsRepo(releaseTrainVersion, "vAngel.SR33"))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("index.html is not present");
|
||||
}
|
||||
@@ -94,13 +102,19 @@ public class ProjectDocumentationUpdaterTests {
|
||||
properties.getGit().setDocumentationUrl(
|
||||
file("/projects/spring-cloud-static/").toURI().toString());
|
||||
|
||||
BDDAssertions.thenThrownBy(() -> new ProjectDocumentationUpdater(properties,
|
||||
SpringCloudCustomProjectDocumentationUpdater customUpdater = new SpringCloudCustomProjectDocumentationUpdater(
|
||||
new ProjectGitHandler(properties)) {
|
||||
@Override
|
||||
String readIndexHtmlContents(File indexHtml) {
|
||||
return "";
|
||||
}
|
||||
}.updateDocsRepo(releaseTrainVersion, "vAngel.SR33"))
|
||||
};
|
||||
|
||||
BDDAssertions
|
||||
.thenThrownBy(() -> new DocumentationUpdater(this.handler, properties,
|
||||
templateGenerator(properties),
|
||||
Collections.singletonList(customUpdater))
|
||||
.updateDocsRepo(releaseTrainVersion, "vAngel.SR33"))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("The URL to the documentation repo not found");
|
||||
}
|
||||
@@ -111,13 +125,52 @@ 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 = projectDocumentationUpdater(properties)
|
||||
.updateDocsRepo(releaseTrainVersion, "vAngel.M7");
|
||||
|
||||
then(updatedDocs).isNull();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private DocumentationUpdater projectDocumentationUpdater(
|
||||
ReleaserProperties properties) {
|
||||
return new DocumentationUpdater(this.handler, properties,
|
||||
templateGenerator(properties), Collections.singletonList(
|
||||
new SpringCloudCustomProjectDocumentationUpdater(this.handler) {
|
||||
@Override
|
||||
boolean isNewerOrEqualReleaseTrain(String storedReleaseTrain,
|
||||
String firstLetterOfReleaseTrain,
|
||||
String currentReleaseTrainVersion,
|
||||
String firstLetterOfCurrentReleaseTrain) {
|
||||
return true;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private DocumentationUpdater projectDocumentationUpdaterWithNoIndexHtml(
|
||||
ReleaserProperties properties) {
|
||||
return new DocumentationUpdater(this.handler, properties,
|
||||
templateGenerator(properties), Collections.singletonList(
|
||||
new SpringCloudCustomProjectDocumentationUpdater(this.handler) {
|
||||
@Override
|
||||
File indexHtml(File clonedDocumentationProject,
|
||||
String pathToIndexHtml) {
|
||||
return new File("non/existent/file");
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private TemplateGenerator templateGenerator(ReleaserProperties properties) {
|
||||
return new TemplateGenerator(properties, this.gitHubHandler);
|
||||
}
|
||||
|
||||
@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 {
|
||||
@@ -127,9 +180,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(
|
||||
new ProjectGitHandler(properties)).updateDocsRepo(this.clonedDocProject,
|
||||
releaseTrainVersion, "vAngel.SR33");
|
||||
|
||||
String indexHtmlContent = new String(
|
||||
Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath()));
|
||||
@@ -145,8 +198,8 @@ 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(handler).updateDocsRepo(
|
||||
this.clonedDocProject, releaseTrainVersion, "vDalston.SR3");
|
||||
|
||||
BDDMockito.then(handler).should(BDDMockito.never())
|
||||
.commit(BDDMockito.any(File.class), BDDMockito.anyString());
|
||||
@@ -160,9 +213,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(
|
||||
new ProjectGitHandler(properties)).updateDocsRepo(this.clonedDocProject,
|
||||
releaseTrainVersion, "Angel.SR33");
|
||||
|
||||
String indexHtmlContent = new String(
|
||||
Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath()));
|
||||
@@ -178,9 +231,8 @@ 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 = projectDocumentationUpdater(properties)
|
||||
.updateDocsRepo(releaseTrainVersion, "vFinchley.SR33");
|
||||
|
||||
String indexHtmlContent = new String(
|
||||
Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath()));
|
||||
@@ -196,9 +248,8 @@ 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 = projectDocumentationUpdater(properties)
|
||||
.updateDocsRepo(releaseTrainVersion, "Finchley.SR33");
|
||||
|
||||
String indexHtmlContent = new String(
|
||||
Files.readAllBytes(new File(updatedDocs, "current/index.html").toPath()));
|
||||
@@ -214,16 +265,15 @@ 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 = projectDocumentationUpdater(properties)
|
||||
.updateDocsRepo(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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
@@ -28,11 +29,12 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import org.springframework.cloud.release.internal.pom.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.pom.TestPomReader;
|
||||
import org.springframework.cloud.release.internal.pom.TestUtils;
|
||||
import org.springframework.cloud.release.internal.buildsystem.MavenBomParserAccessor;
|
||||
import org.springframework.cloud.release.internal.buildsystem.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.buildsystem.TestUtils;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
import org.springframework.cloud.release.internal.tech.PomReader;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
@@ -45,8 +47,6 @@ public class PomUpdateAcceptanceTests {
|
||||
@Rule
|
||||
public TemporaryFolder tmp = new TemporaryFolder();
|
||||
|
||||
TestPomReader testPomReader = new TestPomReader();
|
||||
|
||||
File temporaryFolder;
|
||||
|
||||
@Before
|
||||
@@ -60,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);
|
||||
ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties,
|
||||
Collections.singletonList(
|
||||
MavenBomParserAccessor.cloudMavenBomParser(releaserProperties)));
|
||||
Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom();
|
||||
File project = new File(this.temporaryFolder, "/spring-cloud-sleuth");
|
||||
|
||||
@@ -68,13 +70,12 @@ public class PomUpdateAcceptanceTests {
|
||||
projects.forFile(project), true);
|
||||
|
||||
then(this.temporaryFolder).exists();
|
||||
Model rootPom = this.testPomReader
|
||||
.readPom(tmpFile("/spring-cloud-sleuth/pom.xml"));
|
||||
Model depsPom = this.testPomReader.readPom(
|
||||
Model rootPom = PomReader.readPom(tmpFile("/spring-cloud-sleuth/pom.xml"));
|
||||
Model depsPom = PomReader.readPom(
|
||||
tmpFile("/spring-cloud-sleuth/spring-cloud-sleuth-dependencies/pom.xml"));
|
||||
Model corePom = this.testPomReader.readPom(
|
||||
Model corePom = PomReader.readPom(
|
||||
tmpFile("/spring-cloud-sleuth/spring-cloud-sleuth-core/pom.xml"));
|
||||
Model zipkinStreamPom = this.testPomReader.readPom(tmpFile(
|
||||
Model zipkinStreamPom = PomReader.readPom(tmpFile(
|
||||
"/spring-cloud-sleuth/spring-cloud-sleuth-samples/spring-cloud-sleuth-sample-zipkin-stream/pom.xml"));
|
||||
then(rootPom.getVersion()).isEqualTo("1.2.0.BUILD-SNAPSHOT");
|
||||
then(rootPom.getProperties())
|
||||
@@ -93,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);
|
||||
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,
|
||||
@@ -115,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);
|
||||
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");
|
||||
@@ -131,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);
|
||||
ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties,
|
||||
Collections.singletonList(
|
||||
MavenBomParserAccessor.cloudMavenBomParser(releaserProperties)));
|
||||
Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom();
|
||||
projects.removeIf(projectVersion -> projectVersion.projectName
|
||||
.contains("spring-cloud-build"));
|
||||
@@ -147,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);
|
||||
ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties,
|
||||
Collections.singletonList(
|
||||
MavenBomParserAccessor.cloudMavenBomParser(releaserProperties)));
|
||||
File beforeProcessing = pom("/projects/project/");
|
||||
Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom();
|
||||
File project = tmpFile("/project/");
|
||||
|
||||
@@ -31,14 +31,15 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.boot.test.rule.OutputCapture;
|
||||
import org.springframework.cloud.release.internal.buildsystem.GradleUpdater;
|
||||
import org.springframework.cloud.release.internal.buildsystem.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.docs.DocumentationUpdater;
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.cloud.release.internal.gradle.GradleUpdater;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.post.PostReleaseActions;
|
||||
import org.springframework.cloud.release.internal.project.ProjectBuilder;
|
||||
import org.springframework.cloud.release.internal.github.ProjectGitHubHandler;
|
||||
import org.springframework.cloud.release.internal.postrelease.PostReleaseActions;
|
||||
import org.springframework.cloud.release.internal.project.ProjectCommandExecutor;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
import org.springframework.cloud.release.internal.sagan.SaganUpdater;
|
||||
import org.springframework.cloud.release.internal.template.TemplateGenerator;
|
||||
|
||||
@@ -59,11 +60,14 @@ public class ReleaserTests {
|
||||
ProjectPomUpdater projectPomUpdater;
|
||||
|
||||
@Mock
|
||||
ProjectBuilder projectBuilder;
|
||||
ProjectCommandExecutor projectCommandExecutor;
|
||||
|
||||
@Mock
|
||||
ProjectGitHandler projectGitHandler;
|
||||
|
||||
@Mock
|
||||
ProjectGitHubHandler projectGitHubHandler;
|
||||
|
||||
@Mock
|
||||
TemplateGenerator templateGenerator;
|
||||
|
||||
@@ -89,9 +93,9 @@ public class ReleaserTests {
|
||||
|
||||
Releaser releaser(Supplier<ProjectVersion> originalVersionSupplier) {
|
||||
return new Releaser(new ReleaserProperties(), this.projectPomUpdater,
|
||||
this.projectBuilder, this.projectGitHandler, this.templateGenerator,
|
||||
this.gradleUpdater, this.saganUpdater, this.documentationUpdater,
|
||||
this.postReleaseActions) {
|
||||
this.projectCommandExecutor, this.projectGitHandler,
|
||||
this.projectGitHubHandler, this.templateGenerator, this.gradleUpdater,
|
||||
this.saganUpdater, this.documentationUpdater, this.postReleaseActions) {
|
||||
@Override
|
||||
ProjectVersion originalVersion(File project) {
|
||||
return originalVersionSupplier.get();
|
||||
@@ -101,9 +105,9 @@ public class ReleaserTests {
|
||||
|
||||
Releaser releaser() {
|
||||
return new Releaser(new ReleaserProperties(), this.projectPomUpdater,
|
||||
this.projectBuilder, this.projectGitHandler, this.templateGenerator,
|
||||
this.gradleUpdater, this.saganUpdater, this.documentationUpdater,
|
||||
this.postReleaseActions);
|
||||
this.projectCommandExecutor, this.projectGitHandler,
|
||||
this.projectGitHubHandler, this.templateGenerator, this.gradleUpdater,
|
||||
this.saganUpdater, this.documentationUpdater, this.postReleaseActions);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -173,7 +177,7 @@ public class ReleaserTests {
|
||||
public void should_not_close_milestone_for_snapshots() {
|
||||
releaser().closeMilestone(new ProjectVersion("original", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
then(this.projectGitHandler).should(never())
|
||||
then(this.projectGitHubHandler).should(never())
|
||||
.closeMilestone(any(ProjectVersion.class));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* 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.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
|
||||
class GradleBomParserTests {
|
||||
|
||||
@Test
|
||||
void should_read_versions_from_bom_from_properties() {
|
||||
GradleBomParser parser = new GradleBomParser(new ReleaserProperties(),
|
||||
new ArrayList<>()) {
|
||||
@Override
|
||||
public boolean isApplicable(File clonedBom) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
File file(File clonedBom, String child) {
|
||||
return clonedBom;
|
||||
}
|
||||
|
||||
@Override
|
||||
Properties loadProps(File file) {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("springCloudContractVersion", "1.0.0.RELEASE");
|
||||
return properties;
|
||||
}
|
||||
};
|
||||
|
||||
VersionsFromBom versionsFromBom = parser.versionsFromBom(new File("."));
|
||||
|
||||
BDDAssertions.then(versionsFromBom.versionForProject("spring-cloud-contract"))
|
||||
.isEqualTo("1.0.0.RELEASE");
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_a_version_from_bom_with_substitution() {
|
||||
Map<String, String> gradleSubstitution = new HashMap<>();
|
||||
gradleSubstitution.put("verifierVersion", "spring-cloud-contract");
|
||||
ReleaserProperties releaserProperties = new ReleaserProperties();
|
||||
releaserProperties.getGradle().setGradlePropsSubstitution(gradleSubstitution);
|
||||
GradleBomParser parser = new GradleBomParser(releaserProperties,
|
||||
new ArrayList<>()) {
|
||||
@Override
|
||||
public boolean isApplicable(File clonedBom) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
File file(File clonedBom, String child) {
|
||||
return clonedBom;
|
||||
}
|
||||
|
||||
@Override
|
||||
Properties loadProps(File file) {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("verifierVersion", "1.0.0.RELEASE");
|
||||
return properties;
|
||||
}
|
||||
};
|
||||
|
||||
VersionsFromBom versionsFromBom = parser.versionsFromBom(new File("."));
|
||||
|
||||
BDDAssertions.then(versionsFromBom.versionForProject("spring-cloud-contract"))
|
||||
.isEqualTo("1.0.0.RELEASE");
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_be_not_applicable_when_no_build_gradle_is_present() {
|
||||
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<>()) {
|
||||
@Override
|
||||
File file(File clonedBom, String child) {
|
||||
return clonedBom;
|
||||
}
|
||||
};
|
||||
|
||||
BDDAssertions.then(parser.isApplicable(new File("."))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_empty_version_when_no_gradle_properties_is_present() {
|
||||
GradleBomParser parser = new GradleBomParser(new ReleaserProperties(),
|
||||
new ArrayList<>());
|
||||
|
||||
VersionsFromBom versionsFromBom = parser.versionsFromBom(new File("."));
|
||||
|
||||
BDDAssertions.then(versionsFromBom).isSameAs(VersionsFromBom.EMPTY_VERSION);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.internal.buildsystem;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.util.Collections;
|
||||
|
||||
import org.springframework.cloud.release.cloud.buildsystem.SpringCloudMavenBomParserAccessor;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
|
||||
public class MavenBomParserAccessor {
|
||||
|
||||
public static BomParser cloudMavenBomParser(ReleaserProperties properties) {
|
||||
return new MavenBomParser(properties,
|
||||
Collections.singletonList(SpringCloudMavenBomParserAccessor.cloud()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.internal.buildsystem;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
@@ -24,6 +24,7 @@ import org.junit.Test;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.git.GitRepoTests;
|
||||
import org.springframework.cloud.release.internal.project.Project;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
import static org.assertj.core.api.BDDAssertions.thenThrownBy;
|
||||
@@ -31,7 +32,7 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy;
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class BomParserTests {
|
||||
public class MavenBomParserTests {
|
||||
|
||||
File springCloudReleaseProject;
|
||||
|
||||
@@ -45,9 +46,11 @@ public class BomParserTests {
|
||||
|
||||
@Test
|
||||
public void should_throw_exception_when_boot_pom_is_missing() {
|
||||
BomParser parser = new BomParser(this.properties, new File("."));
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
File file = new File(".");
|
||||
|
||||
thenThrownBy(parser::bootVersion).isInstanceOf(IllegalStateException.class)
|
||||
thenThrownBy(() -> parser.versionsFromBom(file))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("Pom is not present");
|
||||
}
|
||||
|
||||
@@ -55,28 +58,28 @@ public class BomParserTests {
|
||||
public void should_throw_exception_when_null_is_passed_to_boot() {
|
||||
this.properties.getPom().setPomWithBootStarterParent(null);
|
||||
this.properties.getPom().setThisTrainBom(null);
|
||||
BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject);
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
|
||||
thenThrownBy(parser::bootVersion).isInstanceOf(IllegalStateException.class)
|
||||
thenThrownBy(() -> parser.versionsFromBom(this.springCloudReleaseProject))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("Pom is not present");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_throw_exception_when_boot_version_is_missing_in_pom() {
|
||||
this.properties.getPom().setPomWithBootStarterParent("pom.xml");
|
||||
this.properties.getPom().setThisTrainBom(null);
|
||||
BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject);
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
|
||||
thenThrownBy(parser::bootVersion).isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining(
|
||||
thenThrownBy(() -> parser.versionsFromBom(this.springCloudReleaseProject))
|
||||
.isInstanceOf(IllegalStateException.class).hasMessageContaining(
|
||||
"The pom doesn't have a [spring-boot-starter-parent] artifact id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_populate_sc_release_version() {
|
||||
BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject);
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
|
||||
String scReleaseVersion = parser.allVersions()
|
||||
String scReleaseVersion = parser.versionsFromBom(this.springCloudReleaseProject)
|
||||
.versionForProject("spring-cloud-release");
|
||||
|
||||
then(scReleaseVersion).isEqualTo("Dalston.BUILD-SNAPSHOT");
|
||||
@@ -84,18 +87,20 @@ public class BomParserTests {
|
||||
|
||||
@Test
|
||||
public void should_populate_boot_version() {
|
||||
BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject);
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
|
||||
String bootVersion = parser.bootVersion().bootVersion;
|
||||
String bootVersion = parser.versionsFromBom(this.springCloudReleaseProject)
|
||||
.versionForProject("spring-boot");
|
||||
|
||||
then(bootVersion).isEqualTo("1.5.1.BUILD-SNAPSHOT");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_throw_exception_when_cloud_pom_is_missing() {
|
||||
BomParser parser = new BomParser(this.properties, new File("."));
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
|
||||
thenThrownBy(parser::versionsFromBom).isInstanceOf(IllegalStateException.class)
|
||||
thenThrownBy(() -> parser.versionsFromBom(new File(".")))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("Pom is not present");
|
||||
}
|
||||
|
||||
@@ -103,42 +108,48 @@ public class BomParserTests {
|
||||
public void should_throw_exception_when_null_is_passed_to_cloud() {
|
||||
this.properties.getPom().setPomWithBootStarterParent(null);
|
||||
this.properties.getPom().setThisTrainBom(null);
|
||||
BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject);
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
|
||||
thenThrownBy(parser::versionsFromBom).isInstanceOf(IllegalStateException.class)
|
||||
thenThrownBy(() -> parser.versionsFromBom(this.springCloudReleaseProject))
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining("Pom is not present");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_throw_exception_when_cloud_version_is_missing_in_pom() {
|
||||
this.properties.getPom().setPomWithBootStarterParent(null);
|
||||
this.properties.getPom().setPomWithBootStarterParent("pom.xml");
|
||||
this.properties.getPom().setThisTrainBom("pom.xml");
|
||||
BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject);
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
|
||||
thenThrownBy(parser::versionsFromBom).isInstanceOf(IllegalStateException.class)
|
||||
.hasMessageContaining(
|
||||
thenThrownBy(() -> parser.versionsFromBom(this.springCloudReleaseProject))
|
||||
.isInstanceOf(IllegalStateException.class).hasMessageContaining(
|
||||
"The pom doesn't have a [spring-cloud-dependencies-parent] artifact id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_populate_cloud_version() {
|
||||
BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject);
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
|
||||
Versions cloudVersions = parser.versionsFromBom();
|
||||
VersionsFromBom cloudVersionsFromBom = parser
|
||||
.versionsFromBom(this.springCloudReleaseProject);
|
||||
|
||||
then(cloudVersions.scBuildVersion).isEqualTo("1.3.1.BUILD-SNAPSHOT");
|
||||
then(cloudVersions.projects).contains(allProjects());
|
||||
then(cloudVersionsFromBom.versionForProject("spring-cloud-build"))
|
||||
.isEqualTo("1.3.1.BUILD-SNAPSHOT");
|
||||
then(cloudVersionsFromBom.projects).contains(allProjects());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_populate_boot_and_cloud_version() {
|
||||
BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject);
|
||||
BomParser parser = MavenBomParserAccessor.cloudMavenBomParser(this.properties);
|
||||
|
||||
Versions cloudVersions = parser.allVersions();
|
||||
VersionsFromBom cloudVersionsFromBom = parser
|
||||
.versionsFromBom(this.springCloudReleaseProject);
|
||||
|
||||
then(cloudVersions.bootVersion).isEqualTo("1.5.1.BUILD-SNAPSHOT");
|
||||
then(cloudVersions.scBuildVersion).isEqualTo("1.3.1.BUILD-SNAPSHOT");
|
||||
then(cloudVersions.projects).contains(allProjects());
|
||||
then(cloudVersionsFromBom.versionForProject("spring-boot"))
|
||||
.isEqualTo("1.5.1.BUILD-SNAPSHOT");
|
||||
then(cloudVersionsFromBom.versionForProject("spring-cloud-build"))
|
||||
.isEqualTo("1.3.1.BUILD-SNAPSHOT");
|
||||
then(cloudVersionsFromBom.projects).contains(allProjects());
|
||||
}
|
||||
|
||||
private Project[] allProjects() {
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.internal.buildsystem;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.File;
|
||||
@@ -27,6 +27,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.cloud.release.internal.git.GitRepoTests;
|
||||
import org.springframework.cloud.release.internal.tech.PomReader;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
import static org.assertj.core.api.BDDAssertions.thenThrownBy;
|
||||
@@ -36,8 +37,6 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy;
|
||||
*/
|
||||
public class PomReaderTests {
|
||||
|
||||
PomReader pomReader = new PomReader();
|
||||
|
||||
File springCloudReleaseProjectPom;
|
||||
|
||||
File springCloudReleaseProject;
|
||||
@@ -59,7 +58,7 @@ public class PomReaderTests {
|
||||
|
||||
@Test
|
||||
public void should_parse_a_valid_pom() {
|
||||
Model pom = this.pomReader.readPom(this.springCloudReleaseProjectPom);
|
||||
Model pom = PomReader.readPom(this.springCloudReleaseProjectPom);
|
||||
|
||||
then(pom).isNotNull();
|
||||
then(pom.getArtifactId()).isEqualTo("spring-cloud-starter-build");
|
||||
@@ -67,7 +66,7 @@ public class PomReaderTests {
|
||||
|
||||
@Test
|
||||
public void should_parse_a_valid_pom_when_passing_direcory() {
|
||||
Model pom = this.pomReader.readPom(this.springCloudReleaseProject);
|
||||
Model pom = PomReader.readPom(this.springCloudReleaseProject);
|
||||
|
||||
then(pom).isNotNull();
|
||||
then(pom.getArtifactId()).isEqualTo("spring-cloud-starter-build");
|
||||
@@ -75,20 +74,20 @@ public class PomReaderTests {
|
||||
|
||||
@Test
|
||||
public void should_return_null_when_file_is_missing() {
|
||||
then(this.pomReader.readPom(new File("foo/bar"))).isNull();
|
||||
then(PomReader.readPom(new File("foo/bar"))).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_throw_exception_when_file_is_invalid() {
|
||||
thenThrownBy(() -> this.pomReader.readPom(this.licenseFile))
|
||||
thenThrownBy(() -> PomReader.readPom(this.licenseFile))
|
||||
.hasMessageStartingWith("Failed to read file: ")
|
||||
.hasCauseInstanceOf(XmlPullParserException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_throw_exception_when_file_is_empty() {
|
||||
thenThrownBy(() -> this.pomReader.readPom(this.empty))
|
||||
.hasMessageStartingWith("File [").hasMessageContaining("] is empty")
|
||||
thenThrownBy(() -> PomReader.readPom(this.empty)).hasMessageStartingWith("File [")
|
||||
.hasMessageContaining("] is empty")
|
||||
.hasCauseInstanceOf(EOFException.class);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.internal.buildsystem;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -31,7 +31,10 @@ import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import org.springframework.boot.test.rule.OutputCapture;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.git.GitRepoTests;
|
||||
import org.springframework.cloud.release.internal.project.Project;
|
||||
import org.springframework.cloud.release.internal.tech.PomReader;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
/**
|
||||
@@ -45,12 +48,14 @@ public class PomUpdaterTests {
|
||||
@Rule
|
||||
public TemporaryFolder tmp = new TemporaryFolder();
|
||||
|
||||
Versions versions = new Versions("0.0.1", "0.0.2", projects());
|
||||
VersionsFromBom versionsFromBom = new VersionsFromBomBuilder()
|
||||
.releaserProperties(new ReleaserProperties()).projects(projects())
|
||||
.parsers(MavenBomParserAccessor.cloudMavenBomParser(new ReleaserProperties())
|
||||
.customBomParsers())
|
||||
.retrieveFromBom();
|
||||
|
||||
PomUpdater pomUpdater = new PomUpdater();
|
||||
|
||||
PomReader pomReader = new PomReader();
|
||||
|
||||
File temporaryFolder;
|
||||
|
||||
@Before
|
||||
@@ -65,7 +70,7 @@ public class PomUpdaterTests {
|
||||
File springCloudReleasePom = file("/projects/spring-cloud-release");
|
||||
|
||||
BDDAssertions.then(this.pomUpdater.shouldProjectBeUpdated(springCloudReleasePom,
|
||||
this.versions)).isFalse();
|
||||
this.versionsFromBom)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -73,8 +78,8 @@ public class PomUpdaterTests {
|
||||
throws Exception {
|
||||
File springCloud = pom("/projects/project", "pom_with_parent_suffix.xml");
|
||||
|
||||
BDDAssertions
|
||||
.then(this.pomUpdater.shouldProjectBeUpdated(springCloud, this.versions))
|
||||
BDDAssertions.then(
|
||||
this.pomUpdater.shouldProjectBeUpdated(springCloud, this.versionsFromBom))
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
@@ -84,8 +89,8 @@ public class PomUpdaterTests {
|
||||
File springCloud = pom("/projects/project",
|
||||
"pom_matching_with_parent_suffix.xml");
|
||||
|
||||
BDDAssertions
|
||||
.then(this.pomUpdater.shouldProjectBeUpdated(springCloud, this.versions))
|
||||
BDDAssertions.then(
|
||||
this.pomUpdater.shouldProjectBeUpdated(springCloud, this.versionsFromBom))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@@ -95,7 +100,7 @@ public class PomUpdaterTests {
|
||||
File springCloudSleuthPom = file("/projects/spring-cloud-sleuth");
|
||||
|
||||
BDDAssertions.then(this.pomUpdater.shouldProjectBeUpdated(springCloudSleuthPom,
|
||||
this.versions)).isTrue();
|
||||
this.versionsFromBom)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -104,7 +109,7 @@ public class PomUpdaterTests {
|
||||
File springCloudSleuthPom = file("/projects/spring-cloud-sleuth/empty-folder");
|
||||
|
||||
BDDAssertions.then(this.pomUpdater.shouldProjectBeUpdated(springCloudSleuthPom,
|
||||
this.versions)).isFalse();
|
||||
this.versionsFromBom)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,9 +118,9 @@ public class PomUpdaterTests {
|
||||
File pomInTemp = tmpFile("/project/pom.xml");
|
||||
ModelWrapper rootPom = model("foo");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp,
|
||||
this.versions);
|
||||
this.versionsFromBom);
|
||||
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions,
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versionsFromBom,
|
||||
pomInTemp);
|
||||
|
||||
BDDAssertions.then(asString(storedPom)).isEqualTo(asString(originalPom));
|
||||
@@ -128,13 +133,13 @@ public class PomUpdaterTests {
|
||||
File pomInTemp = tmpFile("/project/pom_matching_artifact.xml");
|
||||
ModelWrapper rootPom = model("spring-cloud-sleuth");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp,
|
||||
this.versions);
|
||||
this.versionsFromBom);
|
||||
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions,
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versionsFromBom,
|
||||
pomInTemp);
|
||||
|
||||
BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom));
|
||||
Model overriddenPomModel = this.pomReader.readPom(storedPom);
|
||||
Model overriddenPomModel = PomReader.readPom(storedPom);
|
||||
BDDAssertions.then(overriddenPomModel.getVersion())
|
||||
.isEqualTo("0.0.3.BUILD-SNAPSHOT");
|
||||
}
|
||||
@@ -146,13 +151,13 @@ public class PomUpdaterTests {
|
||||
File pomInTemp = tmpFile("/project/pom_matching_parent_v2.xml");
|
||||
ModelWrapper rootPom = model("spring-cloud-sleuth");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp,
|
||||
this.versions);
|
||||
this.versionsFromBom);
|
||||
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions,
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versionsFromBom,
|
||||
pomInTemp);
|
||||
|
||||
BDDAssertions.then(asString(originalPom)).isNotEqualTo(asString(storedPom));
|
||||
Model overriddenPomModel = this.pomReader.readPom(storedPom);
|
||||
Model overriddenPomModel = PomReader.readPom(storedPom);
|
||||
BDDAssertions.then(overriddenPomModel.getVersion())
|
||||
.isEqualTo("0.0.3.BUILD-SNAPSHOT");
|
||||
BDDAssertions.then(overriddenPomModel.getParent().getVersion())
|
||||
@@ -166,13 +171,13 @@ public class PomUpdaterTests {
|
||||
File pomInTemp = tmpFile("/project/pom_matching_parent.xml");
|
||||
ModelWrapper rootPom = model("spring-cloud-sleuth");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp,
|
||||
this.versions);
|
||||
this.versionsFromBom);
|
||||
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions,
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versionsFromBom,
|
||||
pomInTemp);
|
||||
|
||||
BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom));
|
||||
Model overriddenPomModel = this.pomReader.readPom(storedPom);
|
||||
Model overriddenPomModel = PomReader.readPom(storedPom);
|
||||
BDDAssertions.then(overriddenPomModel.getVersion())
|
||||
.isEqualTo("0.0.3.BUILD-SNAPSHOT");
|
||||
BDDAssertions.then(overriddenPomModel.getParent().getVersion())
|
||||
@@ -185,7 +190,7 @@ public class PomUpdaterTests {
|
||||
File springCloudReleasePom = file("/projects/spring-cloud-release");
|
||||
|
||||
BDDAssertions.then(this.pomUpdater.shouldProjectBeUpdated(springCloudReleasePom,
|
||||
this.versions)).isFalse();
|
||||
this.versionsFromBom)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -194,7 +199,7 @@ public class PomUpdaterTests {
|
||||
File springCloudSleuthPom = file("/projects/spring-cloud-sleuth");
|
||||
|
||||
BDDAssertions.then(this.pomUpdater.shouldProjectBeUpdated(springCloudSleuthPom,
|
||||
this.versions)).isTrue();
|
||||
this.versionsFromBom)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -205,13 +210,13 @@ public class PomUpdaterTests {
|
||||
File pomInTemp = tmpFile("/project/children/pom_matching_parent_v2.xml");
|
||||
ModelWrapper rootPom = model("spring-cloud-sleuth");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp,
|
||||
this.versions);
|
||||
this.versionsFromBom);
|
||||
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions,
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versionsFromBom,
|
||||
pomInTemp);
|
||||
|
||||
BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom));
|
||||
Model overriddenPomModel = this.pomReader.readPom(storedPom);
|
||||
Model overriddenPomModel = PomReader.readPom(storedPom);
|
||||
BDDAssertions.then(overriddenPomModel.getVersion())
|
||||
.isEqualTo("0.0.3.BUILD-SNAPSHOT");
|
||||
BDDAssertions.then(overriddenPomModel.getParent().getVersion())
|
||||
@@ -230,13 +235,13 @@ public class PomUpdaterTests {
|
||||
File pomInTemp = tmpFile("/project/children/pom_different_group_boot_parent.xml");
|
||||
ModelWrapper rootPom = model("spring-cloud-sleuth", "org.springframework.cloud");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp,
|
||||
this.versions);
|
||||
this.versionsFromBom);
|
||||
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions,
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versionsFromBom,
|
||||
pomInTemp);
|
||||
|
||||
BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom));
|
||||
Model overriddenPomModel = this.pomReader.readPom(storedPom);
|
||||
Model overriddenPomModel = PomReader.readPom(storedPom);
|
||||
BDDAssertions.then(overriddenPomModel.getVersion())
|
||||
.isEqualTo("0.0.3.BUILD-SNAPSHOT");
|
||||
BDDAssertions.then(overriddenPomModel.getParent().getVersion())
|
||||
@@ -252,13 +257,13 @@ public class PomUpdaterTests {
|
||||
File pomInTemp = tmpFile("/project/children/pom_different_group.xml");
|
||||
ModelWrapper rootPom = model("spring-cloud-sleuth", "org.springframework.cloud");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp,
|
||||
this.versions);
|
||||
this.versionsFromBom);
|
||||
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions,
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versionsFromBom,
|
||||
pomInTemp);
|
||||
|
||||
BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom));
|
||||
Model overriddenPomModel = this.pomReader.readPom(storedPom);
|
||||
Model overriddenPomModel = PomReader.readPom(storedPom);
|
||||
BDDAssertions.then(overriddenPomModel.getVersion())
|
||||
.isEqualTo("1.2.2.BUILD-SNAPSHOT");
|
||||
BDDAssertions.then(overriddenPomModel.getParent().getVersion())
|
||||
@@ -277,13 +282,13 @@ public class PomUpdaterTests {
|
||||
"/project/children/pom_different_group_skip_deployment_prop.xml");
|
||||
ModelWrapper rootPom = model("spring-cloud-sleuth", "org.springframework.cloud");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp,
|
||||
this.versions);
|
||||
this.versionsFromBom);
|
||||
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions,
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versionsFromBom,
|
||||
pomInTemp);
|
||||
|
||||
BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom));
|
||||
Model overriddenPomModel = this.pomReader.readPom(storedPom);
|
||||
Model overriddenPomModel = PomReader.readPom(storedPom);
|
||||
BDDAssertions.then(overriddenPomModel.getVersion())
|
||||
.isEqualTo("1.2.2.BUILD-SNAPSHOT");
|
||||
BDDAssertions.then(overriddenPomModel.getParent().getVersion())
|
||||
@@ -302,13 +307,13 @@ public class PomUpdaterTests {
|
||||
"/project/children/pom_different_group_skip_deployment_plugin.xml");
|
||||
ModelWrapper rootPom = model("spring-cloud-sleuth", "org.springframework.cloud");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp,
|
||||
this.versions);
|
||||
this.versionsFromBom);
|
||||
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions,
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versionsFromBom,
|
||||
pomInTemp);
|
||||
|
||||
BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom));
|
||||
Model overriddenPomModel = this.pomReader.readPom(storedPom);
|
||||
Model overriddenPomModel = PomReader.readPom(storedPom);
|
||||
BDDAssertions.then(overriddenPomModel.getVersion())
|
||||
.isEqualTo("1.2.2.BUILD-SNAPSHOT");
|
||||
BDDAssertions.then(overriddenPomModel.getParent().getVersion())
|
||||
@@ -327,13 +332,13 @@ public class PomUpdaterTests {
|
||||
"/project/children/pom_different_group_skip_deployment_plugin_mngmnt.xml");
|
||||
ModelWrapper rootPom = model("spring-cloud-sleuth", "org.springframework.cloud");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp,
|
||||
this.versions);
|
||||
this.versionsFromBom);
|
||||
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions,
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versionsFromBom,
|
||||
pomInTemp);
|
||||
|
||||
BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom));
|
||||
Model overriddenPomModel = this.pomReader.readPom(storedPom);
|
||||
Model overriddenPomModel = PomReader.readPom(storedPom);
|
||||
BDDAssertions.then(overriddenPomModel.getVersion())
|
||||
.isEqualTo("1.2.2.BUILD-SNAPSHOT");
|
||||
BDDAssertions.then(overriddenPomModel.getParent().getVersion())
|
||||
@@ -352,13 +357,13 @@ public class PomUpdaterTests {
|
||||
ModelWrapper rootPom = model("spring-cloud-contract",
|
||||
"org.springframework.cloud");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp,
|
||||
this.versions);
|
||||
this.versionsFromBom);
|
||||
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions,
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versionsFromBom,
|
||||
pomInTemp);
|
||||
|
||||
BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom));
|
||||
Model overriddenPomModel = this.pomReader.readPom(storedPom);
|
||||
Model overriddenPomModel = PomReader.readPom(storedPom);
|
||||
BDDAssertions.then(overriddenPomModel.getParent().getVersion())
|
||||
.isEqualTo("0.0.1");
|
||||
|
||||
@@ -371,13 +376,13 @@ public class PomUpdaterTests {
|
||||
File pomInTemp = tmpFile("/project/children/pom_matching_parent.xml");
|
||||
ModelWrapper rootPom = model("spring-cloud-sleuth");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp,
|
||||
this.versions);
|
||||
this.versionsFromBom);
|
||||
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions,
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versionsFromBom,
|
||||
pomInTemp);
|
||||
|
||||
BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom));
|
||||
Model overriddenPomModel = this.pomReader.readPom(storedPom);
|
||||
Model overriddenPomModel = PomReader.readPom(storedPom);
|
||||
BDDAssertions.then(overriddenPomModel.getVersion())
|
||||
.isEqualTo("0.0.3.BUILD-SNAPSHOT");
|
||||
BDDAssertions.then(overriddenPomModel.getParent().getVersion())
|
||||
@@ -395,13 +400,13 @@ public class PomUpdaterTests {
|
||||
File pomInTemp = tmpFile("/project/children/pom_matching_properties.xml");
|
||||
ModelWrapper rootPom = model("spring-cloud-sleuth");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp,
|
||||
this.versions);
|
||||
this.versionsFromBom);
|
||||
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions,
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versionsFromBom,
|
||||
pomInTemp);
|
||||
|
||||
BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom));
|
||||
Model overriddenPomModel = this.pomReader.readPom(storedPom);
|
||||
Model overriddenPomModel = PomReader.readPom(storedPom);
|
||||
BDDAssertions.then(overriddenPomModel.getVersion())
|
||||
.isEqualTo("0.0.3.BUILD-SNAPSHOT");
|
||||
BDDAssertions.then(overriddenPomModel.getParent().getVersion())
|
||||
@@ -418,10 +423,10 @@ public class PomUpdaterTests {
|
||||
"pom_matching_properties.xml");
|
||||
File afterProcessing = tmpFile("/project/children/pom_matching_properties.xml");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(model("spring-cloud-sleuth"),
|
||||
afterProcessing, this.versions);
|
||||
afterProcessing, this.versionsFromBom);
|
||||
|
||||
File processedPom = this.pomUpdater.overwritePomIfDirty(model,
|
||||
Versions.EMPTY_VERSION, afterProcessing);
|
||||
VersionsFromBom.EMPTY_VERSION, afterProcessing);
|
||||
|
||||
String processedPomText = asString(processedPom);
|
||||
String beforeProcessingText = asString(beforeProcessing);
|
||||
@@ -434,10 +439,10 @@ public class PomUpdaterTests {
|
||||
File beforeProcessing = pom("/projects/project/");
|
||||
File afterProcessing = tmpFile("/project/pom.xml");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(model("foo"), afterProcessing,
|
||||
this.versions);
|
||||
this.versionsFromBom);
|
||||
|
||||
File processedPom = this.pomUpdater.overwritePomIfDirty(model,
|
||||
Versions.EMPTY_VERSION, afterProcessing);
|
||||
VersionsFromBom.EMPTY_VERSION, afterProcessing);
|
||||
|
||||
BDDAssertions.then(asString(processedPom)).isEqualTo(asString(beforeProcessing));
|
||||
}
|
||||
@@ -449,13 +454,13 @@ public class PomUpdaterTests {
|
||||
File pomInTemp = tmpFile("/spring-cloud-contract/pom.xml");
|
||||
ModelWrapper rootPom = model("spring-cloud-contract-parent");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp,
|
||||
this.versions);
|
||||
this.versionsFromBom);
|
||||
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions,
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versionsFromBom,
|
||||
pomInTemp);
|
||||
|
||||
BDDAssertions.then(asString(storedPom)).isNotEqualTo(asString(originalPom));
|
||||
Model overriddenPomModel = this.pomReader.readPom(storedPom);
|
||||
Model overriddenPomModel = PomReader.readPom(storedPom);
|
||||
BDDAssertions.then(overriddenPomModel.getVersion())
|
||||
.isEqualTo("0.0.2.BUILD-SNAPSHOT");
|
||||
BDDAssertions.then(overriddenPomModel.getParent().getVersion())
|
||||
@@ -470,9 +475,9 @@ public class PomUpdaterTests {
|
||||
File pomInTemp = tmpFile("/project/pom_matching_artifact_same_version.xml");
|
||||
ModelWrapper rootPom = model("spring-cloud-sleuth");
|
||||
ModelWrapper model = this.pomUpdater.updateModel(rootPom, pomInTemp,
|
||||
this.versions);
|
||||
this.versionsFromBom);
|
||||
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versions,
|
||||
File storedPom = this.pomUpdater.overwritePomIfDirty(model, this.versionsFromBom,
|
||||
pomInTemp);
|
||||
|
||||
BDDAssertions.then(asString(storedPom)).isEqualTo(asString(originalPom));
|
||||
@@ -480,6 +485,8 @@ public class PomUpdaterTests {
|
||||
|
||||
Set<Project> projects() {
|
||||
Set<Project> projects = new HashSet<>();
|
||||
projects.add(new Project("spring-boot", "0.0.1"));
|
||||
projects.add(new Project("spring-cloud-build", "0.0.2"));
|
||||
projects.add(new Project("spring-cloud-contract", "0.0.2.BUILD-SNAPSHOT"));
|
||||
projects.add(new Project("spring-cloud-sleuth", "0.0.3.BUILD-SNAPSHOT"));
|
||||
projects.add(new Project("spring-cloud-vault", "0.0.4.BUILD-SNAPSHOT"));
|
||||
@@ -14,9 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.internal.buildsystem;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -26,6 +27,8 @@ import org.mockito.BDDMockito;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
@@ -64,7 +67,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);
|
||||
ProjectPomUpdater updater = new ProjectPomUpdater(properties, Collections
|
||||
.singletonList(MavenBomParserAccessor.cloudMavenBomParser(properties)));
|
||||
|
||||
Map<String, String> fixedVersions = updater.fixedVersions().stream()
|
||||
.collect(Collectors.toMap(projectVersion -> projectVersion.projectName,
|
||||
@@ -74,7 +78,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");
|
||||
}
|
||||
@@ -83,7 +88,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, handler);
|
||||
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);
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.internal.buildsystem;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
@@ -26,6 +26,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.cloud.release.internal.git.GitRepoTests;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
import static org.assertj.core.api.BDDAssertions.thenThrownBy;
|
||||
@@ -49,14 +50,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");
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.internal.buildsystem;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
@@ -25,6 +25,8 @@ import java.util.Set;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
import static org.assertj.core.api.BDDAssertions.thenThrownBy;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.internal.buildsystem;
|
||||
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader;
|
||||
@@ -25,6 +25,8 @@ import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.cloud.release.internal.project.Project;
|
||||
|
||||
import static org.mockito.BDDMockito.then;
|
||||
|
||||
/**
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.internal.buildsystem;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Properties;
|
||||
@@ -27,6 +27,9 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.project.Project;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.never;
|
||||
@@ -75,8 +78,9 @@ public class PropertyVersionChangerTests {
|
||||
.setPropertyVersionIfApplicable(any(Project.class));
|
||||
}
|
||||
|
||||
Versions versions() {
|
||||
return new Versions("", "", allProjects());
|
||||
VersionsFromBom versions() {
|
||||
return new VersionsFromBomBuilder().releaserProperties(new ReleaserProperties())
|
||||
.projects(allProjects()).retrieveFromBom();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.internal.buildsystem;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.pom;
|
||||
package org.springframework.cloud.release.internal.buildsystem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -0,0 +1,301 @@
|
||||
/*
|
||||
* 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.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.cloud.release.cloud.buildsystem.SpringCloudMavenBomParserAccessor;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.project.Project;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class VersionsFromBomTests {
|
||||
|
||||
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())
|
||||
.parsers(Collections
|
||||
.singletonList(SpringCloudMavenBomParserAccessor.cloud()))
|
||||
.retrieveFromBom();
|
||||
versionsFromBom.setVersion("spring-boot", "1.2.3.RELEASE");
|
||||
|
||||
then(versionsFromBom.projects).contains(
|
||||
new Project("spring-boot", "1.2.3.RELEASE"),
|
||||
new Project("spring-boot-starter-parent", "1.2.3.RELEASE"),
|
||||
new Project("spring-boot-dependencies", "1.2.3.RELEASE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_true_when_project_is_on_the_list() {
|
||||
then(this.versionsFromBom.shouldBeUpdated("foo")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_true_when_project_has_a_parent_suffix_and_project_is_on_the_list() {
|
||||
then(this.versionsFromBom.shouldBeUpdated("foo-parent")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_true_when_project_has_a_dependencies_suffix_and_project_is_on_the_list() {
|
||||
then(this.versionsFromBom.shouldBeUpdated("foo-dependencies")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_false_when_project_is_not_on_the_list() {
|
||||
then(this.versionsFromBom.shouldBeUpdated("missing")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_version_for_present_project() {
|
||||
then(this.versionsFromBom.versionForProject("foo")).isEqualTo("bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_empty_string_for_missing_project() {
|
||||
then(this.versionsFromBom.versionForProject("missing")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_true_if_properties_contains_project_key() {
|
||||
then(this.versionsFromBom.shouldSetProperty(validProps())).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_false_if_properties_does_not_contain_project_key() {
|
||||
then(this.versionsFromBom.shouldSetProperty(missingProps())).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_update_projects_for_boot() {
|
||||
VersionsFromBom versionsFromBom = mixedVersions().setVersion("spring-boot",
|
||||
"3.0.0");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-boot")).isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-boot-starter-parent"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-boot-dependencies"))
|
||||
.isEqualTo("3.0.0");
|
||||
|
||||
versionsFromBom = mixedVersions().setVersion("spring-boot-starter-parent",
|
||||
"3.0.0");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-boot")).isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-boot-starter-parent"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-boot-dependencies"))
|
||||
.isEqualTo("3.0.0");
|
||||
|
||||
versionsFromBom = mixedVersions().setVersion("spring-boot-dependencies", "3.0.0");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-boot")).isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-boot-starter-parent"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-boot-dependencies"))
|
||||
.isEqualTo("3.0.0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_update_projects_for_build() {
|
||||
VersionsFromBom versionsFromBom = mixedVersions().setVersion("spring-cloud-build",
|
||||
"3.0.0");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-cloud-build")).isEqualTo("3.0.0");
|
||||
|
||||
versionsFromBom = mixedVersions().setVersion("spring-cloud-build", "3.0.0");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies-parent"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("Greenwich.RELEASE");
|
||||
|
||||
versionsFromBom = mixedVersions().setVersion("spring-cloud-dependencies-parent",
|
||||
"3.0.0");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-cloud-build")).isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies-parent"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("Greenwich.RELEASE");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_update_projects_for_spring_cloud_release() {
|
||||
VersionsFromBom versionsFromBom = mixedVersions().setVersion("spring-cloud",
|
||||
"3.0.0");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-cloud")).isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-release"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-starter"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("3.0.0");
|
||||
|
||||
versionsFromBom = mixedVersions().setVersion("spring-cloud-release", "3.0.0");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-cloud")).isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-release"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-starter"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("3.0.0");
|
||||
|
||||
versionsFromBom = mixedVersions().setVersion("spring-cloud-release",
|
||||
"Greenwich.SR8");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-cloud"))
|
||||
.isEqualTo("Greenwich.SR8");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-release"))
|
||||
.isEqualTo("Greenwich.SR8");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-starter"))
|
||||
.isEqualTo("Greenwich.SR8");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("Greenwich.SR8");
|
||||
|
||||
versionsFromBom = mixedVersions().setVersion("spring-cloud-dependencies",
|
||||
"Greenwich.SR8");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-cloud"))
|
||||
.isEqualTo("Greenwich.SR8");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-release"))
|
||||
.isEqualTo("Greenwich.SR8");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-starter"))
|
||||
.isEqualTo("Greenwich.SR8");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("Greenwich.SR8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_update_projects_for_custom_bom_only() {
|
||||
VersionsFromBom versionsFromBom = mixedVersions(customBom())
|
||||
.setVersion("spring-cloud", "3.0.0");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-cloud")).isEqualTo("3.0.0");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-stream-starters"))
|
||||
.isEqualTo("Fishtown.RELEASE");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-starter")).isEmpty();
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("Greenwich.RELEASE");
|
||||
|
||||
versionsFromBom = mixedVersions(customBom())
|
||||
.setVersion("spring-cloud-stream-starters", "Fishtown.SR4");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-cloud")).isEmpty();
|
||||
then(versionsFromBom.versionForProject("spring-cloud-stream-starters"))
|
||||
.isEqualTo("Fishtown.SR4");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-starter")).isEmpty();
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("Greenwich.RELEASE");
|
||||
|
||||
versionsFromBom = mixedVersions(customBom()).setVersion("spring-cloud-release",
|
||||
"Greenwich.SR8");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-cloud-release"))
|
||||
.isEqualTo("Greenwich.SR8");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-stream-starters"))
|
||||
.isEqualTo("Fishtown.RELEASE");
|
||||
then(versionsFromBom.versionForProject("spring-cloud")).isEmpty();
|
||||
then(versionsFromBom.versionForProject("spring-cloud-starter")).isEmpty();
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("Greenwich.RELEASE");
|
||||
|
||||
versionsFromBom = mixedVersions(customBom())
|
||||
.setVersion("spring-cloud-dependencies", "Greenwich.SR8");
|
||||
|
||||
then(versionsFromBom.versionForProject("spring-cloud")).isEmpty();
|
||||
then(versionsFromBom.versionForProject("spring-cloud-stream-starters"))
|
||||
.isEqualTo("Fishtown.RELEASE");
|
||||
then(versionsFromBom.versionForProject("spring-cloud-starter")).isEmpty();
|
||||
then(versionsFromBom.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("Greenwich.SR8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_update_projects_for_custom_project() {
|
||||
VersionsFromBom versionsFromBom = mixedVersions().setVersion("foo", "3.0.0");
|
||||
|
||||
then(versionsFromBom.versionForProject("foo")).isEqualTo("3.0.0");
|
||||
}
|
||||
|
||||
private VersionsFromBom mixedVersions() {
|
||||
return new VersionsFromBomBuilder().releaserProperties(new ReleaserProperties())
|
||||
.parsers(Collections
|
||||
.singletonList(SpringCloudMavenBomParserAccessor.cloud()))
|
||||
.projects(mixedProjects()).merged();
|
||||
}
|
||||
|
||||
private VersionsFromBom mixedVersions(ReleaserProperties properties) {
|
||||
return new VersionsFromBomBuilder().releaserProperties(properties)
|
||||
.projects(mixedProjects()).retrieveFromBom();
|
||||
}
|
||||
|
||||
private ReleaserProperties customBom() {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMetaRelease()
|
||||
.setReleaseTrainDependencyNames(Collections.emptyList());
|
||||
properties.getMetaRelease()
|
||||
.setReleaseTrainProjectName("spring-cloud-stream-starters");
|
||||
properties.getPom().setThisTrainBom("spring-cloud-stream-dependencies");
|
||||
return properties;
|
||||
}
|
||||
|
||||
Set<Project> projects() {
|
||||
Set<Project> projects = new HashSet<>();
|
||||
projects.add(new Project("foo", "bar"));
|
||||
return projects;
|
||||
}
|
||||
|
||||
Set<Project> mixedProjects() {
|
||||
Set<Project> projects = new HashSet<>();
|
||||
projects.add(new Project("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
projects.add(new Project("fooBar", "1.0.0.RELEASE"));
|
||||
projects.add(new Project("spring-boot", "1.0.0"));
|
||||
projects.add(new Project("spring-cloud-build", "2.0.0"));
|
||||
projects.add(new Project("spring-cloud-release", "Greenwich.RELEASE"));
|
||||
projects.add(new Project("spring-cloud-dependencies", "Greenwich.RELEASE"));
|
||||
projects.add(new Project("spring-cloud-stream-starters", "Fishtown.RELEASE"));
|
||||
return projects;
|
||||
}
|
||||
|
||||
Properties validProps() {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("foo.version", "1.0.0");
|
||||
return properties;
|
||||
}
|
||||
|
||||
Properties missingProps() {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("missing.version", "1.0.0");
|
||||
return properties;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,8 +23,8 @@ import org.assertj.core.api.BDDAssertions;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
|
||||
@@ -29,11 +29,12 @@ import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.buildsystem.TestUtils;
|
||||
import org.springframework.cloud.release.internal.git.GitTestUtils;
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.pom.TestUtils;
|
||||
import org.springframework.cloud.release.internal.github.ProjectGitHubHandler;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
import org.springframework.cloud.release.internal.template.TemplateGenerator;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
@@ -47,15 +48,18 @@ public class ReleaseTrainContentsUpdaterTests {
|
||||
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
|
||||
ProjectGitHandler projectGitHandler = new ProjectGitHandler(this.properties) {
|
||||
ProjectGitHubHandler projectGitHubHandler = new ProjectGitHubHandler(
|
||||
this.properties) {
|
||||
@Override
|
||||
public String milestoneUrl(ProjectVersion releaseVersion) {
|
||||
return "http://www.foo.com/";
|
||||
}
|
||||
};
|
||||
|
||||
ProjectGitHandler projectGitHandler = new ProjectGitHandler(this.properties);
|
||||
|
||||
TemplateGenerator templateGenerator = new TemplateGenerator(this.properties,
|
||||
this.projectGitHandler);
|
||||
this.projectGitHubHandler);
|
||||
|
||||
ReleaseTrainContentsUpdater updater = new ReleaseTrainContentsUpdater(this.properties,
|
||||
this.projectGitHandler, this.templateGenerator);
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.util.List;
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import org.springframework.cloud.release.internal.pom.TestUtils;
|
||||
import org.springframework.cloud.release.internal.buildsystem.TestUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.git;
|
||||
package org.springframework.cloud.release.internal.github;
|
||||
|
||||
import com.jcabi.github.Coordinates;
|
||||
import com.jcabi.github.Github;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.git;
|
||||
package org.springframework.cloud.release.internal.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
@@ -33,8 +33,8 @@ import org.mockito.BDDMockito;
|
||||
|
||||
import org.springframework.boot.test.rule.OutputCapture;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
import static org.assertj.core.api.BDDAssertions.thenThrownBy;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.git;
|
||||
package org.springframework.cloud.release.internal.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
@@ -30,7 +30,7 @@ import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import org.springframework.boot.test.rule.OutputCapture;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
import static org.assertj.core.api.BDDAssertions.thenThrownBy;
|
||||
@@ -29,8 +29,9 @@ import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.buildsystem.GradleUpdater;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
@@ -1,265 +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
|
||||
*
|
||||
* 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.pom;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class VersionsTests {
|
||||
|
||||
Versions versions = new Versions("", projects());
|
||||
|
||||
@Test
|
||||
public void should_add_boot_to_versions_when_version_is_created() {
|
||||
then(new Versions("1.2.3.RELEASE").projects).contains(
|
||||
new Project("spring-boot", "1.2.3.RELEASE"),
|
||||
new Project("spring-boot-starter-parent", "1.2.3.RELEASE"),
|
||||
new Project("spring-boot-dependencies", "1.2.3.RELEASE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_true_when_project_is_on_the_list() {
|
||||
then(this.versions.shouldBeUpdated("foo")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_true_when_project_has_a_parent_suffix_and_project_is_on_the_list() {
|
||||
then(this.versions.shouldBeUpdated("foo-parent")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_true_when_project_has_a_dependencies_suffix_and_project_is_on_the_list() {
|
||||
then(this.versions.shouldBeUpdated("foo-dependencies")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_false_when_project_is_not_on_the_list() {
|
||||
then(this.versions.shouldBeUpdated("missing")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_version_for_present_project() {
|
||||
then(this.versions.versionForProject("foo")).isEqualTo("bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_empty_string_for_missing_project() {
|
||||
then(this.versions.versionForProject("missing")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_true_if_properties_contains_project_key() {
|
||||
then(this.versions.shouldSetProperty(validProps())).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_false_if_properties_does_not_contain_project_key() {
|
||||
then(this.versions.shouldSetProperty(missingProps())).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_update_projects_for_boot() {
|
||||
Versions versions = mixedVersions().setVersion("spring-boot", "3.0.0");
|
||||
|
||||
then(versions.versionForProject("spring-boot")).isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-boot-starter-parent")).isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-boot-dependencies")).isEqualTo("3.0.0");
|
||||
|
||||
versions = mixedVersions().setVersion("spring-boot-starter-parent", "3.0.0");
|
||||
|
||||
then(versions.versionForProject("spring-boot")).isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-boot-starter-parent")).isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-boot-dependencies")).isEqualTo("3.0.0");
|
||||
|
||||
versions = mixedVersions().setVersion("spring-boot-dependencies", "3.0.0");
|
||||
|
||||
then(versions.versionForProject("spring-boot")).isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-boot-starter-parent")).isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-boot-dependencies")).isEqualTo("3.0.0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_update_projects_for_build() {
|
||||
Versions versions = mixedVersions().setVersion("spring-cloud-build", "3.0.0");
|
||||
|
||||
then(versions.versionForProject("spring-cloud-build")).isEqualTo("3.0.0");
|
||||
|
||||
versions = mixedVersions().setVersion("spring-cloud-build", "3.0.0");
|
||||
|
||||
then(versions.versionForProject("spring-cloud-dependencies-parent"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("Greenwich.RELEASE");
|
||||
|
||||
versions = mixedVersions().setVersion("spring-cloud-dependencies-parent",
|
||||
"3.0.0");
|
||||
|
||||
then(versions.versionForProject("spring-cloud-build")).isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-cloud-dependencies-parent"))
|
||||
.isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("Greenwich.RELEASE");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_update_projects_for_spring_cloud_release() {
|
||||
Versions versions = mixedVersions().setVersion("spring-cloud", "3.0.0");
|
||||
|
||||
then(versions.versionForProject("spring-cloud")).isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-cloud-release")).isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-cloud-starter")).isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-cloud-dependencies")).isEqualTo("3.0.0");
|
||||
|
||||
versions = mixedVersions().setVersion("spring-cloud-release", "3.0.0");
|
||||
|
||||
then(versions.versionForProject("spring-cloud")).isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-cloud-release")).isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-cloud-starter")).isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-cloud-dependencies")).isEqualTo("3.0.0");
|
||||
|
||||
versions = mixedVersions().setVersion("spring-cloud-release", "Greenwich.SR8");
|
||||
|
||||
then(versions.versionForProject("spring-cloud")).isEqualTo("Greenwich.SR8");
|
||||
then(versions.versionForProject("spring-cloud-release"))
|
||||
.isEqualTo("Greenwich.SR8");
|
||||
then(versions.versionForProject("spring-cloud-starter"))
|
||||
.isEqualTo("Greenwich.SR8");
|
||||
then(versions.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("Greenwich.SR8");
|
||||
|
||||
versions = mixedVersions().setVersion("spring-cloud-dependencies",
|
||||
"Greenwich.SR8");
|
||||
|
||||
then(versions.versionForProject("spring-cloud")).isEqualTo("Greenwich.SR8");
|
||||
then(versions.versionForProject("spring-cloud-release"))
|
||||
.isEqualTo("Greenwich.SR8");
|
||||
then(versions.versionForProject("spring-cloud-starter"))
|
||||
.isEqualTo("Greenwich.SR8");
|
||||
then(versions.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("Greenwich.SR8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_update_projects_for_custom_bom_only() {
|
||||
Versions versions = mixedVersions(customBom()).setVersion("spring-cloud",
|
||||
"3.0.0");
|
||||
|
||||
then(versions.versionForProject("spring-cloud")).isEqualTo("3.0.0");
|
||||
then(versions.versionForProject("spring-cloud-stream-starters"))
|
||||
.isEqualTo("Fishtown.RELEASE");
|
||||
then(versions.versionForProject("spring-cloud-starter")).isEmpty();
|
||||
then(versions.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("Greenwich.RELEASE");
|
||||
|
||||
versions = mixedVersions(customBom()).setVersion("spring-cloud-stream-starters",
|
||||
"Fishtown.SR4");
|
||||
|
||||
then(versions.versionForProject("spring-cloud")).isEmpty();
|
||||
then(versions.versionForProject("spring-cloud-stream-starters"))
|
||||
.isEqualTo("Fishtown.SR4");
|
||||
then(versions.versionForProject("spring-cloud-starter")).isEmpty();
|
||||
then(versions.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("Greenwich.RELEASE");
|
||||
|
||||
versions = mixedVersions(customBom()).setVersion("spring-cloud-release",
|
||||
"Greenwich.SR8");
|
||||
|
||||
then(versions.versionForProject("spring-cloud-release"))
|
||||
.isEqualTo("Greenwich.SR8");
|
||||
then(versions.versionForProject("spring-cloud-stream-starters"))
|
||||
.isEqualTo("Fishtown.RELEASE");
|
||||
then(versions.versionForProject("spring-cloud")).isEmpty();
|
||||
then(versions.versionForProject("spring-cloud-starter")).isEmpty();
|
||||
then(versions.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("Greenwich.RELEASE");
|
||||
|
||||
versions = mixedVersions(customBom()).setVersion("spring-cloud-dependencies",
|
||||
"Greenwich.SR8");
|
||||
|
||||
then(versions.versionForProject("spring-cloud")).isEmpty();
|
||||
then(versions.versionForProject("spring-cloud-stream-starters"))
|
||||
.isEqualTo("Fishtown.RELEASE");
|
||||
then(versions.versionForProject("spring-cloud-starter")).isEmpty();
|
||||
then(versions.versionForProject("spring-cloud-dependencies"))
|
||||
.isEqualTo("Greenwich.SR8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_update_projects_for_custom_project() {
|
||||
Versions versions = mixedVersions().setVersion("foo", "3.0.0");
|
||||
|
||||
then(versions.versionForProject("foo")).isEqualTo("3.0.0");
|
||||
}
|
||||
|
||||
private Versions mixedVersions() {
|
||||
return new Versions("1.0.0", "2.0.0", mixedProjects());
|
||||
}
|
||||
|
||||
private Versions mixedVersions(ReleaserProperties properties) {
|
||||
return new Versions(properties, "1.0.0", "2.0.0", mixedProjects());
|
||||
}
|
||||
|
||||
private ReleaserProperties customBom() {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMetaRelease()
|
||||
.setReleaseTrainDependencyNames(Collections.emptyList());
|
||||
properties.getMetaRelease()
|
||||
.setReleaseTrainProjectName("spring-cloud-stream-starters");
|
||||
properties.getPom().setThisTrainBom("spring-cloud-stream-dependencies");
|
||||
return properties;
|
||||
}
|
||||
|
||||
Set<Project> projects() {
|
||||
Set<Project> projects = new HashSet<>();
|
||||
projects.add(new Project("foo", "bar"));
|
||||
return projects;
|
||||
}
|
||||
|
||||
Set<Project> mixedProjects() {
|
||||
Set<Project> projects = new HashSet<>();
|
||||
projects.add(new Project("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
projects.add(new Project("fooBar", "1.0.0.RELEASE"));
|
||||
projects.add(new Project("spring-cloud-release", "Greenwich.RELEASE"));
|
||||
projects.add(new Project("spring-cloud-dependencies", "Greenwich.RELEASE"));
|
||||
projects.add(new Project("spring-cloud-stream-starters", "Fishtown.RELEASE"));
|
||||
return projects;
|
||||
}
|
||||
|
||||
Properties validProps() {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("foo.version", "1.0.0");
|
||||
return properties;
|
||||
}
|
||||
|
||||
Properties missingProps() {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("missing.version", "1.0.0");
|
||||
return properties;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,10 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.release.internal.post;
|
||||
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;
|
||||
@@ -37,16 +38,16 @@ import org.mockito.BDDMockito;
|
||||
|
||||
import org.springframework.cloud.release.internal.PomUpdateAcceptanceTests;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.buildsystem.GradleUpdater;
|
||||
import org.springframework.cloud.release.internal.buildsystem.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.buildsystem.TestUtils;
|
||||
import org.springframework.cloud.release.internal.git.GitTestUtils;
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.cloud.release.internal.gradle.GradleUpdater;
|
||||
import org.springframework.cloud.release.internal.pom.ProcessedProject;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.pom.TestPomReader;
|
||||
import org.springframework.cloud.release.internal.pom.TestUtils;
|
||||
import org.springframework.cloud.release.internal.project.ProjectBuilder;
|
||||
import org.springframework.cloud.release.internal.project.ProcessedProject;
|
||||
import org.springframework.cloud.release.internal.project.ProjectCommandExecutor;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
import org.springframework.cloud.release.internal.tech.PomReader;
|
||||
import org.springframework.cloud.release.internal.versions.VersionsFetcher;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
@@ -61,8 +62,6 @@ public class PostReleaseActionsTests {
|
||||
|
||||
File temporaryFolder;
|
||||
|
||||
TestPomReader testPomReader = new TestPomReader();
|
||||
|
||||
GradleUpdater gradleUpdater = BDDMockito.mock(GradleUpdater.class);
|
||||
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
@@ -92,11 +91,11 @@ public class PostReleaseActionsTests {
|
||||
}
|
||||
};
|
||||
|
||||
ProjectPomUpdater updater = new ProjectPomUpdater(this.properties);
|
||||
ProjectPomUpdater updater = new ProjectPomUpdater(this.properties, new ArrayList<>());
|
||||
|
||||
VersionsFetcher versionsFetcher = new VersionsFetcher(properties, updater);
|
||||
|
||||
ProjectBuilder builder = new ProjectBuilder(this.properties);
|
||||
ProjectCommandExecutor builder = new ProjectCommandExecutor(this.properties);
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
@@ -143,7 +142,7 @@ public class PostReleaseActionsTests {
|
||||
|
||||
actions.runUpdatedTests(currentGa());
|
||||
|
||||
Model rootPom = this.testPomReader.readPom(new File(this.cloned, "pom.xml"));
|
||||
Model rootPom = PomReader.readPom(new File(this.cloned, "pom.xml"));
|
||||
BDDAssertions.then(rootPom.getVersion()).isEqualTo("Finchley.SR1");
|
||||
BDDAssertions.then(rootPom.getParent().getVersion()).isEqualTo("2.0.4.RELEASE");
|
||||
BDDAssertions.then(sleuthParentPomVersion()).isEqualTo("2.0.4.RELEASE");
|
||||
@@ -186,15 +185,14 @@ public class PostReleaseActionsTests {
|
||||
this.properties.getMetaRelease().setEnabled(true);
|
||||
this.properties.getGit().setReleaseTrainDocsUrl(
|
||||
tmpFile("spring-cloud-core-tests/").getAbsolutePath() + "/");
|
||||
this.properties.getMaven()
|
||||
.setGenerateReleaseTrainDocsCommand("touch generate.log");
|
||||
this.properties.getMaven().setGenerateReleaseTrainDocsCommand("./test.sh");
|
||||
PostReleaseActions actions = new PostReleaseActions(this.projectGitHandler,
|
||||
this.updater, this.gradleUpdater, this.builder, this.properties,
|
||||
versionsFetcher);
|
||||
|
||||
actions.generateReleaseTrainDocumentation(currentGa());
|
||||
|
||||
Model rootPom = this.testPomReader.readPom(new File(this.cloned, "pom.xml"));
|
||||
Model rootPom = PomReader.readPom(new File(this.cloned, "pom.xml"));
|
||||
BDDAssertions.then(rootPom.getVersion()).isEqualTo("Finchley.SR1");
|
||||
BDDAssertions.then(rootPom.getParent().getVersion()).isEqualTo("2.0.4.RELEASE");
|
||||
BDDAssertions.then(sleuthParentPomVersion()).isEqualTo("2.0.4.RELEASE");
|
||||
@@ -253,7 +251,7 @@ public class PostReleaseActionsTests {
|
||||
.filter(s -> s.getKey().contains("spring-cloud-core-tests")).findFirst()
|
||||
.orElseThrow(() -> new IllegalStateException("Not found"));
|
||||
File clonedFile = entry.getValue().get(0);
|
||||
Model pomWithCloud = this.testPomReader
|
||||
Model pomWithCloud = PomReader
|
||||
.readPom(new File(clonedFile, "zuul-proxy-eureka/pom.xml"));
|
||||
Git git = GitTestUtils.openGitProject(clonedFile);
|
||||
BDDAssertions
|
||||
@@ -318,15 +316,16 @@ public class PostReleaseActionsTests {
|
||||
this.properties.getMetaRelease().setGitOrgUrl(projects);
|
||||
VersionsFetcher versionsFetcher = BDDMockito.mock(VersionsFetcher.class);
|
||||
BDDMockito.given(versionsFetcher.isLatestGa(BDDMockito.any())).willReturn(true);
|
||||
AtomicReference<ProjectBuilder> projectBuilderStub = new AtomicReference<>();
|
||||
AtomicReference<ProjectCommandExecutor> projectBuilderStub = new AtomicReference<>();
|
||||
ProjectGitHandler handler = BDDMockito.mock(ProjectGitHandler.class);
|
||||
ProjectBuilder projectBuilder = BDDMockito.mock(ProjectBuilder.class);
|
||||
ProjectCommandExecutor projectCommandExecutor = BDDMockito
|
||||
.mock(ProjectCommandExecutor.class);
|
||||
PostReleaseActions actions = new PostReleaseActions(handler, this.updater,
|
||||
this.gradleUpdater, this.builder, this.properties, versionsFetcher) {
|
||||
@Override
|
||||
ProjectBuilder projectBuilder(ProcessedProject processedProject) {
|
||||
projectBuilderStub.set(projectBuilder);
|
||||
return projectBuilder;
|
||||
ProjectCommandExecutor projectBuilder(ProcessedProject processedProject) {
|
||||
projectBuilderStub.set(projectCommandExecutor);
|
||||
return projectCommandExecutor;
|
||||
}
|
||||
};
|
||||
ProjectVersion projectVersion = new ProjectVersion(
|
||||
@@ -343,8 +342,8 @@ public class PostReleaseActionsTests {
|
||||
}
|
||||
|
||||
private String sleuthParentPomVersion() {
|
||||
return this.testPomReader.readPom(new File(this.cloned, "sleuth/pom.xml"))
|
||||
.getParent().getVersion();
|
||||
return PomReader.readPom(new File(this.cloned, "sleuth/pom.xml")).getParent()
|
||||
.getVersion();
|
||||
}
|
||||
|
||||
Projects currentGa() {
|
||||
@@ -32,8 +32,7 @@ import org.junit.rules.TemporaryFolder;
|
||||
import org.springframework.boot.test.rule.OutputCapture;
|
||||
import org.springframework.cloud.release.internal.PomUpdateAcceptanceTests;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.TestUtils;
|
||||
import org.springframework.cloud.release.internal.buildsystem.TestUtils;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
@@ -42,7 +41,7 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy;
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
public class ProjectBuilderTests {
|
||||
public class ProjectCommandExecutorTests {
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder tmp = new TemporaryFolder();
|
||||
@@ -60,8 +59,8 @@ public class ProjectBuilderTests {
|
||||
FileSystemUtils.copyRecursively(file("/projects"), this.temporaryFolder);
|
||||
}
|
||||
|
||||
ProjectBuilder projectBuilder(ReleaserProperties properties) {
|
||||
return new ProjectBuilder(properties) {
|
||||
ProjectCommandExecutor projectBuilder(ReleaserProperties properties) {
|
||||
return new ProjectCommandExecutor(properties) {
|
||||
@Override
|
||||
ProcessExecutor executor(String workingDir) {
|
||||
return testExecutor(workingDir);
|
||||
@@ -73,9 +72,9 @@ public class ProjectBuilderTests {
|
||||
public void should_successfully_execute_a_command_when_after_running_there_is_no_html_file_with_unresolved_tag()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setBuildCommand("ls -al");
|
||||
properties.getBash().setBuildCommand("ls -al");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
@@ -87,9 +86,9 @@ public class ProjectBuilderTests {
|
||||
public void should_successfully_execute_a_command_when_path_is_provided_explicitly()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setBuildCommand("ls -al");
|
||||
properties.getBash().setBuildCommand("ls -al");
|
||||
properties.setWorkingDir(new File("/foo/bar").getAbsolutePath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"),
|
||||
tmpFile("/builder/resolved").getPath());
|
||||
@@ -102,66 +101,63 @@ public class ProjectBuilderTests {
|
||||
public void should_successfully_execute_a_build_command_for_milestone_version()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setBuildCommand("echo foo");
|
||||
properties.getBash().setBuildCommand("echo foo");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.M1"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("foo -Pmilestone");
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log"))).contains("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_successfully_execute_a_build_command_for_rc_version()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setBuildCommand("echo foo");
|
||||
properties.getBash().setBuildCommand("echo foo");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.RC1"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("foo -Pmilestone").doesNotContain("-Pguides");
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log"))).contains("foo")
|
||||
.doesNotContain("-Pguides");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_successfully_execute_a_build_command_for_release_version()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setBuildCommand("echo foo");
|
||||
properties.getBash().setBuildCommand("echo foo");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.RELEASE"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("foo -Pcentral");
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log"))).contains("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_successfully_execute_a_build_command_for_sr_version()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setBuildCommand("echo foo");
|
||||
properties.getBash().setBuildCommand("echo foo");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.SR1"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("foo -Pcentral");
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log"))).contains("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_successfully_execute_a_command_when_system_props_placeholder_is_present()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setBuildCommand("echo {{systemProps}}");
|
||||
properties.getMaven().setSystemProperties("-Dhello=world -Dfoo=bar");
|
||||
properties.getBash().setBuildCommand("echo {{systemProps}}");
|
||||
properties.getBash().setSystemProperties("-Dhello=world -Dfoo=bar");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
@@ -173,9 +169,9 @@ public class ProjectBuilderTests {
|
||||
public void should_successfully_execute_a_command_when_system_props_placeholder_is_present_and_there_are_no_sys_props()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setBuildCommand("echo foo {{systemProps}}");
|
||||
properties.getBash().setBuildCommand("echo foo {{systemProps}}");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
@@ -186,10 +182,10 @@ public class ProjectBuilderTests {
|
||||
public void should_successfully_execute_a_command_when_system_props_placeholder_is_present_without_system_props()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setBuildCommand("echo {{systemProps}}");
|
||||
properties.getMaven().setSystemProperties("hello=world foo=bar");
|
||||
properties.getBash().setBuildCommand("echo {{systemProps}}");
|
||||
properties.getBash().setSystemProperties("hello=world foo=bar");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
@@ -201,10 +197,10 @@ public class ProjectBuilderTests {
|
||||
public void should_successfully_execute_a_command_when_system_props_placeholder_is_present_inside_command()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setBuildCommand("echo {{systemProps}} bar");
|
||||
properties.getMaven().setSystemProperties("-Dhello=world -Dfoo=bar");
|
||||
properties.getBash().setBuildCommand("echo {{systemProps}} bar");
|
||||
properties.getBash().setSystemProperties("-Dhello=world -Dfoo=bar");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
@@ -216,10 +212,10 @@ public class ProjectBuilderTests {
|
||||
public void should_successfully_pass_system_props_when_build_gets_executed_without_explicit_system_props()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setBuildCommand("echo bar");
|
||||
properties.getMaven().setSystemProperties("-Dhello=world -Dfoo=bar");
|
||||
properties.getBash().setBuildCommand("echo bar");
|
||||
properties.getBash().setSystemProperties("-Dhello=world -Dfoo=bar");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
@@ -230,9 +226,9 @@ public class ProjectBuilderTests {
|
||||
@Test
|
||||
public void should_throw_exception_when_after_running_there_is_an_html_file_with_unresolved_tag() {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setBuildCommand("ls -al");
|
||||
properties.getBash().setBuildCommand("ls -al");
|
||||
properties.setWorkingDir(tmpFile("/builder/unresolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
thenThrownBy(
|
||||
() -> builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT")))
|
||||
@@ -243,10 +239,10 @@ public class ProjectBuilderTests {
|
||||
@Test
|
||||
public void should_throw_exception_when_command_took_too_long_to_execute() {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setBuildCommand("sleep 1");
|
||||
properties.getMaven().setWaitTimeInMinutes(0);
|
||||
properties.getBash().setBuildCommand("sleep 1");
|
||||
properties.getBash().setWaitTimeInMinutes(0);
|
||||
properties.setWorkingDir(tmpFile("/builder/unresolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
thenThrownBy(
|
||||
() -> builder.build(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT")))
|
||||
@@ -257,9 +253,9 @@ public class ProjectBuilderTests {
|
||||
@Test
|
||||
public void should_successfully_execute_a_deploy_command() throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setDeployCommand("ls -al");
|
||||
properties.getBash().setDeployCommand("ls -al");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
@@ -271,9 +267,25 @@ public class ProjectBuilderTests {
|
||||
public void should_successfully_execute_a_deploy_command_for_milestone_version()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getBash().setDeployCommand("echo foo");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.M1"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log"))).contains("foo")
|
||||
.doesNotContain("-Pguides");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_successfully_execute_a_deploy_command_for_milestone_version_for_maven()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setDeployCommand("echo foo");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
new ProcessExecutor(properties.getWorkingDir())
|
||||
.runCommand(new String[] { "touch", "pom.xml" }, 1);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.M1"));
|
||||
|
||||
@@ -285,9 +297,25 @@ public class ProjectBuilderTests {
|
||||
public void should_successfully_execute_a_deploy_command_for_rc_version()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getBash().setDeployCommand("echo foo");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.RC1"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log"))).contains("foo")
|
||||
.doesNotContain("-Pguides");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_successfully_execute_a_deploy_command_for_rc_version_for_maven()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setDeployCommand("echo foo");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
new ProcessExecutor(properties.getWorkingDir())
|
||||
.runCommand(new String[] { "touch", "pom.xml" }, 1);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.RC1"));
|
||||
|
||||
@@ -299,9 +327,24 @@ public class ProjectBuilderTests {
|
||||
public void should_successfully_execute_a_deploy_command_for_release_version()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getBash().setDeployCommand("echo foo");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.RELEASE"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log"))).contains("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_successfully_execute_a_deploy_command_for_release_version_for_maven()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setDeployCommand("echo foo");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
new ProcessExecutor(properties.getWorkingDir())
|
||||
.runCommand(new String[] { "touch", "pom.xml" }, 1);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.RELEASE"));
|
||||
|
||||
@@ -313,24 +356,23 @@ public class ProjectBuilderTests {
|
||||
public void should_successfully_execute_a_deploy_command_for_sr_version()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setDeployCommand("echo foo");
|
||||
properties.getBash().setDeployCommand("echo foo");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.SR1"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("foo -Pcentral");
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log"))).contains("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_successfully_execute_a_deploy_command_with_sys_props_placeholder()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setDeployCommand("echo \"{{systemProps}}\"");
|
||||
properties.getMaven().setSystemProperties("-Dhello=hello-world");
|
||||
properties.getBash().setDeployCommand("echo \"{{systemProps}}\"");
|
||||
properties.getBash().setSystemProperties("-Dhello=hello-world");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
@@ -342,10 +384,10 @@ public class ProjectBuilderTests {
|
||||
public void should_successfully_pass_system_props_when_deploy_gets_executed_without_explicit_system_props()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setDeployCommand("echo ");
|
||||
properties.getMaven().setSystemProperties("-Dhello=hello-world");
|
||||
properties.getBash().setDeployCommand("echo ");
|
||||
properties.getBash().setSystemProperties("-Dhello=hello-world");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT"));
|
||||
|
||||
@@ -356,10 +398,10 @@ public class ProjectBuilderTests {
|
||||
@Test
|
||||
public void should_throw_exception_when_deploy_command_took_too_long_to_execute() {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setDeployCommand("sleep 1");
|
||||
properties.getMaven().setWaitTimeInMinutes(0);
|
||||
properties.getBash().setDeployCommand("sleep 1");
|
||||
properties.getBash().setWaitTimeInMinutes(0);
|
||||
properties.setWorkingDir(tmpFile("/builder/unresolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
thenThrownBy(
|
||||
() -> builder.deploy(new ProjectVersion("foo", "1.0.0.BUILD-SNAPSHOT")))
|
||||
@@ -370,10 +412,10 @@ public class ProjectBuilderTests {
|
||||
@Test
|
||||
public void should_successfully_execute_a_publish_docs_command() throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setPublishDocsCommands(new String[] { "ls -al", "ls -al" });
|
||||
properties.getBash().setPublishDocsCommands(new String[] { "ls -al", "ls -al" });
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
TestProcessExecutor executor = testExecutor(properties.getWorkingDir());
|
||||
ProjectBuilder builder = new ProjectBuilder(properties) {
|
||||
ProjectCommandExecutor builder = new ProjectCommandExecutor(properties) {
|
||||
@Override
|
||||
ProcessExecutor executor(String workingDir) {
|
||||
return executor;
|
||||
@@ -391,12 +433,12 @@ public class ProjectBuilderTests {
|
||||
public void should_successfully_execute_a_publish_docs_command_with_sys_props_placeholder()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setPublishDocsCommands(
|
||||
properties.getBash().setPublishDocsCommands(
|
||||
new String[] { "echo {{systemProps}} 1", "echo {{systemProps}} 2" });
|
||||
properties.getMaven().setSystemProperties("-Dhello=world -Dfoo=bar");
|
||||
properties.getBash().setSystemProperties("-Dhello=world -Dfoo=bar");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
TestProcessExecutor executor = testExecutor(properties.getWorkingDir());
|
||||
ProjectBuilder builder = new ProjectBuilder(properties) {
|
||||
ProjectCommandExecutor builder = new ProjectCommandExecutor(properties) {
|
||||
@Override
|
||||
ProcessExecutor executor(String workingDir) {
|
||||
return executor;
|
||||
@@ -414,11 +456,11 @@ public class ProjectBuilderTests {
|
||||
public void should_successfully_execute_a_publish_docs_command_and_substitute_the_version()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven()
|
||||
properties.getBash()
|
||||
.setPublishDocsCommands(new String[] { "echo '{{version}}'" });
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
TestProcessExecutor executor = testExecutor(properties.getWorkingDir());
|
||||
ProjectBuilder builder = new ProjectBuilder(properties) {
|
||||
ProjectCommandExecutor builder = new ProjectCommandExecutor(properties) {
|
||||
@Override
|
||||
ProcessExecutor executor(String workingDir) {
|
||||
return executor;
|
||||
@@ -435,11 +477,11 @@ public class ProjectBuilderTests {
|
||||
public void should_successfully_execute_an_update_docs_command_and_substitute_the_version()
|
||||
throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setGenerateReleaseTrainDocsCommand("echo '{{version}}'");
|
||||
properties.getBash().setGenerateReleaseTrainDocsCommand("echo '{{version}}'");
|
||||
File resolved = tmpFile("/builder/resolved");
|
||||
properties.setWorkingDir(resolved.getPath());
|
||||
TestProcessExecutor executor = testExecutor(properties.getWorkingDir());
|
||||
ProjectBuilder builder = new ProjectBuilder(properties) {
|
||||
ProjectCommandExecutor builder = new ProjectCommandExecutor(properties) {
|
||||
@Override
|
||||
ProcessExecutor executor(String workingDir) {
|
||||
return executor;
|
||||
@@ -455,11 +497,11 @@ public class ProjectBuilderTests {
|
||||
@Test
|
||||
public void should_throw_exception_when_publish_docs_command_took_too_long_to_execute() {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven()
|
||||
properties.getBash()
|
||||
.setPublishDocsCommands(new String[] { "sleep 1", "sleep 1" });
|
||||
properties.getMaven().setWaitTimeInMinutes(0);
|
||||
properties.getBash().setWaitTimeInMinutes(0);
|
||||
properties.setWorkingDir(tmpFile("/builder/unresolved").getPath());
|
||||
ProjectBuilder builder = projectBuilder(properties);
|
||||
ProjectCommandExecutor builder = projectBuilder(properties);
|
||||
|
||||
thenThrownBy(() -> builder.publishDocs(""))
|
||||
.hasMessageContaining("Process waiting time of [0] minutes exceeded");
|
||||
@@ -468,9 +510,9 @@ public class ProjectBuilderTests {
|
||||
@Test
|
||||
public void should_throw_exception_when_process_exits_with_invalid_code() {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setBuildCommand("exit 1");
|
||||
properties.getBash().setBuildCommand("exit 1");
|
||||
properties.setWorkingDir(tmpFile("/builder/unresolved").getPath());
|
||||
ProjectBuilder builder = new ProjectBuilder(properties) {
|
||||
ProjectCommandExecutor builder = new ProjectCommandExecutor(properties) {
|
||||
@Override
|
||||
ProcessExecutor executor(String workingDir) {
|
||||
return new ProcessExecutor(properties.getWorkingDir()) {
|
||||
@@ -31,7 +31,7 @@ import org.mockito.BDDMockito;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
||||
@@ -24,9 +24,9 @@ import java.util.HashSet;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.git.ProjectGitHandler;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.github.ProjectGitHubHandler;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class TemplateGeneratorTests {
|
||||
|
||||
ReleaserProperties props = new ReleaserProperties();
|
||||
|
||||
ProjectGitHandler handler = new ProjectGitHandler(this.props) {
|
||||
ProjectGitHubHandler handler = new ProjectGitHubHandler(this.props) {
|
||||
@Override
|
||||
public String milestoneUrl(ProjectVersion releaseVersion) {
|
||||
if (releaseVersion.projectName.equals("spring-cloud-foo")) {
|
||||
@@ -118,8 +118,8 @@ public class TemplateGeneratorTests {
|
||||
.contains("The release can be found in [Maven Central]")
|
||||
.contains("### Spring Cloud Sleuth")
|
||||
.contains(
|
||||
"| Spring Cloud Sleuth | 1.0.0.RELEASE | ([issues](https://foo.bar.com))")
|
||||
.contains("| Spring Cloud Foo\t| 1.0.2.RELEASE\t| ")
|
||||
"| Spring Cloud Sleuth | 1.0.0.RELEASE | ([issues](https://foo.bar.com))")
|
||||
.contains("| Spring Cloud Foo | 1.0.2.RELEASE | ")
|
||||
.contains("<version>Dalston.RELEASE</version>").contains(
|
||||
"mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.RELEASE'");
|
||||
}
|
||||
@@ -143,7 +143,7 @@ public class TemplateGeneratorTests {
|
||||
.contains("The release can be found in [Maven Central]")
|
||||
.contains("### Spring Cloud Sleuth")
|
||||
.contains(
|
||||
"| Spring Cloud Sleuth\t| 1.0.0.RELEASE\t| ([issues](https://foo.bar.com))")
|
||||
"| Spring Cloud Sleuth | 1.0.0.RELEASE | ([issues](https://foo.bar.com))")
|
||||
.contains("<version>Dalston.RELEASE</version>").contains(
|
||||
"mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.RELEASE'");
|
||||
}
|
||||
@@ -167,7 +167,7 @@ public class TemplateGeneratorTests {
|
||||
.contains("The release can be found in [Maven Central]")
|
||||
.contains("### Spring Cloud Sleuth")
|
||||
.contains(
|
||||
"| Spring Cloud Sleuth | 1.0.0.RELEASE | ([issues](https://foo.bar.com))")
|
||||
"| Spring Cloud Sleuth | 1.0.0.RELEASE | ([issues](https://foo.bar.com))")
|
||||
.contains("<version>Dalston.SR1</version>").contains(
|
||||
"mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.SR1'");
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public class TemplateGeneratorTests {
|
||||
.contains("The release can be found in [Maven Central]")
|
||||
.contains("### Spring Cloud Sleuth")
|
||||
.contains(
|
||||
"| Spring Cloud Sleuth | 1.0.0.RELEASE | ([issues](https://foo.bar.com))")
|
||||
"| Spring Cloud Sleuth | 1.0.0.RELEASE | ([issues](https://foo.bar.com))")
|
||||
.contains("<version>Dalston.SR1</version>").contains(
|
||||
"mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Dalston.SR1'");
|
||||
}
|
||||
@@ -215,7 +215,7 @@ public class TemplateGeneratorTests {
|
||||
.contains("The release can be found in [Spring Milestone]")
|
||||
.contains("### Spring Cloud Sleuth")
|
||||
.contains(
|
||||
"| Spring Cloud Sleuth\t| 1.0.0.M1\t| ([issues](https://foo.bar.com))")
|
||||
"| Spring Cloud Sleuth | 1.0.0.M1 | ([issues](https://foo.bar.com))")
|
||||
.contains("<id>spring-milestones</id>")
|
||||
.contains("url 'https://repo.spring.io/milestone'")
|
||||
.contains("<version>Dalston.M1</version>").contains(
|
||||
@@ -241,7 +241,7 @@ public class TemplateGeneratorTests {
|
||||
.contains("The release can be found in [Spring Milestone]")
|
||||
.contains("### Spring Cloud Sleuth")
|
||||
.contains(
|
||||
"| Spring Cloud Sleuth\t| 1.0.0.M1\t| ([issues](https://foo.bar.com))")
|
||||
"| Spring Cloud Sleuth | 1.0.0.M1 | ([issues](https://foo.bar.com))")
|
||||
.contains("<id>spring-milestones</id>")
|
||||
.contains("url 'https://repo.spring.io/milestone'")
|
||||
.contains("<version>Dalston.M1</version>").contains(
|
||||
@@ -267,7 +267,7 @@ public class TemplateGeneratorTests {
|
||||
.contains("The release can be found in [Spring Milestone]")
|
||||
.contains("### Spring Cloud Sleuth")
|
||||
.contains(
|
||||
"| Spring Cloud Sleuth\t| 1.0.0.RC1\t| ([issues](https://foo.bar.com))")
|
||||
"| Spring Cloud Sleuth | 1.0.0.RC1 | ([issues](https://foo.bar.com))")
|
||||
.contains("<id>spring-milestones</id>")
|
||||
.contains("url 'https://repo.spring.io/milestone'")
|
||||
.contains("<version>Dalston.RC1</version>").contains(
|
||||
@@ -293,7 +293,7 @@ public class TemplateGeneratorTests {
|
||||
.contains("The release can be found in [Spring Milestone]")
|
||||
.contains("### Spring Cloud Sleuth")
|
||||
.contains(
|
||||
"| Spring Cloud Sleuth\t| 1.0.0.RC1\t| ([issues](https://foo.bar.com))")
|
||||
"| Spring Cloud Sleuth | 1.0.0.RC1 | ([issues](https://foo.bar.com))")
|
||||
.contains("<id>spring-milestones</id>")
|
||||
.contains("url 'https://repo.spring.io/milestone'")
|
||||
.contains("<version>Dalston.RC1</version>").contains(
|
||||
@@ -303,7 +303,7 @@ public class TemplateGeneratorTests {
|
||||
@Test
|
||||
public void should_generate_release_notes_template_when_url_exists()
|
||||
throws IOException {
|
||||
ProjectGitHandler handler = new ProjectGitHandler(this.props) {
|
||||
ProjectGitHubHandler handler = new ProjectGitHubHandler(this.props) {
|
||||
@Override
|
||||
public String milestoneUrl(ProjectVersion releaseVersion) {
|
||||
return "https://foo.bar.com?closed=1";
|
||||
|
||||
@@ -21,19 +21,22 @@ import java.io.IOException;
|
||||
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.pom.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.Projects;
|
||||
import org.springframework.cloud.release.internal.pom.TestUtils;
|
||||
import org.springframework.cloud.release.internal.buildsystem.MavenBomParserAccessor;
|
||||
import org.springframework.cloud.release.internal.buildsystem.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.buildsystem.TestUtils;
|
||||
import org.springframework.cloud.release.internal.project.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.project.Projects;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
class VersionsFetcherTests {
|
||||
class VersionsFromBomFetcherTests {
|
||||
|
||||
File temporaryFolder;
|
||||
|
||||
@@ -52,13 +55,14 @@ class VersionsFetcherTests {
|
||||
throws URISyntaxException {
|
||||
ProjectVersion projectVersion = new ProjectVersion("spring-cloud-contract",
|
||||
"2.5.0.RELEASE");
|
||||
URI initilizrUri = VersionsFetcherTests.class.getResource("/raw/initializr.yml")
|
||||
.toURI();
|
||||
URI initilizrUri = VersionsFromBomFetcherTests.class
|
||||
.getResource("/raw/initializr.yml").toURI();
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
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, Collections
|
||||
.singletonList(MavenBomParserAccessor.cloudMavenBomParser(properties)));
|
||||
VersionsFetcher versionsFetcher = new VersionsFetcher(properties, updater);
|
||||
|
||||
boolean latestGa = versionsFetcher.isLatestGa(projectVersion);
|
||||
@@ -71,13 +75,14 @@ class VersionsFetcherTests {
|
||||
throws URISyntaxException {
|
||||
ProjectVersion projectVersion = new ProjectVersion("spring-cloud-contract",
|
||||
"1.0.0.RELEASE");
|
||||
URI initilizrUri = VersionsFetcherTests.class.getResource("/raw/initializr.yml")
|
||||
.toURI();
|
||||
URI initilizrUri = VersionsFromBomFetcherTests.class
|
||||
.getResource("/raw/initializr.yml").toURI();
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
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, Collections
|
||||
.singletonList(MavenBomParserAccessor.cloudMavenBomParser(properties)));
|
||||
VersionsFetcher versionsFetcher = new VersionsFetcher(properties, updater);
|
||||
|
||||
boolean latestGa = versionsFetcher.isLatestGa(projectVersion);
|
||||
@@ -90,13 +95,13 @@ class VersionsFetcherTests {
|
||||
throws URISyntaxException {
|
||||
ProjectVersion projectVersion = new ProjectVersion("spring-cloud-non-existant",
|
||||
"1.0.0.RELEASE");
|
||||
URI initilizrUri = VersionsFetcherTests.class.getResource("/raw/initializr.yml")
|
||||
.toURI();
|
||||
URI initilizrUri = VersionsFromBomFetcherTests.class
|
||||
.getResource("/raw/initializr.yml").toURI();
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
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 +114,7 @@ class VersionsFetcherTests {
|
||||
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 +128,7 @@ class VersionsFetcherTests {
|
||||
"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) {
|
||||
@@ -137,7 +142,8 @@ class VersionsFetcherTests {
|
||||
}
|
||||
|
||||
private File localFile(String relativePath) throws URISyntaxException {
|
||||
return new File(VersionsFetcherTests.class.getResource(relativePath).toURI());
|
||||
return new File(
|
||||
VersionsFromBomFetcherTests.class.getResource(relativePath).toURI());
|
||||
}
|
||||
|
||||
private File file(String relativePath) {
|
||||
@@ -38,7 +38,8 @@ public class BootstrapClientApplicationTests {
|
||||
public void contextLoads() throws Exception {
|
||||
assertThat(2).isEqualTo(this.server.getTomcat().getMaxThreads());
|
||||
// The application.yml is never read because spring.config.name=sample
|
||||
assertThat("application").isEqualTo(this.server.getServlet().getApplicationDisplayName());
|
||||
assertThat("application")
|
||||
.isEqualTo(this.server.getServlet().getApplicationDisplayName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@ import org.springframework.cloud.config.client.ConfigServicePropertySourceLocato
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@DirtiesContext
|
||||
@@ -41,7 +39,8 @@ public class BootstrapDecryptionClientApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() throws Exception {
|
||||
assertThat(new String[] { "http://localhost:8888" }).isEqualTo(this.config.getUri());
|
||||
assertThat(new String[] { "http://localhost:8888" })
|
||||
.isEqualTo(this.config.getUri());
|
||||
// The application.yml is never read because spring.config.name=sample
|
||||
assertThat(this.locator).isNotNull();
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ import static org.junit.Assert.fail;
|
||||
public class StandaloneClientApplicationTests {
|
||||
|
||||
private static ConfigurableApplicationContext context;
|
||||
|
||||
@Autowired
|
||||
private ConfigServicePropertySourceLocator locator;
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Added script
|
||||
@@ -18,7 +18,7 @@
|
||||
# This example catches duplicate Signed-off-by lines.
|
||||
|
||||
test "" = "$(grep '^Signed-off-by: ' "$1" |
|
||||
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
|
||||
echo >&2 Duplicate Signed-off-by lines.
|
||||
exit 1
|
||||
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
|
||||
echo >&2 Duplicate Signed-off-by lines.
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -7,12 +7,11 @@
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-commit".
|
||||
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1
|
||||
then
|
||||
against=HEAD
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1; then
|
||||
against=HEAD
|
||||
else
|
||||
# Initial commit: diff against an empty tree object
|
||||
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
||||
# Initial commit: diff against an empty tree object
|
||||
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
||||
fi
|
||||
|
||||
# If you want to allow non-ASCII filenames set this variable to true.
|
||||
@@ -25,13 +24,12 @@ exec 1>&2
|
||||
# them from being added to the repository. We exploit the fact that the
|
||||
# printable range starts at the space character and ends with tilde.
|
||||
if [ "$allownonascii" != "true" ] &&
|
||||
# Note that the use of brackets around a tr range is ok here, (it's
|
||||
# even required, for portability to Solaris 10's /usr/bin/tr), since
|
||||
# the square bracket bytes happen to fall in the designated range.
|
||||
test $(git diff --cached --name-only --diff-filter=A -z $against |
|
||||
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
|
||||
then
|
||||
cat <<\EOF
|
||||
# Note that the use of brackets around a tr range is ok here, (it's
|
||||
# even required, for portability to Solaris 10's /usr/bin/tr), since
|
||||
# the square bracket bytes happen to fall in the designated range.
|
||||
test $(git diff --cached --name-only --diff-filter=A -z $against |
|
||||
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0; then
|
||||
cat <<\EOF
|
||||
Error: Attempt to add a non-ASCII file name.
|
||||
|
||||
This can cause problems if you want to work with people on other platforms.
|
||||
@@ -42,7 +40,7 @@ If you know what you are doing you can disable this check using:
|
||||
|
||||
git config hooks.allownonascii true
|
||||
EOF
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If there are whitespace errors, print the offending file names and fail.
|
||||
|
||||
@@ -24,30 +24,26 @@ url="$2"
|
||||
|
||||
z40=0000000000000000000000000000000000000000
|
||||
|
||||
while read local_ref local_sha remote_ref remote_sha
|
||||
do
|
||||
if [ "$local_sha" = $z40 ]
|
||||
then
|
||||
# Handle delete
|
||||
:
|
||||
else
|
||||
if [ "$remote_sha" = $z40 ]
|
||||
then
|
||||
# New branch, examine all commits
|
||||
range="$local_sha"
|
||||
else
|
||||
# Update to existing branch, examine new commits
|
||||
range="$remote_sha..$local_sha"
|
||||
fi
|
||||
while read local_ref local_sha remote_ref remote_sha; do
|
||||
if [ "$local_sha" = $z40 ]; then
|
||||
# Handle delete
|
||||
:
|
||||
else
|
||||
if [ "$remote_sha" = $z40 ]; then
|
||||
# New branch, examine all commits
|
||||
range="$local_sha"
|
||||
else
|
||||
# Update to existing branch, examine new commits
|
||||
range="$remote_sha..$local_sha"
|
||||
fi
|
||||
|
||||
# Check for WIP commit
|
||||
commit=`git rev-list -n 1 --grep '^WIP' "$range"`
|
||||
if [ -n "$commit" ]
|
||||
then
|
||||
echo >&2 "Found WIP commit in $local_ref, not pushing"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
# Check for WIP commit
|
||||
commit=$(git rev-list -n 1 --grep '^WIP' "$range")
|
||||
if [ -n "$commit" ]; then
|
||||
echo >&2 "Found WIP commit in $local_ref, not pushing"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -17,20 +17,19 @@
|
||||
|
||||
publish=next
|
||||
basebranch="$1"
|
||||
if test "$#" = 2
|
||||
then
|
||||
topic="refs/heads/$2"
|
||||
if test "$#" = 2; then
|
||||
topic="refs/heads/$2"
|
||||
else
|
||||
topic=`git symbolic-ref HEAD` ||
|
||||
exit 0 ;# we do not interrupt rebasing detached HEAD
|
||||
topic=$(git symbolic-ref HEAD) ||
|
||||
exit 0 # we do not interrupt rebasing detached HEAD
|
||||
fi
|
||||
|
||||
case "$topic" in
|
||||
refs/heads/??/*)
|
||||
;;
|
||||
refs/heads/??/*) ;;
|
||||
|
||||
*)
|
||||
exit 0 ;# we do not interrupt others.
|
||||
;;
|
||||
exit 0 # we do not interrupt others.
|
||||
;;
|
||||
esac
|
||||
|
||||
# Now we are dealing with a topic branch being rebased
|
||||
@@ -38,34 +37,31 @@ esac
|
||||
|
||||
# Does the topic really exist?
|
||||
git show-ref -q "$topic" || {
|
||||
echo >&2 "No such branch $topic"
|
||||
exit 1
|
||||
echo >&2 "No such branch $topic"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Is topic fully merged to master?
|
||||
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
|
||||
if test -z "$not_in_master"
|
||||
then
|
||||
echo >&2 "$topic is fully merged to master; better remove it."
|
||||
exit 1 ;# we could allow it, but there is no point.
|
||||
not_in_master=$(git rev-list --pretty=oneline ^master "$topic")
|
||||
if test -z "$not_in_master"; then
|
||||
echo >&2 "$topic is fully merged to master; better remove it."
|
||||
exit 1 # we could allow it, but there is no point.
|
||||
fi
|
||||
|
||||
# Is topic ever merged to next? If so you should not be rebasing it.
|
||||
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
|
||||
only_next_2=`git rev-list ^master ${publish} | sort`
|
||||
if test "$only_next_1" = "$only_next_2"
|
||||
then
|
||||
not_in_topic=`git rev-list "^$topic" master`
|
||||
if test -z "$not_in_topic"
|
||||
then
|
||||
echo >&2 "$topic is already up to date with master"
|
||||
exit 1 ;# we could allow it, but there is no point.
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
only_next_1=$(git rev-list ^master "^$topic" ${publish} | sort)
|
||||
only_next_2=$(git rev-list ^master ${publish} | sort)
|
||||
if test "$only_next_1" = "$only_next_2"; then
|
||||
not_in_topic=$(git rev-list "^$topic" master)
|
||||
if test -z "$not_in_topic"; then
|
||||
echo >&2 "$topic is already up to date with master"
|
||||
exit 1 # we could allow it, but there is no point.
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
|
||||
/usr/bin/perl -e '
|
||||
not_in_next=$(git rev-list --pretty=oneline ^${publish} "$topic")
|
||||
/usr/bin/perl -e '
|
||||
my $topic = $ARGV[0];
|
||||
my $msg = "* $topic has commits already merged to public branch:\n";
|
||||
my (%not_in_next) = map {
|
||||
@@ -85,7 +81,7 @@ else
|
||||
}
|
||||
}
|
||||
' "$topic" "$not_in_next" "$not_in_master"
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
<<\DOC_END
|
||||
|
||||
@@ -6,19 +6,18 @@
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-receive".
|
||||
|
||||
if test -n "$GIT_PUSH_OPTION_COUNT"
|
||||
then
|
||||
i=0
|
||||
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"
|
||||
do
|
||||
eval "value=\$GIT_PUSH_OPTION_$i"
|
||||
case "$value" in
|
||||
echoback=*)
|
||||
echo "echo from the pre-receive-hook: ${value#*=}" >&2
|
||||
;;
|
||||
reject)
|
||||
exit 1
|
||||
esac
|
||||
i=$((i + 1))
|
||||
done
|
||||
if test -n "$GIT_PUSH_OPTION_COUNT"; then
|
||||
i=0
|
||||
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"; do
|
||||
eval "value=\$GIT_PUSH_OPTION_$i"
|
||||
case "$value" in
|
||||
echoback=*)
|
||||
echo "echo from the pre-receive-hook: ${value#*=}" >&2
|
||||
;;
|
||||
reject)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
i=$((i + 1))
|
||||
done
|
||||
fi
|
||||
|
||||
@@ -31,15 +31,15 @@ newrev="$3"
|
||||
|
||||
# --- Safety check
|
||||
if [ -z "$GIT_DIR" ]; then
|
||||
echo "Don't run this script from the command line." >&2
|
||||
echo " (if you want, you could supply GIT_DIR then run" >&2
|
||||
echo " $0 <ref> <oldrev> <newrev>)" >&2
|
||||
exit 1
|
||||
echo "Don't run this script from the command line." >&2
|
||||
echo " (if you want, you could supply GIT_DIR then run" >&2
|
||||
echo " $0 <ref> <oldrev> <newrev>)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
|
||||
echo "usage: $0 <ref> <oldrev> <newrev>" >&2
|
||||
exit 1
|
||||
echo "usage: $0 <ref> <oldrev> <newrev>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Config
|
||||
@@ -53,75 +53,74 @@ allowmodifytag=$(git config --bool hooks.allowmodifytag)
|
||||
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
|
||||
case "$projectdesc" in
|
||||
"Unnamed repository"* | "")
|
||||
echo "*** Project description file hasn't been set" >&2
|
||||
exit 1
|
||||
;;
|
||||
echo "*** Project description file hasn't been set" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# --- Check types
|
||||
# if $newrev is 0000...0000, it's a commit to delete a ref.
|
||||
zero="0000000000000000000000000000000000000000"
|
||||
if [ "$newrev" = "$zero" ]; then
|
||||
newrev_type=delete
|
||||
newrev_type=delete
|
||||
else
|
||||
newrev_type=$(git cat-file -t $newrev)
|
||||
newrev_type=$(git cat-file -t $newrev)
|
||||
fi
|
||||
|
||||
case "$refname","$newrev_type" in
|
||||
refs/tags/*,commit)
|
||||
# un-annotated tag
|
||||
short_refname=${refname##refs/tags/}
|
||||
if [ "$allowunannotated" != "true" ]; then
|
||||
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
|
||||
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/tags/*,delete)
|
||||
# delete tag
|
||||
if [ "$allowdeletetag" != "true" ]; then
|
||||
echo "*** Deleting a tag is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/tags/*,tag)
|
||||
# annotated tag
|
||||
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
|
||||
then
|
||||
echo "*** Tag '$refname' already exists." >&2
|
||||
echo "*** Modifying a tag is not allowed in this repository." >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/heads/*,commit)
|
||||
# branch
|
||||
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
|
||||
echo "*** Creating a branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/heads/*,delete)
|
||||
# delete branch
|
||||
if [ "$allowdeletebranch" != "true" ]; then
|
||||
echo "*** Deleting a branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/remotes/*,commit)
|
||||
# tracking branch
|
||||
;;
|
||||
refs/remotes/*,delete)
|
||||
# delete tracking branch
|
||||
if [ "$allowdeletebranch" != "true" ]; then
|
||||
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# Anything else (is there anything else?)
|
||||
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
|
||||
exit 1
|
||||
;;
|
||||
refs/tags/*,commit)
|
||||
# un-annotated tag
|
||||
short_refname=${refname##refs/tags/}
|
||||
if [ "$allowunannotated" != "true" ]; then
|
||||
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
|
||||
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/tags/*,delete)
|
||||
# delete tag
|
||||
if [ "$allowdeletetag" != "true" ]; then
|
||||
echo "*** Deleting a tag is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/tags/*,tag)
|
||||
# annotated tag
|
||||
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname >/dev/null 2>&1; then
|
||||
echo "*** Tag '$refname' already exists." >&2
|
||||
echo "*** Modifying a tag is not allowed in this repository." >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/heads/*,commit)
|
||||
# branch
|
||||
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
|
||||
echo "*** Creating a branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/heads/*,delete)
|
||||
# delete branch
|
||||
if [ "$allowdeletebranch" != "true" ]; then
|
||||
echo "*** Deleting a branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/remotes/*,commit)
|
||||
# tracking branch
|
||||
;;
|
||||
refs/remotes/*,delete)
|
||||
# delete tracking branch
|
||||
if [ "$allowdeletebranch" != "true" ]; then
|
||||
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# Anything else (is there anything else?)
|
||||
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# --- Finished
|
||||
|
||||
Binary file not shown.
@@ -1 +1,2 @@
|
||||
0000000000000000000000000000000000000000 6b833ad3b334f1ccf60e0bd27ff5781e618e79aa Marcin Grzejszczak <mgrzejszczak@pivotal.io> 1540290537 +0200 clone: from git@github.com:spring-cloud/spring-cloud-core-tests.git
|
||||
6b833ad3b334f1ccf60e0bd27ff5781e618e79aa aeef09d318e80a96a54332a3eccfa72d6cc56689 Marcin Grzejszczak <marcin@grzejszczak.pl> 1566838500 +0200 commit: Added script
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
0000000000000000000000000000000000000000 6b833ad3b334f1ccf60e0bd27ff5781e618e79aa Marcin Grzejszczak <mgrzejszczak@pivotal.io> 1540290537 +0200 clone: from git@github.com:spring-cloud/spring-cloud-core-tests.git
|
||||
6b833ad3b334f1ccf60e0bd27ff5781e618e79aa aeef09d318e80a96a54332a3eccfa72d6cc56689 Marcin Grzejszczak <marcin@grzejszczak.pl> 1566838500 +0200 commit: Added script
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
xmSAn<41>0<10><>|<7C>§$ph'-
|
||||
<EFBFBD><EFBFBD>Xq\Th`<03>S#GJZ<4A><5A>ȤJRQ<52> <>RV۸<56><0E><><EFBFBD><19><>RieR<65><52>\~|7>p3S<33>-<2D>[<0F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>~<7E>`<60>HZU<5A><1A>5<EFBFBD><35><EFBFBD><EFBFBD><EFBFBD><0B>[<5B>P;̡<>9<EFBFBD><14>*cl<63>3<EFBFBD><33>h
|
||||
<EFBFBD>r'<27>u<EFBFBD>o
|
||||
O<EFBFBD><02><>4<EFBFBD>S{<7B><>C<EFBFBD><43>9<EFBFBD>AA>eX{
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
x<01>U<EFBFBD>n1<10>5<EFBFBD><35>!B$v<>R$.ڦjI<6A>"<22><>J<EFBFBD>O<><4F>;I,ym<79><6D>&<26>|;c<>%!MQ<4D>x<EFBFBD><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD>93G<33><47>PS8|<7C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><10>Dc<44><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ePf*<2A>r~ܽ<><DCBD>1z<31>=<3D><1D><16><><EFBFBD><EFBFBD>t(6<><36><EFBFBD>&<26>a'<27>yϠV<CFA0>ՆJc<4A>҄Rᨤ<1E>
|
||||
<EFBFBD>=<3D><>r^<5E><07><>.<2E>^_M<06><><EFBFBD><EFBFBD><EFBFBD>{<7B><>5<EFBFBD>C3kW<6B><57><EFBFBD>:.O'<27>/<17>>u<>5<EFBFBD>IR<49><52><04>0<EFBFBD><30>F<46><CDB8>m<EFBFBD>QqzE<><45><EFBFBD>y|<16>[p<0B>1P<31><50>X<EFBFBD>
|
||||
<EFBFBD>S`K<><4B>q<EFBFBD>Z`2<>a`<60><>9<EFBFBD>H<15>`Ė(<28>(><3E><03><><11>|<7C>@"<22><>$u d<>(<<3C><><12><>`<60>J<1C>V<EFBFBD>i<EFBFBD>lf<6C>v<EFBFBD><76>X<EFBFBD><58>sPf<50>.@3<><33><EFBFBD>%<25>W<EFBFBD><57>[<5B>~<7E><><0B>l3<6C>A&<26>&芷]<5D>R<EFBFBD><52><15>ΓGn<47>~<7E><14><><EFBFBD>Ԁf<>,<1C><>^x<0E><><EFBFBD>pK;&I<><49>p~$q<><71><EFBFBD>^<5E>$&O<>DQ<44><51><EFBFBD>G<><47><04>%CI'
|
||||
<[<5B>q<EFBFBD>J<EFBFBD>zΔ<7A>&<26>YO<59><4F>n<EFBFBD>So;˝2<CB9D>Z4մ<34>u<EFBFBD><1F>Y<EFBFBD><59><EFBFBD>d<EFBFBD><64><EFBFBD>lK<6C><1A>='<27><>0<EFBFBD><14>tK'-<2D><>-<2D><><EFBFBD>}<7D><><EFBFBD><EFBFBD>D<EFBFBD><44>mq#<23>2&<26><>T_<54><5F>W։N<D689><4E>M<05><><EFBFBD><EFBFBD><EFBFBD>.Ov<4F><76>p_<70>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD>;<3B>)<29>w*mU<Db<44><62> <20>3&,-<2D><><EFBFBD>4(<28>ٻ%<25><><EFBFBD>{
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user