diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..ddda9782
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,24 @@
+root = true
+
+[*.java]
+indent_style = tab
+indent_size = 4
+continuation_indent_size = 8
+
+[*.groovy]
+indent_style = tab
+indent_size = 4
+continuation_indent_size = 8
+
+[*.xml]
+indent_style = tab
+indent_size = 4
+continuation_indent_size = 8
+
+[*.yml]
+indent_style = space
+indent_size = 2
+
+[*.yaml]
+indent_style = space
+indent_size = 2
diff --git a/.settings.xml b/.settings.xml
index 32e8266c..1261ef8f 100644
--- a/.settings.xml
+++ b/.settings.xml
@@ -1,73 +1,77 @@
-
-
- repo.spring.io
- ${env.CI_DEPLOY_USERNAME}
- ${env.CI_DEPLOY_PASSWORD}
-
-
-
-
-
- spring
- true
-
-
- spring-snapshots
- Spring Snapshots
- http://repo.spring.io/libs-snapshot-local
-
- true
-
-
-
- spring-milestones
- Spring Milestones
- http://repo.spring.io/libs-milestone-local
-
- false
-
-
-
- spring-releases
- Spring Releases
- http://repo.spring.io/release
-
- false
-
-
-
-
-
- spring-snapshots
- Spring Snapshots
- http://repo.spring.io/libs-snapshot-local
-
- true
-
-
-
- spring-milestones
- Spring Milestones
- http://repo.spring.io/libs-milestone-local
-
- false
-
-
-
-
-
-
- ide
- true
-
-
+
+
+ repo.spring.io
+ ${env.CI_DEPLOY_USERNAME}
+ ${env.CI_DEPLOY_PASSWORD}
+
+
+
+
+
+ spring
+
+ true
+
+
+
+ spring-snapshots
+ Spring Snapshots
+ http://repo.spring.io/libs-snapshot-local
+
+ true
+
+
+
+ spring-milestones
+ Spring Milestones
+ http://repo.spring.io/libs-milestone-local
+
+ false
+
+
+
+ spring-releases
+ Spring Releases
+ http://repo.spring.io/release
+
+ false
+
+
+
+
+
+ spring-snapshots
+ Spring Snapshots
+ http://repo.spring.io/libs-snapshot-local
+
+ true
+
+
+
+ spring-milestones
+ Spring Milestones
+ http://repo.spring.io/libs-milestone-local
+
+ false
+
+
+
+
+
+
+ ide
+
+ true
+
+
+
diff --git a/.springformat b/.springformat
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/.springformat
@@ -0,0 +1 @@
+
diff --git a/docs/pom.xml b/docs/pom.xml
index 74acef4d..9de368b3 100644
--- a/docs/pom.xml
+++ b/docs/pom.xml
@@ -1,6 +1,6 @@
-
+
4.0.0
org.springframework.cloud.internal
diff --git a/pom.xml b/pom.xml
index 4a3e9c45..ae1bc2da 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,6 +1,6 @@
-
4.0.0
@@ -12,7 +12,7 @@
org.springframework.cloud
spring-cloud-build
- 2.1.2.RELEASE
+ 2.1.3.BUILD-SNAPSHOT
@@ -24,7 +24,13 @@
- Greenwich.RELEASE
+ Greenwich.BUILD-SNAPSHOT
+
+ true
+ true
+
+ true
+
@@ -39,6 +45,28 @@
+
+
+
+ io.spring.javaformat
+ spring-javaformat-maven-plugin
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+
+
+
spring-snapshots
diff --git a/spring-cloud-release-tools-core/pom.xml b/spring-cloud-release-tools-core/pom.xml
index 2b1b3783..1a963a11 100644
--- a/spring-cloud-release-tools-core/pom.xml
+++ b/spring-cloud-release-tools-core/pom.xml
@@ -1,6 +1,6 @@
-
4.0.0
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/Releaser.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/Releaser.java
index 99e1a4e6..89ea0c9e 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/Releaser.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/Releaser.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal;
import java.io.File;
@@ -22,24 +54,34 @@ import org.springframework.util.Assert;
* @author Marcin Grzejszczak
*/
public class Releaser {
+
private static final Logger log = LoggerFactory.getLogger(Releaser.class);
private static boolean ASSERT_SNAPSHOTS = true;
+
private static boolean SKIP_SNAPSHOT_ASSERTION = false;
private final ProjectPomUpdater projectPomUpdater;
+
private final ProjectBuilder projectBuilder;
+
private final ProjectGitHandler projectGitHandler;
+
private final TemplateGenerator templateGenerator;
+
private final GradleUpdater gradleUpdater;
+
private final SaganUpdater saganUpdater;
+
private final DocumentationUpdater documentationUpdater;
+
private final PostReleaseActions postReleaseActions;
public Releaser(ProjectPomUpdater projectPomUpdater, ProjectBuilder projectBuilder,
ProjectGitHandler projectGitHandler, TemplateGenerator templateGenerator,
GradleUpdater gradleUpdater, SaganUpdater saganUpdater,
- DocumentationUpdater documentationUpdater, PostReleaseActions postReleaseActions) {
+ DocumentationUpdater documentationUpdater,
+ PostReleaseActions postReleaseActions) {
this.projectPomUpdater = projectPomUpdater;
this.projectBuilder = projectBuilder;
this.projectGitHandler = projectGitHandler;
@@ -71,8 +113,8 @@ public class Releaser {
ProjectVersion versionFromScRelease, boolean assertSnapshots) {
this.projectPomUpdater.updateProjectFromReleaseTrain(project, versions,
versionFromScRelease, assertSnapshots);
- this.gradleUpdater.updateProjectFromBom(project, versions,
- versionFromScRelease, assertSnapshots);
+ this.gradleUpdater.updateProjectFromBom(project, versions, versionFromScRelease,
+ assertSnapshots);
ProjectVersion changedVersion = new ProjectVersion(project);
log.info("\n\nProject was successfully updated to [{}]", changedVersion);
}
@@ -97,7 +139,8 @@ public class Releaser {
log.info("\nThe docs were published successfully");
}
- public void rollbackReleaseVersion(File project, Projects projects, ProjectVersion scReleaseVersion) {
+ public void rollbackReleaseVersion(File project, Projects projects,
+ ProjectVersion scReleaseVersion) {
if (scReleaseVersion.isSnapshot()) {
log.info("\nWon't rollback a snapshot version");
return;
@@ -105,15 +148,17 @@ public class Releaser {
this.projectGitHandler.revertChangesIfApplicable(project, scReleaseVersion);
ProjectVersion originalVersion = originalVersion(project);
log.info("Original project version is [{}]", originalVersion);
- if ((scReleaseVersion.isRelease() || scReleaseVersion
- .isServiceRelease()) && originalVersion.isSnapshot()) {
+ if ((scReleaseVersion.isRelease() || scReleaseVersion.isServiceRelease())
+ && originalVersion.isSnapshot()) {
Projects newProjects = Projects.forRollback(projects, originalVersion);
- updateProjectFromBom(project, newProjects, originalVersion, SKIP_SNAPSHOT_ASSERTION);
+ updateProjectFromBom(project, newProjects, originalVersion,
+ SKIP_SNAPSHOT_ASSERTION);
this.projectGitHandler.commitAfterBumpingVersions(project, originalVersion);
log.info("\nSuccessfully reverted the commit and bumped snapshot versions");
}
else {
- log.info("\nSuccessfully reverted the commit and came back to snapshot versions");
+ log.info(
+ "\nSuccessfully reverted the commit and came back to snapshot versions");
}
}
@@ -134,14 +179,17 @@ public class Releaser {
try {
this.projectGitHandler.closeMilestone(releaseVersion);
log.info("\nSuccessfully closed milestone");
- } catch (Exception ex) {
+ }
+ catch (Exception ex) {
throw new MakeBuildUnstableException("Failed to create an email template");
}
}
public void createEmail(ProjectVersion releaseVersion, Projects projects) {
- Assert.notNull(releaseVersion, "You must provide a release version for your project");
- Assert.notNull(releaseVersion.version, "You must provide a release version for your project");
+ Assert.notNull(releaseVersion,
+ "You must provide a release version for your project");
+ Assert.notNull(releaseVersion.version,
+ "You must provide a release version for your project");
if (releaseVersion.isSnapshot()) {
log.info("\nWon't create email template for a SNAPSHOT version");
return;
@@ -152,11 +200,13 @@ public class Releaser {
log.info("\nSuccessfully created email template at location [{}]", email);
}
else {
- throw new MakeBuildUnstableException("Failed to create an email template");
+ throw new MakeBuildUnstableException(
+ "Failed to create an email template");
}
}
catch (Exception ex) {
- throw new MakeBuildUnstableException("Failed to create an email template", ex);
+ throw new MakeBuildUnstableException("Failed to create an email template",
+ ex);
}
}
@@ -181,14 +231,16 @@ public class Releaser {
public void updateSpringGuides(ProjectVersion releaseVersion, Projects projects) {
if (!(releaseVersion.isRelease() || releaseVersion.isServiceRelease())) {
- log.info("\nWon't update Spring Guides for a non Release / Service Release version");
+ log.info(
+ "\nWon't update Spring Guides for a non Release / Service Release version");
return;
}
try {
this.projectGitHandler.createIssueInSpringGuides(projects, releaseVersion);
}
catch (Exception ex) {
- throw new MakeBuildUnstableException("Successfully updated Spring Guides issues", ex);
+ throw new MakeBuildUnstableException(
+ "Successfully updated Spring Guides issues", ex);
}
}
@@ -237,10 +289,12 @@ public class Releaser {
}
}
- public void updateDocumentationRepository(ReleaserProperties properties, ProjectVersion releaseVersion) {
+ public void updateDocumentationRepository(ReleaserProperties properties,
+ ProjectVersion releaseVersion) {
String releaseBranch = properties.getPom().getBranch();
this.documentationUpdater.updateDocsRepo(releaseVersion, releaseBranch);
- log.info("\nSuccessfully updated documentation repository for branch [{}]", releaseBranch);
+ log.info("\nSuccessfully updated documentation repository for branch [{}]",
+ releaseBranch);
}
public void updateSpringProjectPage(Projects projects) {
@@ -271,4 +325,5 @@ public class Releaser {
this.documentationUpdater.updateReleaseTrainWiki(projects);
log.info("\nSuccessfully updated project wiki");
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserProperties.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserProperties.java
index 18c82d71..7f0f0f67 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserProperties.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserProperties.java
@@ -1,18 +1,35 @@
/*
- * Copyright 2013-2019 the original author or authors.
+ * 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
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * 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.
*/
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal;
import java.io.Serializable;
@@ -29,8 +46,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.StringUtils;
/**
- * Since, we are making a deep copy of this object, remember to have all the
- * nested classes to implement the Serializable interface.
+ * Since, we are making a deep copy of this object, remember to have all the nested
+ * classes to implement the Serializable interface.
*
* @author Marcin Grzejszczak
*/
@@ -44,7 +61,7 @@ public class ReleaserProperties implements Serializable {
private String workingDir;
/**
- * If set to {@code true} will run only post release tasks
+ * If set to {@code true} will run only post release tasks.
*/
private boolean postReleaseTasksOnly = false;
@@ -61,40 +78,133 @@ public class ReleaserProperties implements Serializable {
private Template template = new Template();
/**
- * 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 repository
+ * like Spring Cloud Release.
*/
private Map fixedVersions = new LinkedHashMap<>();
private MetaRelease metaRelease = new MetaRelease();
+ public String getWorkingDir() {
+ return StringUtils.hasText(this.workingDir) ? this.workingDir
+ : System.getProperty("user.dir");
+ }
+
+ public void setWorkingDir(String workingDir) {
+ this.workingDir = workingDir;
+ }
+
+ public Git getGit() {
+ return this.git;
+ }
+
+ public void setGit(Git git) {
+ this.git = git;
+ }
+
+ public Pom getPom() {
+ return this.pom;
+ }
+
+ public void setPom(Pom pom) {
+ this.pom = pom;
+ }
+
+ public Maven getMaven() {
+ return this.maven;
+ }
+
+ public void setMaven(Maven maven) {
+ this.maven = maven;
+ }
+
+ public Gradle getGradle() {
+ return this.gradle;
+ }
+
+ public void setGradle(Gradle gradle) {
+ this.gradle = gradle;
+ }
+
+ public Map getFixedVersions() {
+ return this.fixedVersions;
+ }
+
+ public void setFixedVersions(Map fixedVersions) {
+ this.fixedVersions = fixedVersions;
+ }
+
+ public MetaRelease getMetaRelease() {
+ return this.metaRelease;
+ }
+
+ public void setMetaRelease(MetaRelease metaRelease) {
+ this.metaRelease = metaRelease;
+ }
+
+ public Sagan getSagan() {
+ return this.sagan;
+ }
+
+ public void setSagan(Sagan sagan) {
+ this.sagan = sagan;
+ }
+
+ public Template getTemplate() {
+ return this.template;
+ }
+
+ public void setTemplate(Template template) {
+ this.template = template;
+ }
+
+ public boolean isPostReleaseTasksOnly() {
+ return this.postReleaseTasksOnly;
+ }
+
+ public void setPostReleaseTasksOnly(boolean postReleaseTasksOnly) {
+ this.postReleaseTasksOnly = postReleaseTasksOnly;
+ }
+
+ @Override
+ public String toString() {
+ return "ReleaserProperties{" + "workingDir='" + this.workingDir + '\'' + ", git="
+ + this.git + ", pom=" + this.pom + ", maven=" + this.maven + ", gradle="
+ + this.gradle + ", sagan=" + this.sagan + ", fixedVersions="
+ + this.fixedVersions + ", metaRelease=" + this.metaRelease + ", template="
+ + this.template + '}';
+ }
+
+ public ReleaserProperties copy() {
+ return (ReleaserProperties) SerializationUtils.clone(this);
+ }
+
public static class MetaRelease implements Serializable {
+
/**
* Are we releasing the whole suite of apps or only one?
*/
private boolean enabled = false;
/**
- * Name of the release train project
+ * Name of the release train project.
*/
private String releaseTrainProjectName = "spring-cloud-release";
/**
- * All the names of dependencies that should be updated with the release
- * train project version
+ * All the names of dependencies that should be updated with the release train
+ * project version.
*/
- private List releaseTrainDependencyNames = Arrays.asList(
- "spring-cloud", "spring-cloud-dependencies", "spring-cloud-starter"
- );
+ private List releaseTrainDependencyNames = Arrays.asList("spring-cloud",
+ "spring-cloud-dependencies", "spring-cloud-starter");
/**
- * The URL of the Git organization. We'll append each project's
- * name to it
+ * The URL of the Git organization. We'll append each project's name to it.
*/
private String gitOrgUrl = "https://github.com/spring-cloud";
/**
- * Names of projects to skip deployment for meta-release
+ * Names of projects to skip deployment for meta-release.
*/
private List projectsToSkip = new ArrayList() {
{
@@ -132,7 +242,8 @@ public class ReleaserProperties implements Serializable {
return this.releaseTrainDependencyNames;
}
- public void setReleaseTrainDependencyNames(List releaseTrainDependencyNames) {
+ public void setReleaseTrainDependencyNames(
+ List releaseTrainDependencyNames) {
this.releaseTrainDependencyNames = releaseTrainDependencyNames;
}
@@ -146,101 +257,102 @@ public class ReleaserProperties implements Serializable {
@Override
public String toString() {
- return "MetaRelease{" +
- "enabled=" + this.enabled +
- ", releaseTrainProjectName='" + this.releaseTrainProjectName + '\'' +
- ", gitOrgUrl='" + this.gitOrgUrl + '\'' +
- ", projectsToSkip=" + this.projectsToSkip +
- '}';
+ return "MetaRelease{" + "enabled=" + this.enabled
+ + ", releaseTrainProjectName='" + this.releaseTrainProjectName + '\''
+ + ", gitOrgUrl='" + this.gitOrgUrl + '\'' + ", projectsToSkip="
+ + this.projectsToSkip + '}';
}
+
}
public static class Git implements Serializable {
/**
- * URL to Spring Cloud Release Git repository
+ * URL to Spring Cloud Release Git repository.
*/
private String releaseTrainBomUrl = "https://github.com/spring-cloud/spring-cloud-release";
/**
- * URL to the documentation Git repository
+ * URL to the documentation Git repository.
*/
private String documentationUrl = "https://github.com/spring-cloud/spring-cloud-static";
/**
- * URL to main release train project repository
+ * URL to main release train project repository.
*/
private String springProjectUrl = "https://github.com/spring-projects/spring-cloud";
/**
- * URL to test samples
+ * URL to test samples.
*/
private String testSamplesProjectUrl = "https://github.com/spring-cloud/spring-cloud-core-tests";
/**
- * URL to the release train documentation
+ * URL to the release train documentation.
*/
private String releaseTrainDocsUrl = "https://github.com/spring-cloud-samples/scripts";
/**
- * URL to the release train wiki
+ * URL to the release train wiki.
*/
private String releaseTrainWikiUrl = "https://github.com/spring-projects/spring-cloud.wiki";
/**
- * Branch to check out for the documentation project
+ * Branch to check out for the documentation project.
*/
private String documentationBranch = "gh-pages";
/**
- * Branch to check out for the release train project
+ * Branch to check out for the release train project.
*/
private String springProjectBranch = "gh-pages";
/**
- * Branch to check out for the test samples
+ * Branch to check out for the test samples.
*/
private String testSamplesBranch = "master";
/**
- * Branch to check out for the release train docs
+ * Branch to check out for the release train docs.
*/
private String releaseTrainDocsBranch = "master";
/**
- * Page prefix for the release train wiki. E.g. for [Spring-Cloud-Finchley-Release-Notes]
- * it would be [Spring-Cloud].
+ * Page prefix for the release train wiki. E.g. for
+ * [Spring-Cloud-Finchley-Release-Notes] it would be [Spring-Cloud].
*/
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 Spring Cloud Release repo get cloned to. If {@code null}
+ * defaults to a temporary directory.
*/
private String cloneDestinationDir;
/**
- * If {@code true} then should fill the map of versions from Git. If {@code false} then picks fixed versions
+ * If {@code true} then should fill the map of versions from Git. If {@code false}
+ * then picks fixed versions.
*/
private boolean fetchVersionsFromGit = true;
/**
- * GitHub OAuth token to be used to interact with GitHub repo
+ * GitHub OAuth token to be used to interact with GitHub repo.
*/
private String oauthToken = "";
/**
- * Optional Git username. If not passed keys will be used for authentication
+ * Optional Git username. If not passed keys will be used for authentication.
*/
private String username;
/**
- * Optional Git password. If not passed keys will be used for authentication
+ * Optional Git password. If not passed keys will be used for authentication.
*/
private String password;
/**
- * In order not to iterate endlessly over milestones we introduce a threshold of milestones
- * that we will go through to find the matching milestone
+ * In order not to iterate endlessly over milestones we introduce a threshold of
+ * milestones that we will go through to find the matching milestone.
*/
private Integer numberOfCheckedMilestones = 50;
@@ -255,28 +367,29 @@ public class ReleaserProperties implements Serializable {
private boolean updateSpringGuides = true;
/**
- * If set to {@code false}, will not update the Spring Project for a release train.
- * E.g. for Spring Cloud will not update https://cloud.spring.io
+ * If set to {@code false}, will not update the Spring Project for a release
+ * train. E.g. for Spring Cloud will not update https://cloud.spring.io .
*/
private boolean updateSpringProject = true;
/**
- * If set to {@code false}, will not update the test samples
+ * If set to {@code false}, will not update the test samples.
*/
private boolean runUpdatedSamples = true;
/**
- * If set to {@code false}, will not update the release train docs
+ * If set to {@code false}, will not update the release train docs.
*/
private boolean updateReleaseTrainDocs = true;
/**
- * If set to {@code false}, will not clone and update the release train wiki
+ * If set to {@code false}, will not clone and update the release train wiki.
*/
private boolean updateReleaseTrainWiki = true;
/**
- * If set to {@code false}, will not clone and update the samples for all projects
+ * If set to {@code false}, will not clone and update the samples for all
+ * projects.
*/
private boolean updateAllTestSamples = true;
@@ -286,15 +399,13 @@ public class ReleaserProperties implements Serializable {
*/
private Map> allTestSampleUrls = new HashMap>() {
{
- this.put("spring-cloud-sleuth" , Arrays.asList(
+ this.put("spring-cloud-sleuth", Arrays.asList(
"https://github.com/spring-cloud-samples/sleuth-issues",
- "https://github.com/spring-cloud-samples/sleuth-documentation-apps")
- );
- this.put("spring-cloud-contract" , Arrays.asList(
+ "https://github.com/spring-cloud-samples/sleuth-documentation-apps"));
+ this.put("spring-cloud-contract", Arrays.asList(
"https://github.com/spring-cloud-samples/spring-cloud-contract-samples",
"https://github.com/spring-cloud-samples/the-legacy-app",
- "https://github.com/spring-cloud-samples/sc-contract-car-rental")
- );
+ "https://github.com/spring-cloud-samples/sc-contract-car-rental"));
}
};
@@ -366,6 +477,10 @@ public class ReleaserProperties implements Serializable {
return this.runUpdatedSamples;
}
+ public void setRunUpdatedSamples(boolean runUpdatedSamples) {
+ this.runUpdatedSamples = runUpdatedSamples;
+ }
+
public boolean isUpdateAllTestSamples() {
return this.updateAllTestSamples;
}
@@ -374,10 +489,6 @@ public class ReleaserProperties implements Serializable {
this.updateAllTestSamples = updateAllTestSamples;
}
- public void setRunUpdatedSamples(boolean runUpdatedSamples) {
- this.runUpdatedSamples = runUpdatedSamples;
- }
-
public String getCloneDestinationDir() {
return this.cloneDestinationDir;
}
@@ -500,57 +611,57 @@ public class ReleaserProperties implements Serializable {
@Override
public String toString() {
- return "Git{" +
- "releaseTrainBomUrl='" + this.releaseTrainBomUrl + '\'' +
- ", documentationUrl='" + this.documentationUrl + '\'' +
- ", documentationBranch='" + this.documentationBranch + '\'' +
- ", releaseTrainWikiUrl='" + this.releaseTrainWikiUrl + '\'' +
- ", updateDocumentationRepo=" + this.updateDocumentationRepo +
- ", springProjectUrl=" + this.springProjectUrl+
- ", springProjectBranch=" + this.springProjectBranch +
- ", releaseTrainWikiPagePrefix=" + this.releaseTrainWikiPagePrefix +
- ", cloneDestinationDir='" + this.cloneDestinationDir + '\'' +
- ", fetchVersionsFromGit=" + this.fetchVersionsFromGit +
- ", numberOfCheckedMilestones=" + this.numberOfCheckedMilestones +
- ", updateSpringGuides=" + this.updateSpringGuides +
- ", updateSpringProject=" + this.updateSpringProject +
- ", sampleUrlsSize=" + this.allTestSampleUrls.size() +
- '}';
+ return "Git{" + "releaseTrainBomUrl='" + this.releaseTrainBomUrl + '\''
+ + ", documentationUrl='" + this.documentationUrl + '\''
+ + ", documentationBranch='" + this.documentationBranch + '\''
+ + ", releaseTrainWikiUrl='" + this.releaseTrainWikiUrl + '\''
+ + ", updateDocumentationRepo=" + this.updateDocumentationRepo
+ + ", springProjectUrl=" + this.springProjectUrl
+ + ", springProjectBranch=" + this.springProjectBranch
+ + ", releaseTrainWikiPagePrefix=" + this.releaseTrainWikiPagePrefix
+ + ", cloneDestinationDir='" + this.cloneDestinationDir + '\''
+ + ", fetchVersionsFromGit=" + this.fetchVersionsFromGit
+ + ", numberOfCheckedMilestones=" + this.numberOfCheckedMilestones
+ + ", updateSpringGuides=" + this.updateSpringGuides
+ + ", updateSpringProject=" + this.updateSpringProject
+ + ", sampleUrlsSize=" + this.allTestSampleUrls.size() + '}';
}
+
}
public static class Pom implements Serializable {
/**
- * Which branch of release train BOM should be checked out. Defaults to {@code master}
+ * Which branch of release train BOM should be checked out. Defaults to
+ * {@code master}.
*/
private String branch = "master";
/**
- * Subfolder of the pom that contains the {@code spring-boot-starer-parent} dependency
+ * Subfolder of the pom that contains the {@code spring-boot-starer-parent}
+ * dependency.
*/
private String pomWithBootStarterParent = "spring-cloud-starter-parent/pom.xml";
/**
- * Subfolder of the pom that contains the versions for the release train
+ * Subfolder of the pom that contains the versions for the release train.
*/
private String thisTrainBom = "spring-cloud-dependencies/pom.xml";
/**
- * The pattern to match a version property in a BOM
+ * The pattern to match a version property in a BOM.
*/
private String bomVersionPattern = "^(spring-cloud-.*)\\.version$";
/**
- * List of regular expressions of ignored poms. Defaults to test projects and samples.
+ * List of regular expressions of ignored poms. Defaults to test projects and
+ * samples.
*/
@SuppressWarnings("unchecked")
- private List ignoredPomRegex = Arrays.asList(
- "^.*\\.git/.*$",
+ private List ignoredPomRegex = Arrays.asList("^.*\\.git/.*$",
"^.*spring-cloud-contract-maven-plugin/src/test/projects/.*$",
"^.*spring-cloud-contract-maven-plugin/target/.*$",
- "^.*samples/standalone/[a-z]+/.*$"
- );
+ "^.*samples/standalone/[a-z]+/.*$");
public String getBranch() {
return this.branch;
@@ -594,54 +705,57 @@ public class ReleaserProperties implements Serializable {
@Override
public String toString() {
- return "Pom{" +
- "branch='" + this.branch + '\'' +
- ", pomWithBootStarterParent='" + this.pomWithBootStarterParent + '\'' +
- ", thisTrainBom='" + this.thisTrainBom + '\'' +
- ", bomVersionPattern='" + this.bomVersionPattern + '\'' +
- ", ignoredPomRegex=" + this.ignoredPomRegex +
- '}';
+ return "Pom{" + "branch='" + this.branch + '\''
+ + ", pomWithBootStarterParent='" + this.pomWithBootStarterParent
+ + '\'' + ", thisTrainBom='" + this.thisTrainBom + '\''
+ + ", bomVersionPattern='" + this.bomVersionPattern + '\''
+ + ", ignoredPomRegex=" + this.ignoredPomRegex + '}';
}
+
}
public static class Maven implements Serializable {
/**
- * Command to be executed to build the project
+ * Placeholder for system properties.
+ */
+ public static final String SYSTEM_PROPS_PLACEHOLDER = "{{systemProps}}";
+
+ /**
+ * Command to be executed to build the project.
*/
private String buildCommand = "./mvnw clean install -B -Pdocs {{systemProps}}";
/**
- * Command to be executed to deploy a built project
+ * Command to be executed to deploy a built project.
*/
private String deployCommand = "./mvnw deploy -DskipTests -B -Pfast,deploy {{systemProps}}";
/**
- * Command to be executed to publish documentation. If present "{{version}}" will be replaced by the
- * provided version
+ * Command to be executed to publish documentation. If present "{{version}}" will
+ * be replaced by the provided version.
*/
- private String[] publishDocsCommands = {
- "mkdir -p target",
- "wget https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/ghpages.sh -O target/gh-pages.sh",
- "chmod +x target/gh-pages.sh",
- "./target/gh-pages.sh -v {{version}} -c"
- };
+ private String[] publishDocsCommands = { "mkdir -p target",
+ "wget https://raw.githubusercontent.com/spring-cloud/"
+ + "spring-cloud-build/master/"
+ + "docs/src/main/asciidoc/ghpages.sh -O target/gh-pages.sh",
+ "chmod +x target/gh-pages.sh", "./target/gh-pages.sh -v {{version}} -c" };
/**
- * Command to be executed to generate release train documentation
+ * Command to be executed to generate release train documentation.
*/
- private String generateReleaseTrainDocsCommand = "bash release_train.sh --retrieveversions --version {{version}} --ghpages --auto";
-
- public static final String SYSTEM_PROPS_PLACEHOLDER = "{{systemProps}}";
+ private String generateReleaseTrainDocsCommand = "bash release_train.sh "
+ + "--retrieveversions --version {{version}} --ghpages --auto";
/**
- * Additional system properties that should be passed to the build / deploy commands.
- * If present in other commands "{{systemProps}}" will be substituted with this property.
+ * 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
+ * Max wait time in minutes for the process to finish.
*/
private long waitTimeInMinutes = 20;
@@ -673,18 +787,19 @@ public class ReleaserProperties implements Serializable {
return this.publishDocsCommands;
}
+ public void setPublishDocsCommands(String[] publishDocsCommands) {
+ this.publishDocsCommands = publishDocsCommands;
+ }
+
public String getGenerateReleaseTrainDocsCommand() {
return this.generateReleaseTrainDocsCommand;
}
- public void setGenerateReleaseTrainDocsCommand(String generateReleaseTrainDocsCommand) {
+ public void setGenerateReleaseTrainDocsCommand(
+ String generateReleaseTrainDocsCommand) {
this.generateReleaseTrainDocsCommand = generateReleaseTrainDocsCommand;
}
- public void setPublishDocsCommands(String[] publishDocsCommands) {
- this.publishDocsCommands = publishDocsCommands;
- }
-
public String getSystemProperties() {
return this.systemProperties;
}
@@ -693,26 +808,29 @@ public class ReleaserProperties implements Serializable {
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 + '}';
+ @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 {
/**
- * 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 {@code gradle.properties} to the projects name. Example
+ * 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
+ * {@code gradle.properties} to the projects name. Example.
*
- * In {@code gradle.properties} you have {@code verifierVersion=1.0.0} . You
- * want this property to get updated with the value of {@code spring-cloud-contract}
- * version. Then it's enough to do the mapping like this for this Releaser's property:
- * {@code verifierVersion=spring-cloud-contract}
+ * In {@code gradle.properties} you have {@code verifierVersion=1.0.0} . You want
+ * this property to get updated with the value of {@code spring-cloud-contract}
+ * version. Then it's enough to do the mapping like this for this Releaser's
+ * property: {@code verifierVersion=spring-cloud-contract}.
*/
private Map gradlePropsSubstitution = new HashMap() {
{
@@ -725,15 +843,14 @@ public class ReleaserProperties implements Serializable {
};
/**
- * List of regular expressions of ignored gradle props.
- * Defaults to test projects and samples.
+ * List of regular expressions of ignored gradle props. Defaults to test projects
+ * and samples.
*/
@SuppressWarnings("unchecked")
private List ignoredGradleRegex = Arrays.asList(
"^.*spring-cloud-contract-maven-plugin/src/test/projects/.*$",
"^.*spring-cloud-contract-maven-plugin/target/.*$",
- "^.*samples/standalone/[a-z]+/.*$"
- );
+ "^.*samples/standalone/[a-z]+/.*$");
public Map getGradlePropsSubstitution() {
return this.gradlePropsSubstitution;
@@ -752,21 +869,23 @@ public class ReleaserProperties implements Serializable {
this.ignoredGradleRegex = ignoredGradleRegex;
}
- @Override public String toString() {
+ @Override
+ public String toString() {
return "Gradle{" + "gradlePropsSubstitution=" + this.gradlePropsSubstitution
+ ", ignoredGradleRegex=" + this.ignoredGradleRegex + '}';
}
+
}
public static class Sagan implements Serializable {
/**
- * If set to {@code false} will not update Sagan
+ * If set to {@code false} will not update Sagan.
*/
private boolean updateSagan = true;
/**
- * URL to the Sagan API
+ * URL to the Sagan API.
*/
private String baseUrl = "https://spring.io";
@@ -786,14 +905,17 @@ public class ReleaserProperties implements Serializable {
this.updateSagan = updateSagan;
}
- @Override public String toString() {
+ @Override
+ public String toString() {
return "Sagan{" + "baseUrl='" + this.baseUrl + '\'' + '}';
}
+
}
public static class Template implements Serializable {
+
/**
- * Folder in which blog, email etc. templates are stored
+ * Folder in which blog, email etc. templates are stored.
*/
private String templateFolder = "cloud";
@@ -807,101 +929,9 @@ public class ReleaserProperties implements Serializable {
@Override
public String toString() {
- return "Template{" +
- "templateFolder='" + this.templateFolder + '\'' +
- '}';
+ return "Template{" + "templateFolder='" + this.templateFolder + '\'' + '}';
}
+
}
- public String getWorkingDir() {
- return StringUtils.hasText(this.workingDir) ?
- this.workingDir : System.getProperty("user.dir");
- }
-
- public void setWorkingDir(String workingDir) {
- this.workingDir = workingDir;
- }
-
- public Git getGit() {
- return this.git;
- }
-
- public void setGit(Git git) {
- this.git = git;
- }
-
- public Pom getPom() {
- return this.pom;
- }
-
- public void setPom(Pom pom) {
- this.pom = pom;
- }
-
- public Maven getMaven() {
- return this.maven;
- }
-
- public void setMaven(Maven maven) {
- this.maven = maven;
- }
-
- public Gradle getGradle() {
- return this.gradle;
- }
-
- public void setGradle(Gradle gradle) {
- this.gradle = gradle;
- }
-
- public Map getFixedVersions() {
- return this.fixedVersions;
- }
-
- public void setFixedVersions(Map fixedVersions) {
- this.fixedVersions = fixedVersions;
- }
-
- public MetaRelease getMetaRelease() {
- return this.metaRelease;
- }
-
- public void setMetaRelease(MetaRelease metaRelease) {
- this.metaRelease = metaRelease;
- }
-
- public Sagan getSagan() {
- return this.sagan;
- }
-
- public void setSagan(Sagan sagan) {
- this.sagan = sagan;
- }
-
- public Template getTemplate() {
- return this.template;
- }
-
- public void setTemplate(Template template) {
- this.template = template;
- }
-
- public boolean isPostReleaseTasksOnly() {
- return this.postReleaseTasksOnly;
- }
-
- public void setPostReleaseTasksOnly(boolean postReleaseTasksOnly) {
- this.postReleaseTasksOnly = postReleaseTasksOnly;
- }
-
- @Override public String toString() {
- return "ReleaserProperties{" + "workingDir='" + this.workingDir + '\'' + ", git=" + this.git
- + ", pom=" + this.pom + ", maven=" + this.maven + ", gradle=" + this.gradle + ", sagan="
- + this.sagan + ", fixedVersions=" + this.fixedVersions + ", metaRelease="
- + this.metaRelease + ", template=" + this.template + '}';
- }
-
- public ReleaserProperties copy() {
- return (ReleaserProperties) SerializationUtils.clone(this);
- }
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserPropertiesAware.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserPropertiesAware.java
index 99b0c251..55256c65 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserPropertiesAware.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/ReleaserPropertiesAware.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal;
/**
@@ -6,4 +38,5 @@ package org.springframework.cloud.release.internal;
public interface ReleaserPropertiesAware {
void setReleaserProperties(ReleaserProperties properties);
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/DocumentationUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/DocumentationUpdater.java
index 8966db2c..98032d1e 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/DocumentationUpdater.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/DocumentationUpdater.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.docs;
import java.io.File;
@@ -15,18 +47,22 @@ import org.springframework.cloud.release.internal.template.TemplateGenerator;
public class DocumentationUpdater implements ReleaserPropertiesAware {
private final ProjectDocumentationUpdater projectDocumentationUpdater;
+
private final ReleaseTrainContentsUpdater releaseTrainContentsUpdater;
+
private ReleaserProperties properties;
- public DocumentationUpdater(ProjectGitHandler gitHandler, ReleaserProperties properties,
- TemplateGenerator templateGenerator) {
+ public DocumentationUpdater(ProjectGitHandler gitHandler,
+ ReleaserProperties properties, TemplateGenerator templateGenerator) {
this.properties = properties;
- this.projectDocumentationUpdater = new ProjectDocumentationUpdater(this.properties, gitHandler);
- this.releaseTrainContentsUpdater = new ReleaseTrainContentsUpdater(this.properties, gitHandler,
- templateGenerator);
+ this.projectDocumentationUpdater = new ProjectDocumentationUpdater(
+ this.properties, gitHandler);
+ this.releaseTrainContentsUpdater = new ReleaseTrainContentsUpdater(
+ this.properties, gitHandler, templateGenerator);
}
- DocumentationUpdater(ReleaserProperties properties, ProjectDocumentationUpdater updater,
+ DocumentationUpdater(ReleaserProperties properties,
+ ProjectDocumentationUpdater updater,
ReleaseTrainContentsUpdater contentsUpdater) {
this.properties = properties;
this.projectDocumentationUpdater = updater;
@@ -34,34 +70,34 @@ public class DocumentationUpdater implements ReleaserPropertiesAware {
}
/**
- * Updates the documentation repository if current release train version is greater or equal
- * than the one stored in the repo.
- *
- * @param currentProject
- * @param springCloudReleaseBranch
- * @return {@link File cloned temporary directory} - {@code null} if wrong version is used
+ * Updates the documentation repository if current release train version is greater or
+ * equal than the one stored in the repo.
+ * @param currentProject the project we're parsing
+ * @param bomReleaseBranch branch of the BOM
+ * @return {@link File cloned temporary directory} - {@code null} if wrong version is
+ * used
*/
- public File updateDocsRepo(ProjectVersion currentProject, String springCloudReleaseBranch) {
- return this.projectDocumentationUpdater
- .updateDocsRepo(currentProject, springCloudReleaseBranch);
+ public File updateDocsRepo(ProjectVersion currentProject, String bomReleaseBranch) {
+ return this.projectDocumentationUpdater.updateDocsRepo(currentProject,
+ bomReleaseBranch);
}
/**
- * Updates the project page if current release train version is greater or equal
- * than the one stored in the repo.
- *
- * @param projects
- * @return {@link File cloned temporary directory} - {@code null} if wrong version is used or the switch is turned off
+ * Updates the project page if current release train version is greater or equal than
+ * the one stored in the repo.
+ * @param projects list of projects to update versions for
+ * @return {@link File cloned temporary directory} - {@code null} if wrong version is
+ * used or the switch is turned off
*/
public File updateProjectRepo(Projects projects) {
return this.releaseTrainContentsUpdater.updateProjectRepo(projects);
}
/**
- * Updates the release train wiki page
- *
- * @param projects
- * @return {@link File cloned temporary directory} - {@code null} if wrong version is used or the switch is turned off
+ * Updates the release train wiki page.
+ * @param projects list of projects to update versions for
+ * @return {@link File cloned temporary directory} - {@code null} if wrong version is
+ * used or the switch is turned off
*/
public File updateReleaseTrainWiki(Projects projects) {
return this.releaseTrainContentsUpdater.updateReleaseTrainWiki(projects);
@@ -73,4 +109,5 @@ public class DocumentationUpdater implements ReleaserPropertiesAware {
this.projectDocumentationUpdater.setReleaserProperties(properties);
this.releaseTrainContentsUpdater.setReleaserProperties(properties);
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ProjectDocumentationUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ProjectDocumentationUpdater.java
index f75262aa..2b3f760e 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ProjectDocumentationUpdater.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ProjectDocumentationUpdater.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.docs;
import java.io.File;
@@ -18,9 +50,12 @@ import org.springframework.cloud.release.internal.pom.ProjectVersion;
class ProjectDocumentationUpdater implements ReleaserPropertiesAware {
private static final String SC_STATIC_URL = "http://cloud.spring.io/spring-cloud-static/";
- private static final Logger log = LoggerFactory.getLogger(ProjectDocumentationUpdater.class);
+
+ private static final Logger log = LoggerFactory
+ .getLogger(ProjectDocumentationUpdater.class);
private final ProjectGitHandler gitHandler;
+
private ReleaserProperties properties;
ProjectDocumentationUpdater(ReleaserProperties properties,
@@ -30,21 +65,24 @@ class ProjectDocumentationUpdater implements ReleaserPropertiesAware {
}
/**
- * Updates the documentation repository if current release train version is greater or equal
- * than the one stored in the repo.
- *
- * @param currentProject
- * @param springCloudReleaseBranch
- * @return {@link File cloned temporary directory} - {@code null} if wrong version is used
+ * 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 springCloudReleaseBranch) {
+ File updateDocsRepo(ProjectVersion currentProject, String bomBranch) {
if (!this.properties.getGit().isUpdateDocumentationRepo()) {
- log.info("Will not update documentation repository, since the switch to do so "
- + "is off. Set [releaser.git.update-documentation-repo] to [true] to change that");
+ log.info(
+ "Will not update documentation repository, since the switch to do so "
+ + "is off. Set [releaser.git.update-documentation-repo] to [true] to change that");
return null;
}
if (!currentProject.isReleaseOrServiceRelease()) {
- log.info("Will not update documentation repository for non release or service release [{}]", currentProject.version);
+ log.info(
+ "Will not update documentation repository for non release or service release [{}]",
+ currentProject.version);
return null;
}
File documentationProject = this.gitHandler.cloneDocumentationProject();
@@ -52,28 +90,38 @@ class ProjectDocumentationUpdater implements ReleaserPropertiesAware {
String pathToIndexHtml = "current/index.html";
File indexHtml = new File(documentationProject, pathToIndexHtml);
if (!indexHtml.exists()) {
- throw new IllegalStateException("index.html is not present at [" + pathToIndexHtml + "]");
+ throw new IllegalStateException(
+ "index.html is not present at [" + pathToIndexHtml + "]");
}
- return updateTheDocsRepo(springCloudReleaseBranch, documentationProject, indexHtml);
+ return updateTheDocsRepo(bomBranch, documentationProject, indexHtml);
}
- private File updateTheDocsRepo(String springCloudReleaseBranch, File documentationProject, File indexHtml) {
+ private File updateTheDocsRepo(String springCloudReleaseBranch,
+ File documentationProject, File indexHtml) {
try {
String indexHtmlText = readIndexHtmlContents(indexHtml);
int index = indexHtmlText.indexOf(SC_STATIC_URL);
if (index == -1) {
- throw new IllegalStateException("The URL to the documentation repo not found in the index.html file");
+ throw new IllegalStateException(
+ "The URL to the documentation repo not found in the index.html file");
}
int beginIndex = index + SC_STATIC_URL.length();
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;
+ 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 [{}]",
+ log.info(
+ "Current release train [{}] is not newer than the stored one [{}]",
currentReleaseTrainVersion, storedReleaseTrain);
return documentationProject;
}
@@ -95,11 +143,14 @@ class ProjectDocumentationUpdater implements ReleaserPropertiesAware {
private File pushCommitedChanges(String currentReleaseTrainVersion,
File documentationProject, File indexHtml, String indexHtmlText,
String storedReleaseTrain) throws IOException {
- String replacedIndexHtml = indexHtmlText.replace(storedReleaseTrain, currentReleaseTrainVersion);
+ 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 + "]");
+ 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;
@@ -113,4 +164,5 @@ class ProjectDocumentationUpdater implements ReleaserPropertiesAware {
public void setReleaserProperties(ReleaserProperties properties) {
this.properties = properties;
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContents.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContents.java
index 2f2a6a1a..6b68e064 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContents.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContents.java
@@ -1,10 +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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.docs;
import java.util.List;
import java.util.Objects;
public class ReleaseTrainContents {
+
final Title title;
+
final List rows;
ReleaseTrainContents(Title title, List rows) {
@@ -14,11 +48,15 @@ public class ReleaseTrainContents {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
ReleaseTrainContents contents = (ReleaseTrainContents) o;
- return Objects.equals(this.title, contents.title) &&
- Objects.equals(this.rows, contents.rows);
+ return Objects.equals(this.title, contents.title)
+ && Objects.equals(this.rows, contents.rows);
}
@Override
@@ -33,5 +71,5 @@ public class ReleaseTrainContents {
public List getRows() {
return this.rows;
}
-}
+}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsUpdater.java
index 6052e962..7d52af73 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsUpdater.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/ReleaseTrainContentsUpdater.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.docs;
import java.io.File;
@@ -31,13 +63,18 @@ class ReleaseTrainContentsUpdater implements ReleaserPropertiesAware {
private static final Logger log = LoggerFactory
.getLogger(ReleaseTrainContentsUpdater.class);
- private ReleaserProperties properties;
private final ReleaseTrainContentsGitHandler handler;
+
private final ReleaseTrainContentsParser parser;
+
private final ReleaseTrainContentsGenerator generator;
+
private final TemplateGenerator templateGenerator;
- ReleaseTrainContentsUpdater(ReleaserProperties properties, ProjectGitHandler handler, TemplateGenerator templateGenerator) {
+ private ReleaserProperties properties;
+
+ ReleaseTrainContentsUpdater(ReleaserProperties properties, ProjectGitHandler handler,
+ TemplateGenerator templateGenerator) {
this.properties = properties;
this.handler = new ReleaseTrainContentsGitHandler(handler);
this.templateGenerator = templateGenerator;
@@ -46,22 +83,24 @@ class ReleaseTrainContentsUpdater implements ReleaserPropertiesAware {
}
/**
- * Updates the project page if current release train version is greater or equal
- * than the one stored in the repo.
- *
- * @param projects
- * @return {@link File cloned temporary directory} - {@code null} if wrong version is used or the switch is turned off
+ * Updates the project page if current release train version is greater or equal than
+ * the one stored in the repo.
+ * @param projects projects to update project repo for
+ * @return {@link File cloned temporary directory} - {@code null} if wrong version is
+ * used or the switch is turned off
*/
File updateProjectRepo(Projects projects) {
if (!this.properties.getGit().isUpdateSpringProject()) {
- log.info("Will not update the Spring Project cause the switch is turned off. Set [releaser.git.update-spring-project=true].");
+ log.info("Will not update the Spring Project cause "
+ + "the switch is turned off. Set [releaser.git.update-spring-project=true].");
return null;
}
File releaseTrainProject = this.handler.cloneSpringDocProject();
File index = new File(releaseTrainProject, "index.html");
ReleaseTrainContents contents = this.parser.parseProjectPage(index);
if (contents == null) {
- log.warn("There are no markers for the index.html page - I don't really know what to do, so I'll back away");
+ log.warn(
+ "There are no markers for the index.html page - I don't really know what to do, so I'll back away");
return null;
}
String newContents = this.generator.releaseTrainContents(contents, projects);
@@ -72,8 +111,8 @@ class ReleaseTrainContentsUpdater implements ReleaserPropertiesAware {
return pushNewContents(projects, releaseTrainProject, index, newContents);
}
- private File pushNewContents(Projects projects, File releaseTrainProject,
- File index, String newContents) {
+ private File pushNewContents(Projects projects, File releaseTrainProject, File index,
+ String newContents) {
try {
log.debug("Storing new contents to the page");
Files.write(index.toPath(), newContents.getBytes());
@@ -88,28 +127,35 @@ class ReleaseTrainContentsUpdater implements ReleaserPropertiesAware {
}
/**
- * Clones the test project, updates it and runs tests
- *
+ * Clones the test project, updates it and runs tests.
* @param projects - set of project with versions to assert against
*/
File updateReleaseTrainWiki(Projects projects) {
- if (!this.properties.getGit().isUpdateReleaseTrainWiki() ||
- !this.properties.getMetaRelease().isEnabled()) {
- log.info("Will not clone and update the release train wiki, since the switch to do so "
- + "is off or it's not a meta-release. Set [releaser.git.update-release-train-wiki] to [true] to change that");
+ if (!this.properties.getGit().isUpdateReleaseTrainWiki()
+ || !this.properties.getMetaRelease().isEnabled()) {
+ log.info(
+ "Will not clone and update the release train wiki, since the switch to do so "
+ + "is off or it's not a meta-release. Set [releaser.git.update-release-train-wiki] to [true] to change that");
return null;
}
File releaseTrainWiki = this.handler.cloneReleaseTrainWiki();
ProjectVersion releaseTrain = projects.releaseTrain(this.properties);
String releaseTrainName = releaseTrain.major();
String wikiPagePrefix = this.properties.getGit().getReleaseTrainWikiPagePrefix();
- String releaseTrainDocFileName = releaseTrainDocFileName(releaseTrainName, wikiPagePrefix);
- log.info("Reading the file [{}] for the current release train", releaseTrainDocFileName);
- File releaseTrainDocFile = releaseTrainDocFile(releaseTrainWiki, releaseTrainDocFileName);
- String releaseVersionFromCurrentFile = this.parser.latestReleaseTrainFromWiki(releaseTrainDocFile);
- log.info("Latest release train version in the file is [{}]", releaseVersionFromCurrentFile);
- if (!isThisReleaseTrainVersionNewer(releaseTrain, releaseVersionFromCurrentFile)) {
- log.info("Current release train version [{}] is not "
+ String releaseTrainDocFileName = releaseTrainDocFileName(releaseTrainName,
+ wikiPagePrefix);
+ log.info("Reading the file [{}] for the current release train",
+ releaseTrainDocFileName);
+ File releaseTrainDocFile = releaseTrainDocFile(releaseTrainWiki,
+ releaseTrainDocFileName);
+ String releaseVersionFromCurrentFile = this.parser
+ .latestReleaseTrainFromWiki(releaseTrainDocFile);
+ log.info("Latest release train version in the file is [{}]",
+ releaseVersionFromCurrentFile);
+ if (!isThisReleaseTrainVersionNewer(releaseTrain,
+ releaseVersionFromCurrentFile)) {
+ log.info(
+ "Current release train version [{}] is not "
+ "newer than the version taken from the wiki [{}]",
releaseTrain.version, releaseVersionFromCurrentFile);
return releaseTrainWiki;
@@ -118,7 +164,9 @@ class ReleaseTrainContentsUpdater implements ReleaserPropertiesAware {
releaseTrainName, releaseTrainDocFile, releaseVersionFromCurrentFile);
}
- private File generateNewWikiEntry(Projects projects, File releaseTrainWiki, ProjectVersion releaseTrain, String releaseTrainName, File releaseTrainDocFile, String releaseVersionFromCurrentFile) {
+ private File generateNewWikiEntry(Projects projects, File releaseTrainWiki,
+ ProjectVersion releaseTrain, String releaseTrainName,
+ File releaseTrainDocFile, String releaseVersionFromCurrentFile) {
File releaseNotes = this.templateGenerator.releaseNotes(projects);
try {
List lines = Files.readAllLines(releaseTrainDocFile.toPath());
@@ -128,44 +176,54 @@ class ReleaseTrainContentsUpdater implements ReleaserPropertiesAware {
break;
}
}
- return insertNewWikiContentBeforeTheLatestRelease(releaseTrainWiki, releaseTrain,
- releaseTrainName, releaseTrainDocFile, releaseNotes, lines, lineIndex);
+ return insertNewWikiContentBeforeTheLatestRelease(releaseTrainWiki,
+ releaseTrain, releaseTrainName, releaseTrainDocFile, releaseNotes,
+ lines, lineIndex);
}
catch (IOException ex) {
throw new IllegalStateException(ex);
}
}
- private File insertNewWikiContentBeforeTheLatestRelease(File releaseTrainWiki, ProjectVersion releaseTrain, String releaseTrainName, File releaseTrainDocFile, File releaseNotes, List lines, int lineIndex) throws IOException {
+ private File insertNewWikiContentBeforeTheLatestRelease(File releaseTrainWiki,
+ ProjectVersion releaseTrain, String releaseTrainName,
+ File releaseTrainDocFile, File releaseNotes, List lines,
+ int lineIndex) throws IOException {
String newContent = new StringJoiner("\n")
- .add(String.join("\n", lines.subList(0, lineIndex)))
- .add("\n").add(new String(Files.readAllBytes(releaseNotes.toPath())))
+ .add(String.join("\n", lines.subList(0, lineIndex))).add("\n")
+ .add(new String(Files.readAllBytes(releaseNotes.toPath())))
.add(String.join("\n", lines.subList(lineIndex, lines.size())))
.toString();
Files.write(releaseTrainDocFile.toPath(), newContent.getBytes());
- log.info("Successfully stored new wiki contents for release train [{}]", releaseTrainName);
+ log.info("Successfully stored new wiki contents for release train [{}]",
+ releaseTrainName);
this.handler.commitAndPushChanges(releaseTrainWiki, releaseTrain);
return releaseTrainWiki;
}
- private String releaseTrainDocFileName(String releaseTrainName, String wikiPagePrefix) {
- return new StringJoiner("-")
- .add(wikiPagePrefix).add(releaseTrainName).add("Release-Notes.md").toString();
+ private String releaseTrainDocFileName(String releaseTrainName,
+ String wikiPagePrefix) {
+ return new StringJoiner("-").add(wikiPagePrefix).add(releaseTrainName)
+ .add("Release-Notes.md").toString();
}
- private boolean isThisReleaseTrainVersionNewer(ProjectVersion releaseTrain, String releaseVersionFromCurrentFile) {
+ private boolean isThisReleaseTrainVersionNewer(ProjectVersion releaseTrain,
+ String releaseVersionFromCurrentFile) {
if (StringUtils.hasText(releaseVersionFromCurrentFile)) {
- return releaseTrain.compareToReleaseTrainName(releaseVersionFromCurrentFile) > 0;
+ return releaseTrain
+ .compareToReleaseTrainName(releaseVersionFromCurrentFile) > 0;
}
return true;
}
- private File releaseTrainDocFile(File releaseTrainWiki, String releaseTrainDocFileName) {
+ private File releaseTrainDocFile(File releaseTrainWiki,
+ String releaseTrainDocFileName) {
File releaseTrainDocFile = new File(releaseTrainWiki, releaseTrainDocFileName);
if (!releaseTrainDocFile.exists()) {
try {
if (!releaseTrainDocFile.createNewFile()) {
- throw new IllegalStateException("Failed to create releae train doc file");
+ throw new IllegalStateException(
+ "Failed to create releae train doc file");
}
}
catch (IOException e) {
@@ -180,6 +238,7 @@ class ReleaseTrainContentsUpdater implements ReleaserPropertiesAware {
this.properties = properties;
this.generator.setReleaserProperties(properties);
}
+
}
/**
@@ -189,29 +248,36 @@ class ReleaseTrainContentsGenerator implements ReleaserPropertiesAware {
private static final Logger log = LoggerFactory
.getLogger(ReleaseTrainContentsGenerator.class);
+
private static final String SPRING_PROJECT_TEMPLATE = "spring-project";
- private ReleaserProperties properties;
private final File projectOutput;
+ private ReleaserProperties properties;
+
ReleaseTrainContentsGenerator(ReleaserProperties properties) {
this.properties = properties;
this.projectOutput = new File("target/index.html");
}
String releaseTrainContents(ReleaseTrainContents currentContents, Projects projects) {
- String trainProject = this.properties.getMetaRelease().getReleaseTrainProjectName();
+ String trainProject = this.properties.getMetaRelease()
+ .getReleaseTrainProjectName();
ProjectVersion currentReleaseTrainProject = currentReleaseTrainProject(projects);
- ProjectVersion lastGa = new ProjectVersion(trainProject, currentContents.title.lastGaTrainName);
- ProjectVersion currentGa = new ProjectVersion(trainProject, currentContents.title.currentGaTrainName);
- ReleaseTrainContents newReleaseTrainContents = updateReleaseTrainContentsIfNecessary(currentContents, projects,
- currentReleaseTrainProject, lastGa, currentGa);
+ ProjectVersion lastGa = new ProjectVersion(trainProject,
+ currentContents.title.lastGaTrainName);
+ ProjectVersion currentGa = new ProjectVersion(trainProject,
+ currentContents.title.currentGaTrainName);
+ ReleaseTrainContents newReleaseTrainContents = updateReleaseTrainContentsIfNecessary(
+ currentContents, projects, currentReleaseTrainProject, lastGa, currentGa);
if (!currentContents.equals(newReleaseTrainContents)) {
- Template template = HandlebarsHelper.template(this.properties.getTemplate()
- .getTemplateFolder(), SPRING_PROJECT_TEMPLATE);
+ Template template = HandlebarsHelper.template(
+ this.properties.getTemplate().getTemplateFolder(),
+ SPRING_PROJECT_TEMPLATE);
return generate(this.projectOutput, template, newReleaseTrainContents);
}
- log.warn("Current release train [{}] is neither last [{}] or current [{}] or the projects haven't changed. Will not update the contents",
+ log.warn("Current release train [{}] is neither last [{}] "
+ + "or current [{}] or the projects haven't changed. Will not update the contents",
currentReleaseTrainProject.version, lastGa, currentGa);
return "";
}
@@ -220,14 +286,16 @@ class ReleaseTrainContentsGenerator implements ReleaserPropertiesAware {
return projects.releaseTrain(this.properties);
}
- private String generate(File contentOutput, Template template, ReleaseTrainContents releaseTrainContents) {
+ private String generate(File contentOutput, Template template,
+ ReleaseTrainContents releaseTrainContents) {
try {
Map map = ImmutableMap.builder()
.put("lastGaTrainName", releaseTrainContents.title.lastGaTrainName)
- .put("currentGaTrainName", releaseTrainContents.title.currentGaTrainName)
- .put("currentSnapshotTrainName", releaseTrainContents.title.currentSnapshotTrainName)
- .put("projects", releaseTrainContents.rows)
- .build();
+ .put("currentGaTrainName",
+ releaseTrainContents.title.currentGaTrainName)
+ .put("currentSnapshotTrainName",
+ releaseTrainContents.title.currentSnapshotTrainName)
+ .put("projects", releaseTrainContents.rows).build();
String contents = template.apply(map);
Files.write(contentOutput.toPath(), contents.getBytes());
return contents;
@@ -237,61 +305,77 @@ class ReleaseTrainContentsGenerator implements ReleaserPropertiesAware {
}
}
- private ReleaseTrainContents updateReleaseTrainContentsIfNecessary(ReleaseTrainContents currentContents, Projects projects,
- ProjectVersion currentReleaseTrainProject, ProjectVersion lastGa, ProjectVersion currentGa) {
+ private ReleaseTrainContents updateReleaseTrainContentsIfNecessary(
+ ReleaseTrainContents currentContents, Projects projects,
+ ProjectVersion currentReleaseTrainProject, ProjectVersion lastGa,
+ ProjectVersion currentGa) {
ReleaseTrainContents newReleaseTrainContents = currentContents;
// current GA is greater than the last GA
if (greaterMinorOfLastGaReleaseTrain(currentReleaseTrainProject, lastGa)) {
- Title title = new Title(currentReleaseTrainProject.version, currentContents.title.currentGaTrainName,
+ Title title = new Title(currentReleaseTrainProject.version,
+ currentContents.title.currentGaTrainName,
currentContents.title.currentSnapshotTrainName);
return updatedReleaseTrainContents(currentContents, projects, title, true);
- } else if (currentReleaseTrainProject.isSameReleaseTrainName(currentGa.version)) {
- Title title = new Title(currentContents.title.lastGaTrainName, currentReleaseTrainProject.isReleaseOrServiceRelease() ?
- currentReleaseTrainProject.version : currentContents.title.currentGaTrainName, currentReleaseTrainProject.isSnapshot() ?
- currentReleaseTrainProject.version : currentContents.title.currentSnapshotTrainName);
+ }
+ else if (currentReleaseTrainProject.isSameReleaseTrainName(currentGa.version)) {
+ Title title = new Title(currentContents.title.lastGaTrainName,
+ currentReleaseTrainProject.isReleaseOrServiceRelease()
+ ? currentReleaseTrainProject.version
+ : currentContents.title.currentGaTrainName,
+ currentReleaseTrainProject.isSnapshot()
+ ? currentReleaseTrainProject.version
+ : currentContents.title.currentSnapshotTrainName);
return updatedReleaseTrainContents(currentContents, projects, title, false);
}
return newReleaseTrainContents;
}
- private boolean greaterMinorOfLastGaReleaseTrain(ProjectVersion currentReleaseTrainProject, ProjectVersion lastGa) {
- return currentReleaseTrainProject.isSameReleaseTrainName(lastGa.version) &&
- currentReleaseTrainProject.isReleaseOrServiceRelease() &&
- currentReleaseTrainProject.compareToReleaseTrainName(lastGa.version) > 0;
+ private boolean greaterMinorOfLastGaReleaseTrain(
+ ProjectVersion currentReleaseTrainProject, ProjectVersion lastGa) {
+ return currentReleaseTrainProject.isSameReleaseTrainName(lastGa.version)
+ && currentReleaseTrainProject.isReleaseOrServiceRelease()
+ && currentReleaseTrainProject
+ .compareToReleaseTrainName(lastGa.version) > 0;
}
- private ReleaseTrainContents updatedReleaseTrainContents(ReleaseTrainContents currentContents, Projects projects,
- Title title, boolean lastGa) {
+ private ReleaseTrainContents updatedReleaseTrainContents(
+ ReleaseTrainContents currentContents, Projects projects, Title title,
+ boolean lastGa) {
List rows = Row.fromProjects(projects, lastGa);
- return new ReleaseTrainContents(
- title, currentContents.rows.stream().map(current -> {
- Row projectRow = rows.stream().filter(row ->
- current.componentName.equals(row.componentName)).findFirst().orElse(current);
- if (projectRow == current) {
- return projectRow;
- }
- return from(current, projectRow);
- }).collect(Collectors.toCollection(LinkedList::new)));
+ return new ReleaseTrainContents(title,
+ currentContents.rows.stream().map(current -> {
+ Row projectRow = rows.stream().filter(
+ row -> current.componentName.equals(row.componentName))
+ .findFirst().orElse(current);
+ if (projectRow == current) {
+ return projectRow;
+ }
+ return from(current, projectRow);
+ }).collect(Collectors.toCollection(LinkedList::new)));
}
private Row from(Row current, Row project) {
- return new Row(current.componentName, StringUtils.hasText(project.lastGaVersion) ?
- project.lastGaVersion : current.lastGaVersion,
- StringUtils.hasText(project.currentGaVersion) ?
- project.currentGaVersion : current.currentGaVersion,
- StringUtils.hasText(project.currentSnapshotVersion) ?
- project.currentSnapshotVersion : current.currentSnapshotVersion);
+ return new Row(current.componentName,
+ StringUtils.hasText(project.lastGaVersion) ? project.lastGaVersion
+ : current.lastGaVersion,
+ StringUtils.hasText(project.currentGaVersion) ? project.currentGaVersion
+ : current.currentGaVersion,
+ StringUtils.hasText(project.currentSnapshotVersion)
+ ? project.currentSnapshotVersion
+ : current.currentSnapshotVersion);
}
@Override
public void setReleaserProperties(ReleaserProperties properties) {
this.properties = properties;
}
+
}
class ReleaseTrainContentsGitHandler {
- private static final Logger log = LoggerFactory.getLogger(ReleaseTrainContentsGitHandler.class);
+ private static final Logger log = LoggerFactory
+ .getLogger(ReleaseTrainContentsGitHandler.class);
private static final String PROJECT_PAGE_UPDATED_COMMIT_MSG = "Updating project page to release train [%s]";
@@ -311,7 +395,8 @@ class ReleaseTrainContentsGitHandler {
void commitAndPushChanges(File repo, ProjectVersion releaseTrain) {
log.debug("Committing and pushing changes");
- this.handler.commit(repo, String.format(PROJECT_PAGE_UPDATED_COMMIT_MSG, releaseTrain.version));
+ this.handler.commit(repo,
+ String.format(PROJECT_PAGE_UPDATED_COMMIT_MSG, releaseTrain.version));
this.handler.pushCurrentBranch(repo);
}
@@ -327,7 +412,8 @@ class ReleaseTrainContentsParser {
String contents = new String(Files.readAllBytes(rawHtml.toPath()));
String[] split = contents.split("");
if (split.length != 3) {
- log.warn("The page is missing the components table markers. Please add [] and [] to the file.");
+ log.warn("The page is missing the components table markers. "
+ + "Please add [] and [] to the file.");
return null;
}
String table = split[1];
@@ -349,14 +435,13 @@ class ReleaseTrainContentsParser {
String latestReleaseTrainFromWiki(File rawMd) {
try {
return Files.readAllLines(rawMd.toPath()).stream()
- .filter(s -> s.trim().startsWith("#"))
- .map(s -> s.substring(1).trim())
- .filter(s -> new ProjectVersion("foo", s).isValid())
- .findFirst()
+ .filter(s -> s.trim().startsWith("#")).map(s -> s.substring(1).trim())
+ .filter(s -> new ProjectVersion("foo", s).isValid()).findFirst()
.orElse("");
}
catch (IOException e) {
throw new IllegalStateException(e);
}
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/Row.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/Row.java
index 11a44844..ae63ebd9 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/Row.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/Row.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.docs;
import java.util.LinkedList;
@@ -12,9 +44,13 @@ import org.springframework.cloud.release.internal.pom.Projects;
* @author Marcin Grzejszczak
*/
public class Row {
+
final String componentName;
+
final String lastGaVersion;
+
final String currentGaVersion;
+
final String currentSnapshotVersion;
Row(String[] row) {
@@ -25,7 +61,8 @@ public class Row {
this.currentSnapshotVersion = row[initialIndex + 3].trim();
}
- Row(String componentName, String lastGaVersion, String currentGaVersion, String currentSnapshotVersion) {
+ Row(String componentName, String lastGaVersion, String currentGaVersion,
+ String currentSnapshotVersion) {
this.componentName = componentName.trim();
this.lastGaVersion = lastGaVersion.trim();
this.currentGaVersion = currentGaVersion.trim();
@@ -33,34 +70,36 @@ public class Row {
}
static List fromProjects(Projects projects, boolean lastGa) {
- return projects
- .stream()
+ return projects.stream()
.map(v -> new Row(v.projectName, lastGa ? versionOrEmptyForGa(v) : "",
- !lastGa ? versionOrEmptyForGa(v) : "", v.isSnapshot() ? v.version : ""))
+ !lastGa ? versionOrEmptyForGa(v) : "",
+ v.isSnapshot() ? v.version : ""))
.collect(Collectors.toCollection(LinkedList::new));
}
private static String versionOrEmptyForGa(ProjectVersion v) {
- return v.isReleaseOrServiceRelease() ?
- v.version : "";
+ return v.isReleaseOrServiceRelease() ? v.version : "";
}
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
Row row = (Row) o;
- return Objects.equals(this.componentName, row.componentName) &&
- Objects.equals(this.lastGaVersion, row.lastGaVersion) &&
- Objects.equals(this.currentGaVersion, row.currentGaVersion) &&
- Objects.equals(this.currentSnapshotVersion, row.currentSnapshotVersion);
+ return Objects.equals(this.componentName, row.componentName)
+ && Objects.equals(this.lastGaVersion, row.lastGaVersion)
+ && Objects.equals(this.currentGaVersion, row.currentGaVersion) && Objects
+ .equals(this.currentSnapshotVersion, row.currentSnapshotVersion);
}
@Override
public int hashCode() {
- return Objects
- .hash(this.componentName, this.lastGaVersion,
- this.currentGaVersion, this.currentSnapshotVersion);
+ return Objects.hash(this.componentName, this.lastGaVersion, this.currentGaVersion,
+ this.currentSnapshotVersion);
}
public String getComponentName() {
@@ -78,4 +117,5 @@ public class Row {
public String getCurrentSnapshotVersion() {
return this.currentSnapshotVersion;
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/Title.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/Title.java
index fe5bfbe5..57b20610 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/Title.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/docs/Title.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.docs;
import java.util.Objects;
@@ -8,7 +40,9 @@ import java.util.Objects;
public class Title {
final String lastGaTrainName;
+
final String currentGaTrainName;
+
final String currentSnapshotTrainName;
Title(String[] row) {
@@ -18,7 +52,8 @@ public class Title {
this.currentSnapshotTrainName = row[initialIndex + 2].trim();
}
- Title(String lastGaTrainName, String currentGaTrainName, String currentSnapshotTrainName) {
+ Title(String lastGaTrainName, String currentGaTrainName,
+ String currentSnapshotTrainName) {
this.lastGaTrainName = lastGaTrainName.trim();
this.currentGaTrainName = currentGaTrainName.trim();
this.currentSnapshotTrainName = currentSnapshotTrainName.trim();
@@ -26,19 +61,23 @@ public class Title {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
Title title = (Title) o;
- return Objects.equals(this.lastGaTrainName, title.lastGaTrainName) &&
- Objects.equals(this.currentGaTrainName, title.currentGaTrainName) &&
- Objects
- .equals(this.currentSnapshotTrainName, title.currentSnapshotTrainName);
+ return Objects.equals(this.lastGaTrainName, title.lastGaTrainName)
+ && Objects.equals(this.currentGaTrainName, title.currentGaTrainName)
+ && Objects.equals(this.currentSnapshotTrainName,
+ title.currentSnapshotTrainName);
}
@Override
public int hashCode() {
- return Objects
- .hash(this.lastGaTrainName, this.currentGaTrainName, this.currentSnapshotTrainName);
+ return Objects.hash(this.lastGaTrainName, this.currentGaTrainName,
+ this.currentSnapshotTrainName);
}
public String getLastGaTrainName() {
@@ -52,4 +91,5 @@ public class Title {
public String getCurrentSnapshotTrainName() {
return this.currentSnapshotTrainName;
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GitRepo.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GitRepo.java
index bc2c310d..eb0b4645 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GitRepo.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GitRepo.java
@@ -1,18 +1,35 @@
/*
- * Copyright 2013-2019 the original author or authors.
+ * 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
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * 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.
*/
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.git;
import java.io.File;
@@ -58,8 +75,8 @@ import org.springframework.util.ResourceUtils;
import org.springframework.util.StringUtils;
/**
- * Abstraction over a Git repo. Can cloned repo from a given location
- * and check its branch.
+ * Abstraction over a Git repo. Can cloned repo from a given location and check its
+ * branch.
*
* @author Marcin Grzejszczak
*/
@@ -89,7 +106,7 @@ class GitRepo {
}
/**
- * Clones the project
+ * Clones the project.
* @param projectUri - URI of the project
* @return file where the project was cloned
*/
@@ -111,7 +128,7 @@ class GitRepo {
}
/**
- * Checks out a branch for a project
+ * Checks out a branch for a project.
* @param branch - branch to check out
*/
void checkout(String branch) {
@@ -126,31 +143,35 @@ class GitRepo {
}
/**
- * Performs a commit
+ * Performs a commit.
* @param message - commit message
*/
void commit(String message) {
- try(Git git = this.gitFactory.open(file(this.basedir))) {
+ try (Git git = this.gitFactory.open(file(this.basedir))) {
git.add().addFilepattern(".").call();
git.commit().setAllowEmpty(false).setMessage(message).call();
printLog(git);
- } catch (EmtpyCommitException e) {
+ }
+ catch (EmtpyCommitException e) {
log.info("There were no changes detected. Will not commit an empty commit");
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new IllegalStateException(e);
}
}
boolean hasBranch(String branch) {
- try(Git git = this.gitFactory.open(file(this.basedir))) {
+ try (Git git = this.gitFactory.open(file(this.basedir))) {
List[ refs = git.branchList().setListMode(ListBranchCommand.ListMode.ALL)
.call();
- boolean present = refs.stream().anyMatch(ref -> branch.equals(nameOfBranch(ref.getName())));
+ boolean present = refs.stream()
+ .anyMatch(ref -> branch.equals(nameOfBranch(ref.getName())));
if (log.isDebugEnabled()) {
log.debug("Branch [{}] is present [{}]", branch, present);
}
return present;
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new IllegalStateException(e);
}
}
@@ -165,84 +186,92 @@ class GitRepo {
log.info("Printing [{}] last commits for branch [{}]", maxCount, currentBranch);
Iterable commits = git.log().setMaxCount(maxCount).call();
for (RevCommit commit : commits) {
- log.info("Name [{}], msg [{}]", commit.getId().name(), commit.getShortMessage());
+ log.info("Name [{}], msg [{}]", commit.getId().name(),
+ commit.getShortMessage());
}
}
/**
- * Creates a tag with a given name
- * @param tagName
+ * Creates a tag with a given name.
+ * @param tagName name of the tag to set
*/
void tag(String tagName) {
- try(Git git = this.gitFactory.open(file(this.basedir))) {
+ try (Git git = this.gitFactory.open(file(this.basedir))) {
git.tag().setName(tagName).call();
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new IllegalStateException(e);
}
}
/**
- * Pushes the commits to {@code origin} remote branch
+ * Pushes the commits to {@code origin} remote branch.
* @param branch - remote branch to which the code should be pushed
*/
void pushBranch(String branch) {
- try(Git git = this.gitFactory.open(file(this.basedir))) {
+ try (Git git = this.gitFactory.open(file(this.basedir))) {
String localBranch = git.getRepository().getFullBranch();
RefSpec refSpec = new RefSpec(localBranch + ":" + branch);
this.gitFactory.push(git).setPushTags().setRefSpecs(refSpec).call();
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new IllegalStateException(e);
}
}
/**
- * Pushes the commits od current branch
+ * Pushes the commits od current branch.
*/
void pushCurrentBranch() {
- try(Git git = this.gitFactory.open(file(this.basedir))) {
+ try (Git git = this.gitFactory.open(file(this.basedir))) {
this.gitFactory.push(git).call();
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new IllegalStateException(e);
}
}
/**
- * Pushes the commits to {@code origin} remote tag
+ * Pushes the commits to {@code origin} remote tag.
* @param tagName - remote tag to which the code should be pushed
*/
void pushTag(String tagName) {
- try(Git git = this.gitFactory.open(file(this.basedir))) {
+ try (Git git = this.gitFactory.open(file(this.basedir))) {
String localBranch = git.getRepository().getFullBranch();
RefSpec refSpec = new RefSpec(localBranch + ":" + "refs/tags/" + tagName);
this.gitFactory.push(git).setPushTags().setRefSpecs(refSpec).call();
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new IllegalStateException(e);
}
}
void revert(String message) {
- try(Git git = this.gitFactory.open(file(this.basedir))) {
+ try (Git git = this.gitFactory.open(file(this.basedir))) {
RevCommit commit = git.log().setMaxCount(1).call().iterator().next();
String shortMessage = commit.getShortMessage();
String id = commit.getId().getName();
if (!shortMessage.contains("Update SNAPSHOT to ")) {
- throw new IllegalStateException("Won't revert the commit with id [" + id + "] "
- + "and message [" + shortMessage + "]. Only commit that updated "
- + "snapshot to another version can be reverted");
+ throw new IllegalStateException(
+ "Won't revert the commit with id [" + id + "] " + "and message ["
+ + shortMessage + "]. Only commit that updated "
+ + "snapshot to another version can be reverted");
}
log.debug("The commit to be reverted is [{}]", commit);
git.revert().include(commit).call();
git.commit().setAmend(true).setMessage(message).call();
printLog(git);
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new IllegalStateException(e);
}
}
String currentBranch() {
- try(Git git = this.gitFactory.open(file(this.basedir))) {
+ try (Git git = this.gitFactory.open(file(this.basedir))) {
return git.getRepository().getBranch();
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new IllegalStateException(e);
}
}
@@ -254,8 +283,8 @@ class GitRepo {
private Git cloneToBasedir(URIish projectUrl, File destinationFolder)
throws GitAPIException {
CloneCommand command = this.gitFactory.getCloneCommandByCloneRepository()
- .setURI(projectUrl.toString() + ".git").setDirectory(
- humanishDestination(projectUrl, destinationFolder));
+ .setURI(projectUrl.toString() + ".git")
+ .setDirectory(humanishDestination(projectUrl, destinationFolder));
try {
return command.call();
}
@@ -269,8 +298,7 @@ class GitRepo {
return new File(destinationFolder, projectUrl.getHumanishName());
}
- private Ref checkoutBranch(File projectDir, String branch)
- throws GitAPIException {
+ private Ref checkoutBranch(File projectDir, String branch) throws GitAPIException {
Git git = this.gitFactory.open(projectDir);
CheckoutCommand command = git.checkout().setName(branch);
try {
@@ -282,7 +310,8 @@ class GitRepo {
catch (GitAPIException e) {
deleteBaseDirIfExists();
throw e;
- } finally {
+ }
+ finally {
git.close();
}
}
@@ -305,8 +334,8 @@ class GitRepo {
return containsBranch(git, label, null);
}
- private boolean containsBranch(Git git, String label, ListBranchCommand.ListMode listMode)
- throws GitAPIException {
+ private boolean containsBranch(Git git, String label,
+ ListBranchCommand.ListMode listMode) throws GitAPIException {
ListBranchCommand command = git.branchList();
if (listMode != null) {
command.setListMode(listMode);
@@ -336,31 +365,37 @@ class GitRepo {
* {@link org.eclipse.jgit.api.CloneCommand} allowing for easier unit testing.
*/
static class JGitFactory {
+
private static final Logger log = LoggerFactory.getLogger(JGitFactory.class);
private final JschConfigSessionFactory factory = new JschConfigSessionFactory() {
- @Override protected void configure(OpenSshConfig.Host host, Session session) {
+ @Override
+ protected void configure(OpenSshConfig.Host host, Session session) {
}
@Override
protected JSch createDefaultJSch(FS fs) throws JSchException {
Connector connector = null;
try {
- if(SSHAgentConnector.isConnectorAvailable()){
+ if (SSHAgentConnector.isConnectorAvailable()) {
USocketFactory usf = new JNAUSocketFactory();
connector = new SSHAgentConnector(usf);
}
log.info("Successfully connected to an agent");
- } catch (AgentProxyException e) {
- log.error("Exception occurred while trying to connect to agent. Will create"
- + "the default JSch connection", e);
+ }
+ catch (AgentProxyException e) {
+ log.error(
+ "Exception occurred while trying to connect to agent. Will create"
+ + "the default JSch connection",
+ e);
return super.createDefaultJSch(fs);
}
final JSch jsch = super.createDefaultJSch(fs);
if (connector != null) {
JSch.setConfig("PreferredAuthentications", "publickey,password");
- IdentityRepository identityRepository = new RemoteIdentityRepository(connector);
+ IdentityRepository identityRepository = new RemoteIdentityRepository(
+ connector);
jsch.setIdentityRepository(identityRepository);
}
return jsch;
@@ -369,27 +404,6 @@ class GitRepo {
private final CredentialsProvider provider;
- JGitFactory(ReleaserProperties releaserProperties) {
- if (StringUtils.hasText(releaserProperties.getGit().getUsername())) {
- log.info("Passed username and password - will set a custom credentials provider");
- this.provider = credentialsProvider(releaserProperties);
- } else {
- log.info("No custom credentials provider will be set");
- this.provider = null;
- }
- }
-
- CredentialsProvider credentialsProvider(ReleaserProperties properties) {
- return new UsernamePasswordCredentialsProvider(
- properties.getGit().getUsername(),
- properties.getGit().getPassword());
- }
-
- // for tests
- JGitFactory() {
- this.provider = null;
- }
-
private final TransportConfigCallback callback = transport -> {
if (transport instanceof SshTransport) {
SshTransport sshTransport = (SshTransport) transport;
@@ -397,15 +411,35 @@ class GitRepo {
}
};
+ JGitFactory(ReleaserProperties releaserProperties) {
+ if (StringUtils.hasText(releaserProperties.getGit().getUsername())) {
+ log.info(
+ "Passed username and password - will set a custom credentials provider");
+ this.provider = credentialsProvider(releaserProperties);
+ }
+ else {
+ log.info("No custom credentials provider will be set");
+ this.provider = null;
+ }
+ }
+
+ // for tests
+ JGitFactory() {
+ this.provider = null;
+ }
+
+ CredentialsProvider credentialsProvider(ReleaserProperties properties) {
+ return new UsernamePasswordCredentialsProvider(
+ properties.getGit().getUsername(), properties.getGit().getPassword());
+ }
+
CloneCommand getCloneCommandByCloneRepository() {
- return Git.cloneRepository()
- .setCredentialsProvider(this.provider)
+ return Git.cloneRepository().setCredentialsProvider(this.provider)
.setTransportConfigCallback(this.callback);
}
PushCommand push(Git git) {
- return git.push()
- .setCredentialsProvider(this.provider)
+ return git.push().setCredentialsProvider(this.provider)
.setTransportConfigCallback(this.callback);
}
@@ -417,5 +451,7 @@ class GitRepo {
throw new IllegalStateException(e);
}
}
+
}
-}
\ No newline at end of file
+
+}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GithubIssues.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GithubIssues.java
index a55fd86c..c4ba2202 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GithubIssues.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GithubIssues.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.git;
import java.io.IOException;
@@ -12,6 +44,7 @@ import com.jcabi.github.RtGithub;
import com.jcabi.http.wire.RetryWire;
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;
@@ -24,14 +57,16 @@ import org.springframework.util.StringUtils;
class GithubIssues {
private static final Logger log = LoggerFactory.getLogger(GithubIssues.class);
+
private static final String GITHUB_ISSUE_TITLE = "Spring Cloud Release took place";
private final Github github;
+
private final ReleaserProperties properties;
GithubIssues(ReleaserProperties properties) {
- this.github = new RtGithub(new RtGithub(
- properties.getGit().getOauthToken()).entry().through(RetryWire.class));
+ this.github = new RtGithub(new RtGithub(properties.getGit().getOauthToken())
+ .entry().through(RetryWire.class));
this.properties = properties;
}
@@ -51,12 +86,15 @@ class GithubIssues {
// do this only for RELEASE & SR
String releaseVersion = parsedVersion();
if (!(version.isRelease() || version.isServiceRelease())) {
- log.info("Guide issue creation will occur only for Release or Service Release versions. Your version is [{}]", releaseVersion);
+ log.info(
+ "Guide issue creation will occur only for Release or Service Release versions. Your version is [{}]",
+ releaseVersion);
return;
}
Repo springGuides = this.github.repos()
.get(new Coordinates.Simple("spring-guides", "getting-started-guides"));
- String issueTitle = StringUtils.capitalize(releaseVersion) + " " + GITHUB_ISSUE_TITLE;
+ String issueTitle = StringUtils.capitalize(releaseVersion) + " "
+ + GITHUB_ISSUE_TITLE;
// check if the issue is not already there
boolean issueAlreadyFiled = issueAlreadyFiled(springGuides, issueTitle);
if (issueAlreadyFiled) {
@@ -66,7 +104,9 @@ class GithubIssues {
try {
int number = springGuides.issues().create(issueTitle, issueText(projects))
.number();
- log.info("Successfully created an issue with title [{}] in Spring Guides under: https://github.com/spring-guides/getting-started-guides/issues/" + number, issueTitle);
+ log.info("Successfully created an issue with "
+ + "title [{}] in Spring Guides under: https://github.com/spring-guides/getting-started-guides/issues/"
+ + number, issueTitle);
}
catch (IOException e) {
log.error("Exception occurred while trying to create the issue in guides", e);
@@ -82,15 +122,11 @@ class GithubIssues {
}
private String issueText(Projects projects) {
- StringBuilder builder = new StringBuilder()
- .append("Spring Cloud [")
- .append(parsedVersion())
- .append("] Released with the following projects:")
+ StringBuilder builder = new StringBuilder().append("Spring Cloud [")
+ .append(parsedVersion()).append("] Released with the following projects:")
.append("\n\n");
- projects.forEach(project -> builder
- .append(project.projectName).append(" : ")
- .append("`").append(project.version).append("`")
- .append("\n"));
+ projects.forEach(project -> builder.append(project.projectName).append(" : ")
+ .append("`").append(project.version).append("`").append("\n"));
return builder.toString();
}
@@ -116,4 +152,5 @@ class GithubIssues {
}
return false;
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GithubMilestones.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GithubMilestones.java
index f19ebeca..cae7c0a1 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GithubMilestones.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/GithubMilestones.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.git;
import java.io.IOException;
@@ -25,16 +57,18 @@ import org.springframework.util.StringUtils;
*/
class GithubMilestones {
- private static final Logger log = LoggerFactory.getLogger(GithubMilestones.class);
-
- private final Github github;
- private final ReleaserProperties properties;
static final Map MILESTONE_URL_CACHE = new ConcurrentHashMap<>();
static final Map MILESTONE_CACHE = new ConcurrentHashMap<>();
+ private static final Logger log = LoggerFactory.getLogger(GithubMilestones.class);
+
+ private final Github github;
+
+ private final ReleaserProperties properties;
+
GithubMilestones(ReleaserProperties properties) {
- this.github = new RtGithub(new RtGithub(
- properties.getGit().getOauthToken()).entry().through(RetryWire.class));
+ this.github = new RtGithub(new RtGithub(properties.getGit().getOauthToken())
+ .entry().through(RetryWire.class));
this.properties = properties;
}
@@ -66,32 +100,35 @@ class GithubMilestones {
catch (IOException e) {
log.error("Exception occurred while trying to retrieve the milestone", e);
}
- } else {
+ }
+ else {
log.warn("No matching milestone was found");
}
}
- Milestone.Smart matchingMilestone(String tagVersion,
- Iterable milestones) {
+ Milestone.Smart matchingMilestone(String tagVersion, Iterable milestones) {
log.debug("Successfully received list of milestones [{}]", milestones);
log.info("Will try to match against tag version [{}]", tagVersion);
try {
int counter = 0;
for (Milestone milestone : milestones) {
- if (counter++ >= this.properties.getGit().getNumberOfCheckedMilestones()) {
- log.warn("No matching milestones were found within the provided threshold [{}] of checked milestones",
+ if (counter++ >= this.properties.getGit()
+ .getNumberOfCheckedMilestones()) {
+ log.warn(
+ "No matching milestones were found within the provided threshold [{}] of checked milestones",
this.properties.getGit().getNumberOfCheckedMilestones());
return null;
}
Milestone.Smart smartMilestone = new Milestone.Smart(milestone);
String title = milestoneTitle(smartMilestone);
- if (tagVersion.equals(title) || numericVersion(tagVersion)
- .equals(title)) {
+ if (tagVersion.equals(title)
+ || numericVersion(tagVersion).equals(title)) {
log.info("Found a matching milestone [{}]", smartMilestone.number());
return smartMilestone;
}
}
- } catch (AssertionError | IOException e) {
+ }
+ catch (AssertionError | IOException e) {
log.error("Exception occurred while trying to retrieve the milestone", e);
return null;
}
@@ -107,7 +144,8 @@ class GithubMilestones {
Assert.hasText(this.properties.getGit().getOauthToken(),
"You have to pass Github OAuth token for milestone closing to be operational");
String tagVersion = version.version;
- Milestone.Smart foundMilestone = matchingMilestone(tagVersion, closedMilestones(version));
+ Milestone.Smart foundMilestone = matchingMilestone(tagVersion,
+ closedMilestones(version));
String foundUrl = "";
if (foundMilestone != null) {
try {
@@ -115,7 +153,7 @@ class GithubMilestones {
log.info("Found a matching milestone with issues URL [{}]", url);
foundUrl = url.toString()
.replace("https://api.github.com/repos", "https://github.com")
- .replace("milestones", "milestone")+ "?closed=1";
+ .replace("milestones", "milestone") + "?closed=1";
}
catch (IOException e) {
throw new IllegalStateException(e);
@@ -129,8 +167,8 @@ class GithubMilestones {
}
private String numericVersion(String version) {
- return version.contains("RELEASE") ?
- version.substring(0, version.lastIndexOf(".")) : "";
+ return version.contains("RELEASE")
+ ? version.substring(0, version.lastIndexOf(".")) : "";
}
String milestoneTitle(Milestone.Smart milestone) throws IOException {
@@ -145,9 +183,10 @@ class GithubMilestones {
Map map) {
try {
return this.github.repos()
- .get(new Coordinates.Simple(org(), version.projectName))
- .milestones().iterate(map);
- } catch (AssertionError e) {
+ .get(new Coordinates.Simple(org(), version.projectName)).milestones()
+ .iterate(map);
+ }
+ catch (AssertionError e) {
log.error("Exception occurred while trying to fetch milestones", e);
return new ArrayList<>();
}
@@ -180,4 +219,5 @@ class GithubMilestones {
params.put("direction", "desc");
return params;
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/ProjectGitHandler.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/ProjectGitHandler.java
index 40bdd295..3cbba140 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/ProjectGitHandler.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/git/ProjectGitHandler.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.git;
import java.io.File;
@@ -15,7 +47,7 @@ import org.springframework.cloud.release.internal.pom.Projects;
import org.springframework.util.StringUtils;
/**
- * Contains business logic around Git & Github operations
+ * Contains business logic around Git & Github operations.
*
* @author Marcin Grzejszczak
*/
@@ -24,11 +56,17 @@ public class ProjectGitHandler implements ReleaserPropertiesAware {
private static final Logger log = LoggerFactory.getLogger(ProjectGitHandler.class);
private static final String MSG = "Bumping versions";
+
private static final String PRE_RELEASE_MSG = "Update SNAPSHOT to %s";
+
private static final String POST_RELEASE_MSG = "Going back to snapshots";
+
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) {
@@ -40,11 +78,14 @@ public class ProjectGitHandler implements ReleaserPropertiesAware {
public void commitAndTagIfApplicable(File project, ProjectVersion version) {
GitRepo gitRepo = gitRepo(project);
if (version.isSnapshot()) {
- log.info("Snapshot version [{}] found. Will only commit the changed poms", version);
+ log.info("Snapshot version [{}] found. Will only commit the changed poms",
+ version);
gitRepo.commit(MSG);
}
else {
- log.info("NON-snapshot version [{}] found. Will commit the changed poms, tag the version and push the tag", version);
+ log.info(
+ "NON-snapshot version [{}] found. Will commit the changed poms, tag the version and push the tag",
+ version);
gitRepo.commit(String.format(PRE_RELEASE_MSG, version.version));
String tagName = "v" + version.version;
gitRepo.tag(tagName);
@@ -54,9 +95,10 @@ public class ProjectGitHandler implements ReleaserPropertiesAware {
public void commitAfterBumpingVersions(File project, ProjectVersion version) {
if (version.isSnapshot()) {
- log.info("Snapshot version [{}] found. Will only commit the changed poms", version);
- commit(project, String
- .format(POST_RELEASE_BUMP_MSG, version.bumpedVersion()));
+ log.info("Snapshot version [{}] found. Will only commit the changed poms",
+ version);
+ commit(project,
+ String.format(POST_RELEASE_BUMP_MSG, version.bumpedVersion()));
}
else {
log.info("Non snapshot version [{}] found. Won't do anything", version);
@@ -87,18 +129,17 @@ public class ProjectGitHandler implements ReleaserPropertiesAware {
}
public File cloneDocumentationProject() {
- return cloneAndCheckOut(this.properties.getGit()
- .getDocumentationUrl(), this.properties.getGit()
- .getDocumentationBranch());
+ return cloneAndCheckOut(this.properties.getGit().getDocumentationUrl(),
+ this.properties.getGit().getDocumentationBranch());
}
public File cloneSpringDocProject() {
- return cloneAndCheckOut(this.properties.getGit()
- .getSpringProjectUrl(), this.properties.getGit()
- .getSpringProjectBranch());
+ return cloneAndCheckOut(this.properties.getGit().getSpringProjectUrl(),
+ this.properties.getGit().getSpringProjectBranch());
}
- private File cloneAndCheckOut(String springProjectUrl, String springProjectUrlBranch) {
+ private File cloneAndCheckOut(String springProjectUrl,
+ String springProjectUrlBranch) {
File clonedProject = cloneProject(springProjectUrl);
checkout(clonedProject, springProjectUrlBranch);
return clonedProject;
@@ -111,8 +152,8 @@ public class ProjectGitHandler implements ReleaserPropertiesAware {
*/
public File cloneProjectFromOrg(String projectName) {
String orgUrl = this.properties.getMetaRelease().getGitOrgUrl();
- String fullUrl = orgUrl.endsWith("/") ? (orgUrl + projectName) : (orgUrl + "/" +
- projectName + suffixNonHttpRepo(orgUrl));
+ String fullUrl = orgUrl.endsWith("/") ? (orgUrl + projectName)
+ : (orgUrl + "/" + projectName + suffixNonHttpRepo(orgUrl));
if (log.isDebugEnabled()) {
log.debug("Full url of the project is [{}]", fullUrl);
}
@@ -122,20 +163,20 @@ public class ProjectGitHandler implements ReleaserPropertiesAware {
}
String version = this.properties.getFixedVersions().get(projectName);
if (StringUtils.isEmpty(version)) {
- throw new IllegalStateException("You haven't provided a version for project [" + projectName + "]");
+ throw new IllegalStateException(
+ "You haven't provided a version for project [" + projectName + "]");
}
return findAndCheckOutBranchForVersion(clonedProject, new String[] { version });
}
-
/**
- * From the version analyzes the branch and checks it out. E.g.
- * - for spring-cloud-release’s `Finchley.RELEASE version will resolve either Finchley
- * branch or will fallback to master if there’s no Finchley branch
- * - for spring-cloud-sleuth’s `2.1.0.RELEASE version will resolve 2.1.x branch
- *
+ * From the version analyzes the branch and checks it out. E.g. - for
+ * spring-cloud-release’s `Finchley.RELEASE version will resolve either Finchley
+ * branch or will fallback to master if there’s no Finchley branch - for
+ * spring-cloud-sleuth’s `2.1.0.RELEASE version will resolve 2.1.x branch
* @param url - of project to clone
- * @param versions - list of versions to check against, if none matches, will fallback to master
+ * @param versions - list of versions to check against, if none matches, will fallback
+ * to master
* @return location of the cloned project
*/
public File cloneAndGuessBranch(String url, String... versions) {
@@ -150,14 +191,13 @@ public class ProjectGitHandler implements ReleaserPropertiesAware {
if (log.isDebugEnabled()) {
log.debug("Checking versions {} for project [{}]", versions, clonedProject);
}
- String branchToCheckout = Arrays.stream(versions)
- .map(this::branchFromVersion)
+ String branchToCheckout = Arrays.stream(versions).map(this::branchFromVersion)
.map(version -> gitRepo(clonedProject).hasBranch(version) ? version : "")
- .filter(StringUtils::hasText)
- .findFirst()
- .orElse("master");
+ .filter(StringUtils::hasText).findFirst().orElse("master");
if ("master".equals(branchToCheckout)) {
- log.info("None of the versions {} matches a branch. Assuming that should work with master branch", (Object) versions);
+ log.info(
+ "None of the versions {} matches a branch. Assuming that should work with master branch",
+ (Object) versions);
return clonedProject;
}
log.info("Branch [{}] exists. Will check it out", branchToCheckout);
@@ -171,9 +211,10 @@ public class ProjectGitHandler implements ReleaserPropertiesAware {
File cloneProject(String url) {
try {
- File destinationDir = this.properties.getGit().getCloneDestinationDir() != null ?
- new File(this.properties.getGit().getCloneDestinationDir()) :
- Files.createTempDirectory("releaser").toFile();
+ File destinationDir = this.properties.getGit()
+ .getCloneDestinationDir() != null
+ ? new File(this.properties.getGit().getCloneDestinationDir())
+ : Files.createTempDirectory("releaser").toFile();
return gitRepo(destinationDir).cloneProject(new URIish(url));
}
catch (Exception e) {
@@ -203,7 +244,8 @@ public class ProjectGitHandler implements ReleaserPropertiesAware {
// [Camden] -> [Camden.x]
return splitVersion[0];
}
- throw new IllegalStateException("Wrong version [" + version + "]. Can't extract semver pieces of it");
+ throw new IllegalStateException(
+ "Wrong version [" + version + "]. Can't extract semver pieces of it");
}
@@ -244,4 +286,5 @@ public class ProjectGitHandler implements ReleaserPropertiesAware {
public void setReleaserProperties(ReleaserProperties properties) {
this.properties = properties;
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/gradle/GradleUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/gradle/GradleUpdater.java
index c4f3a373..dbc18154 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/gradle/GradleUpdater.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/gradle/GradleUpdater.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.gradle;
import java.io.File;
@@ -18,6 +50,7 @@ import java.util.stream.Collectors;
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;
@@ -37,10 +70,10 @@ public class GradleUpdater implements ReleaserPropertiesAware {
}
/**
- * For the given root folder (typically the working directory) performs the whole
- * flow of updating {@code gradle.properties} with values from BOM project.
- * Remember to pass the mapping from a property name inside {@code gradle.properties} to
- * the project name via {@link ReleaserProperties.Gradle#getGradlePropsSubstitution}
+ * For the given root folder (typically the working directory) performs the whole flow
+ * of updating {@code gradle.properties} with values from BOM project. Remember to
+ * pass the mapping from a property name inside {@code gradle.properties} to the
+ * project name via {@link ReleaserProperties.Gradle#getGradlePropsSubstitution}
* @param projectRoot - root folder with project to update
* @param projects - versions of projects used to update poms
* @param versionFromBom - version for the project from Spring Cloud Release
@@ -54,35 +87,42 @@ public class GradleUpdater implements ReleaserPropertiesAware {
private void processAllGradleProps(File projectRoot, Projects projects,
ProjectVersion versionFromScRelease, boolean assertVersions) {
try {
- Files.walkFileTree(projectRoot.toPath(),
- new GradlePropertiesWalker(this.properties, projects, versionFromScRelease, assertVersions));
+ Files.walkFileTree(projectRoot.toPath(), new GradlePropertiesWalker(
+ this.properties, projects, versionFromScRelease, assertVersions));
}
catch (IOException e) {
throw new IllegalStateException(e);
}
}
- @Override public void setReleaserProperties(ReleaserProperties properties) {
+ @Override
+ public void setReleaserProperties(ReleaserProperties properties) {
this.properties = properties;
}
- private class GradlePropertiesWalker extends SimpleFileVisitor {
+ private final class GradlePropertiesWalker extends SimpleFileVisitor {
private static final String GRADLE_PROPERTIES = "gradle.properties";
private final ReleaserProperties properties;
+
private final Projects projects;
+
private final boolean skipVersionAssert;
+
private final boolean assertVersions;
+
private final List unacceptableVersionPatterns;
private GradlePropertiesWalker(ReleaserProperties properties, Projects projects,
ProjectVersion versionFromScRelease, boolean assertVersions) {
this.properties = properties;
this.projects = projects;
- List unacceptableVersionPatterns = versionFromScRelease.unacceptableVersionPatterns();
+ List unacceptableVersionPatterns = versionFromScRelease
+ .unacceptableVersionPatterns();
this.unacceptableVersionPatterns = unacceptableVersionPatterns;
- this.skipVersionAssert = !assertVersions || unacceptableVersionPatterns.isEmpty();
+ this.skipVersionAssert = !assertVersions
+ || unacceptableVersionPatterns.isEmpty();
this.assertVersions = assertVersions;
}
@@ -91,12 +131,16 @@ public class GradleUpdater implements ReleaserPropertiesAware {
File file = path.toFile();
if (GRADLE_PROPERTIES.equals(file.getName())) {
if (pathIgnored(file)) {
- log.debug("Ignoring file [{}] since it's on a list of patterns to ignore", file);
+ log.debug(
+ "Ignoring file [{}] since it's on a list of patterns to ignore",
+ file);
return FileVisitResult.CONTINUE;
}
- log.info("Will process the file [{}] and update its gradle properties", file);
+ log.info("Will process the file [{}] and update its gradle properties",
+ file);
final String fileContents = asString(path);
- final AtomicReference changedString = new AtomicReference<>(fileContents);
+ final AtomicReference changedString = new AtomicReference<>(
+ fileContents);
Properties props = loadProps(file);
final Map substitution = this.properties.getGradle()
.getGradlePropsSubstitution();
@@ -104,12 +148,14 @@ public class GradleUpdater implements ReleaserPropertiesAware {
if (substitution.containsKey(key)) {
String projectName = substitution.get(key);
if (!this.projects.containsProject(projectName)) {
- log.warn("Should update project with name [{}] but it wasn't found in the list of projects [{}]", projectName, this.projects
- .asList());
+ log.warn(
+ "Should update project with name [{}] but it wasn't found in the list of projects [{}]",
+ projectName, this.projects.asList());
return;
}
ProjectVersion value = this.projects.forName(projectName);
- log.info("Replacing [{}->{}] with [{}->{}]", key, value1, key, value);
+ log.info("Replacing [{}->{}] with [{}->{}]", key, value1, key,
+ value);
changedString.set(changedString.get().replace(key + "=" + value1,
key + "=" + value));
}
@@ -122,9 +168,10 @@ public class GradleUpdater implements ReleaserPropertiesAware {
private void assertNoSnapshotsArePresent(Path path) {
if (this.assertVersions && !this.skipVersionAssert) {
- log.debug("Update should check if no wrong versions remained in the gradle prop. List of wrong patterns: {}",
- this.unacceptableVersionPatterns.stream().map(Pattern::pattern).collect(Collectors
- .toList()));
+ log.debug(
+ "Update should check if no wrong versions remained in the gradle prop. List of wrong patterns: {}",
+ this.unacceptableVersionPatterns.stream().map(Pattern::pattern)
+ .collect(Collectors.toList()));
Scanner scanner = new Scanner(asString(path));
int lineNumber = 0;
while (scanner.hasNextLine()) {
@@ -134,7 +181,10 @@ public class GradleUpdater implements ReleaserPropertiesAware {
.filter(pattern -> pattern.matcher(line).matches())
.findFirst().orElse(null);
if (matchingPattern != null) {
- throw new IllegalStateException("The file [" + path + "] matches the [ " + matchingPattern.pattern() + "] pattern in line number [" + lineNumber + "]\n\n" + line);
+ throw new IllegalStateException("The file [" + path
+ + "] matches the [ " + matchingPattern.pattern()
+ + "] pattern in line number [" + lineNumber + "]\n\n"
+ + line);
}
}
log.info("No invalid versions remained in the gradle properties");
@@ -154,8 +204,8 @@ 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);
+ return this.assertVersions && this.properties.getGradle()
+ .getIgnoredGradleRegex().stream().anyMatch(path::matches);
}
private String asString(Path path) {
@@ -175,5 +225,7 @@ public class GradleUpdater implements ReleaserPropertiesAware {
throw new IllegalStateException(e);
}
}
+
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/BomParser.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/BomParser.java
index 9a2b0f90..d5275ce9 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/BomParser.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/BomParser.java
@@ -1,18 +1,35 @@
/*
- * Copyright 2013-2019 the original author or authors.
+ * 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
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * 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.
*/
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.pom;
import java.io.File;
@@ -31,8 +48,10 @@ 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
+ * Parses the poms for a given project and populates versions from a release train.
*
* @author Marcin Grzejszczak
*/
@@ -41,12 +60,16 @@ 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;
+ 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;
@@ -59,7 +82,8 @@ class BomParser {
Versions allVersions() {
Versions boot = bootVersion();
Versions cloud = versionsFromBom();
- return new Versions(boot.bootVersion, cloud.scBuildVersion, allProjects(boot, cloud));
+ return new Versions(boot.bootVersion, cloud.scBuildVersion,
+ allProjects(boot, cloud));
}
private Set allProjects(Versions boot, Versions cloud) {
@@ -76,8 +100,10 @@ class BomParser {
}
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
+ 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();
@@ -96,27 +122,29 @@ class BomParser {
return this.pomReader.readPom(pomFile);
}
- // the BOM contains all versions of projects and its parent MUST be Spring Cloud Dependencies Parent
+ // 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 [{}]", SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildArtifact);
- if (!SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID.equals(buildArtifact)) {
- throw new IllegalStateException("The pom doesn't have a [" + SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID
- + "] artifact id");
+ 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 projects = model.getProperties().entrySet()
- .stream()
- .filter(propertyMatchesSCPattern())
- .map(toProject())
+ Set 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));
+ projects.add(
+ new Project(this.properties.getMetaRelease().getReleaseTrainProjectName(),
+ releaseTrainProjectVersion));
return new Versions(buildVersion, projects);
}
@@ -133,5 +161,5 @@ class BomParser {
return new Project(name, entry.getValue().toString());
};
}
-}
+}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/PomReader.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/PomReader.java
index e9654e8c..2f32fe37 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/PomReader.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/PomReader.java
@@ -1,18 +1,35 @@
/*
- * Copyright 2013-2019 the original author or authors.
+ * 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
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * 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.
*/
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.pom;
import java.io.File;
@@ -31,18 +48,18 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
class PomReader {
/**
- * Returns a parsed POM
+ * Returns a parsed POM.
*/
Model readPom(File file) {
File pom = file;
if (file.isDirectory()) {
- pom = new File(file,"pom.xml");
+ pom = new File(file, "pom.xml");
}
if (!pom.exists()) {
return null;
}
String fileText = "";
- try(Reader reader = new FileReader(pom)) {
+ try (Reader reader = new FileReader(pom)) {
if (file.isFile()) {
fileText = new String(Files.readAllBytes(file.toPath()));
}
@@ -51,9 +68,12 @@ class PomReader {
}
catch (XmlPullParserException | IOException e) {
if (file.isFile() && fileText.length() == 0) {
- throw new IllegalStateException("File [" + pom.getAbsolutePath() + "] is empty", e);
+ throw new IllegalStateException(
+ "File [" + pom.getAbsolutePath() + "] is empty", e);
}
- throw new IllegalStateException("Failed to read file: " + pom.getAbsolutePath(), e);
+ throw new IllegalStateException(
+ "Failed to read file: " + pom.getAbsolutePath(), e);
}
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/PomUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/PomUpdater.java
index f51b9540..6b2d34d6 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/PomUpdater.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/PomUpdater.java
@@ -1,18 +1,35 @@
/*
- * Copyright 2013-2019 the original author or authors.
+ * 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
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * 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.
*/
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.pom;
import java.io.BufferedWriter;
@@ -21,6 +38,7 @@ import java.io.FileWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
+
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
@@ -37,6 +55,7 @@ import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.stax2.XMLInputFactory2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
import org.springframework.util.StringUtils;
import static org.springframework.util.StringUtils.hasText;
@@ -50,12 +69,12 @@ 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.
- *
+ * 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
* @return {@code true} if the project is on the list of projects to be updated
@@ -70,18 +89,20 @@ class PomUpdater {
log.info("Failed to read the model");
return false;
}
- String artifactId = artifactId(model);
+ String artifactId = artifactId(model);
if (!versions.shouldBeUpdated(artifactId)) {
- log.info("Skipping project [{}] since it's not on the list of projects to update", model.getArtifactId());
+ log.info(
+ "Skipping project [{}] since it's not on the list of projects to update",
+ model.getArtifactId());
return false;
}
- log.info("Project [{}] will have its dependencies updated", model.getArtifactId());
+ log.info("Project [{}] will have its dependencies updated",
+ model.getArtifactId());
return true;
}
boolean hasSkipDeployment(Model model) {
- String property = model.getProperties()
- .getProperty("maven.deploy.skip");
+ String property = model.getProperties().getProperty("maven.deploy.skip");
boolean hasSkipDeploymentProperty = Boolean.parseBoolean(property);
if (hasSkipDeploymentProperty) {
return true;
@@ -89,28 +110,20 @@ class PomUpdater {
if (model.getBuild() == null) {
return false;
}
- boolean plugins = model.getBuild()
- .getPlugins()
- .stream()
- .filter(plugin -> "maven-deploy-plugin".equalsIgnoreCase(plugin.getArtifactId()))
- .map(this::skipFromConfiguration)
- .findFirst()
- .orElse(false);
+ boolean plugins = model.getBuild().getPlugins().stream()
+ .filter(plugin -> "maven-deploy-plugin"
+ .equalsIgnoreCase(plugin.getArtifactId()))
+ .map(this::skipFromConfiguration).findFirst().orElse(false);
if (plugins) {
return true;
}
- if (model.getBuild()
- .getPluginManagement() == null) {
+ if (model.getBuild().getPluginManagement() == null) {
return false;
}
- return model.getBuild()
- .getPluginManagement()
- .getPlugins()
- .stream()
- .filter(plugin -> "maven-deploy-plugin".equalsIgnoreCase(plugin.getArtifactId()))
- .map(this::skipFromConfiguration)
- .findFirst()
- .orElse(false);
+ return model.getBuild().getPluginManagement().getPlugins().stream()
+ .filter(plugin -> "maven-deploy-plugin"
+ .equalsIgnoreCase(plugin.getArtifactId()))
+ .map(this::skipFromConfiguration).findFirst().orElse(false);
}
private Boolean skipFromConfiguration(Plugin plugin) {
@@ -134,16 +147,16 @@ class PomUpdater {
if (!parent) {
return model.getArtifactId();
}
- return model.getArtifactId().substring(0, model.getArtifactId().indexOf("-parent"));
+ return model.getArtifactId().substring(0,
+ model.getArtifactId().indexOf("-parent"));
}
ModelWrapper readModel(File pom) {
return new ModelWrapper(this.pomReader.readPom(pom));
}
- /**q
- * Updates the root / child module model
- *
+ /**
+ * Updates the root / child module model.
* @param rootPom - root project model
* @param pom - file with the pom
* @param versions - versions to update
@@ -158,9 +171,8 @@ class PomUpdater {
}
/**
- * Overwrites the pom.xml with data from {@link ModelWrapper} only if there were
- * any changes in the model.
- *
+ * Overwrites the pom.xml with data from {@link ModelWrapper} only if there were any
+ * changes in the model.
* @return - the pom file
*/
File overwritePomIfDirty(ModelWrapper updatedPomModel, Versions versions, File pom) {
@@ -172,8 +184,8 @@ class PomUpdater {
return pom;
}
- private List updateParentIfPossible(ModelWrapper wrapper, Versions versions,
- Model model, List sourceChanges) {
+ private List updateParentIfPossible(ModelWrapper wrapper,
+ Versions versions, Model model, List sourceChanges) {
String rootProjectName = wrapper.projectName();
List changes = new ArrayList<>(sourceChanges);
if (model.getParent() == null || isEmpty(model.getParent().getVersion())) {
@@ -182,39 +194,48 @@ class PomUpdater {
}
String parentGroupId = model.getParent().getGroupId();
String parentArtifactId = model.getParent().getArtifactId();
- log.debug("Searching for a version of parent [{}:{}]", parentGroupId, parentArtifactId);
+ log.debug("Searching for a version of parent [{}:{}]", parentGroupId,
+ parentArtifactId);
String oldVersion = model.getParent().getVersion();
String version = versions.versionForProject(parentArtifactId);
log.debug("Found version is [{}]", version);
if (isEmpty(version)) {
if (hasText(model.getParent().getRelativePath())) {
version = versions.versionForProject(rootProjectName);
- } else {
- log.warn("There is no info on the [{}:{}] version", parentGroupId, parentArtifactId);
+ }
+ else {
+ log.warn("There is no info on the [{}:{}] version", parentGroupId,
+ parentArtifactId);
return changes;
}
}
if (oldVersion.equals(version)) {
- log.debug("Won't update the version of parent [{}:{}] since you're already using the proper one", parentGroupId, parentArtifactId);
+ log.debug(
+ "Won't update the version of parent [{}:{}] since you're already using the proper one",
+ parentGroupId, parentArtifactId);
return changes;
}
- log.info("Setting version of parent [{}] to [{}] for module [{}]", parentArtifactId,
- version, model.getArtifactId());
+ log.info("Setting version of parent [{}] to [{}] for module [{}]",
+ parentArtifactId, version, model.getArtifactId());
if (hasText(version)) {
- changes.add(new VersionChange(parentGroupId, parentArtifactId, oldVersion, version));
+ changes.add(new VersionChange(parentGroupId, parentArtifactId, oldVersion,
+ version));
}
return changes;
}
- private List updateVersionIfPossible(ModelWrapper wrapper, Versions versions,
- Model model, List sourceChanges) {
+ private List updateVersionIfPossible(ModelWrapper wrapper,
+ Versions versions, Model model, List sourceChanges) {
String rootProjectName = wrapper.projectName();
String rootProjectGroupId = wrapper.groupId();
List changes = new ArrayList<>(sourceChanges);
String groupId = groupId(model);
String artifactId = model.getArtifactId();
- if (model.getGroupId() != null && !model.getGroupId().equals(rootProjectGroupId)) {
- log.info("Will not update project [{}] since its group id [{}] is not equal the parent group id [{}]", model.getArtifactId(), model.getGroupId(), rootProjectGroupId);
+ if (model.getGroupId() != null
+ && !model.getGroupId().equals(rootProjectGroupId)) {
+ log.info(
+ "Will not update project [{}] since its group id [{}] is not equal the parent group id [{}]",
+ model.getArtifactId(), model.getGroupId(), rootProjectGroupId);
return changes;
}
log.debug("Searching for a version [{}:{}]", groupId, artifactId);
@@ -222,11 +243,15 @@ class PomUpdater {
String version = versions.versionForProject(rootProjectName);
log.debug("Found version is [{}]", version);
if (isEmpty(version) || isEmpty(model.getVersion())) {
- log.debug("There was no version set for project [{}], skipping version setting for module [{}]", rootProjectName, model.getArtifactId());
+ log.debug(
+ "There was no version set for project [{}], skipping version setting for module [{}]",
+ rootProjectName, model.getArtifactId());
return changes;
}
if (oldVersion.equals(version)) {
- log.debug("Won't update the version of module [{}]:[{}] since you're already using the proper one", groupId, artifactId);
+ log.debug(
+ "Won't update the version of module [{}]:[{}] since you're already using the proper one",
+ groupId, artifactId);
return changes;
}
log.info("Setting [{}] version to [{}]", artifactId, version);
@@ -243,11 +268,15 @@ class PomUpdater {
}
return "";
}
+
}
class ModelWrapper {
+
final Model model;
+
final Versions versions;
+
final List sourceChanges = new ArrayList<>();
ModelWrapper(Model model, List sourceChanges, Versions versions) {
@@ -269,13 +298,14 @@ class ModelWrapper {
if (this.model.getGroupId() != null) {
return this.model.getGroupId();
}
- return this.model.getParent() != null ?
- this.model.getParent().getGroupId() : "";
+ return this.model.getParent() != null ? this.model.getParent().getGroupId() : "";
}
boolean isDirty() {
- return !this.sourceChanges.isEmpty() || this.versions.shouldSetProperty(this.model.getProperties());
+ return !this.sourceChanges.isEmpty()
+ || this.versions.shouldSetProperty(this.model.getProperties());
}
+
}
class PomWriter {
@@ -291,9 +321,11 @@ class PomWriter {
LoggerToMavenLog loggerToMavenLog = new LoggerToMavenLog(PomWriter.log);
versionChangerFactory.setLog(loggerToMavenLog);
versionChangerFactory.setModel(wrapper.model);
- log.info("Applying version / parent / plugin / project changes to the pom [{}]", pom);
- VersionChanger changer = versionChangerFactory.newVersionChanger( true,
- true, true, true);
+ log.info(
+ "Applying version / parent / plugin / project changes to the pom [{}]",
+ pom);
+ VersionChanger changer = versionChangerFactory.newVersionChanger(true, true,
+ true, true);
for (VersionChange versionChange : wrapper.sourceChanges) {
changer.apply(versionChange);
}
@@ -304,14 +336,15 @@ class PomWriter {
bw.write(input.toString());
}
log.debug("Flushed changes to the pom file [{}]", pom);
- } catch (Exception e) {
+ }
+ catch (Exception e) {
log.error("Exception occurred while trying to apply changes to the POM", e);
}
}
/**
- * Creates a {@link org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader} from a StringBuilder.
- *
+ * Creates a {@link org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader}
+ * from a StringBuilder.
* @param input The XML to read and modify.
* @return The {@link org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader}.
*/
@@ -327,48 +360,52 @@ class PomWriter {
}
return newPom;
}
+
}
class PropertyVersionChanger extends AbstractVersionChanger {
private final Versions versions;
+
private final PropertyStorer propertyStorer;
- PropertyVersionChanger(ModelWrapper wrapper, Versions versions, ModifiedPomXMLEventReader pom, Log log) {
+ PropertyVersionChanger(ModelWrapper wrapper, Versions versions,
+ ModifiedPomXMLEventReader pom, Log log) {
super(wrapper.model, pom, log);
this.versions = versions;
this.propertyStorer = new PropertyStorer(log, pom);
}
- PropertyVersionChanger(ModelWrapper wrapper, Versions versions, ModifiedPomXMLEventReader pom, Log log, PropertyStorer propertyStorer) {
+ PropertyVersionChanger(ModelWrapper wrapper, Versions versions,
+ ModifiedPomXMLEventReader pom, Log log, PropertyStorer propertyStorer) {
super(wrapper.model, pom, log);
this.versions = versions;
this.propertyStorer = propertyStorer;
}
- @Override public void apply(final VersionChange versionChange) {
- this.versions.projects
- .stream()
- .filter(project -> {
- Properties properties = getModel().getProperties();
- String projectVersionKey = propertyName(project);
- if (!properties.containsKey(projectVersionKey)) {
- return false;
- }
- String version = properties.getProperty(projectVersionKey);
- return !version.equals(project.version);
- })
- .forEach(this.propertyStorer::setPropertyVersionIfApplicable);
+ @Override
+ public void apply(final VersionChange versionChange) {
+ this.versions.projects.stream().filter(project -> {
+ Properties properties = getModel().getProperties();
+ String projectVersionKey = propertyName(project);
+ if (!properties.containsKey(projectVersionKey)) {
+ return false;
+ }
+ String version = properties.getProperty(projectVersionKey);
+ return !version.equals(project.version);
+ }).forEach(this.propertyStorer::setPropertyVersionIfApplicable);
}
private String propertyName(Project project) {
return project.name + ".version";
}
+
}
class PropertyStorer {
private final Log log;
+
private final ModifiedPomXMLEventReader pom;
PropertyStorer(Log log, ModifiedPomXMLEventReader pom) {
@@ -379,7 +416,8 @@ class PropertyStorer {
void setPropertyVersionIfApplicable(Project project) {
String propertyName = propertyName(project);
if (setPropertyVersion(propertyName, project.version)) {
- this.log.info("Updating property [" + propertyName + "] to version [" + project.version + "]");
+ this.log.info("Updating property [" + propertyName + "] to version ["
+ + project.version + "]");
}
}
@@ -390,7 +428,8 @@ class PropertyStorer {
private boolean setPropertyVersion(String propertyName, String version) {
try {
if (StringUtils.isEmpty(version)) {
- this.log.warn("Version for [" + propertyName + "] is empty. Will not set it");
+ this.log.warn(
+ "Version for [" + propertyName + "] is empty. Will not set it");
return false;
}
return PomHelper.setPropertyVersion(this.pom, null, propertyName, version);
@@ -400,6 +439,7 @@ class PropertyStorer {
return false;
}
}
+
}
class LoggerToMavenLog implements Log {
@@ -410,67 +450,84 @@ class LoggerToMavenLog implements Log {
this.logger = logger;
}
- @Override public boolean isDebugEnabled() {
+ @Override
+ public boolean isDebugEnabled() {
return this.logger.isDebugEnabled();
}
- @Override public void debug(CharSequence content) {
+ @Override
+ public void debug(CharSequence content) {
this.logger.debug(content.toString());
}
- @Override public void debug(CharSequence content, Throwable error) {
+ @Override
+ public void debug(CharSequence content, Throwable error) {
this.logger.debug(content.toString(), error);
}
- @Override public void debug(Throwable error) {
+ @Override
+ public void debug(Throwable error) {
this.debug("Exception occurred", error);
}
- @Override public boolean isInfoEnabled() {
+ @Override
+ public boolean isInfoEnabled() {
return this.logger.isInfoEnabled();
}
- @Override public void info(CharSequence content) {
+ @Override
+ public void info(CharSequence content) {
this.logger.info(content.toString());
}
- @Override public void info(CharSequence content, Throwable error) {
+ @Override
+ public void info(CharSequence content, Throwable error) {
this.logger.info(content.toString(), error);
}
- @Override public void info(Throwable error) {
+ @Override
+ public void info(Throwable error) {
this.info("Exception occurred", error);
}
- @Override public boolean isWarnEnabled() {
+ @Override
+ public boolean isWarnEnabled() {
return this.logger.isWarnEnabled();
}
- @Override public void warn(CharSequence content) {
+ @Override
+ public void warn(CharSequence content) {
this.logger.warn(content.toString());
}
- @Override public void warn(CharSequence content, Throwable error) {
+ @Override
+ public void warn(CharSequence content, Throwable error) {
this.logger.warn(content.toString(), error);
}
- @Override public void warn(Throwable error) {
+ @Override
+ public void warn(Throwable error) {
this.warn("Exception occurred", error);
}
- @Override public boolean isErrorEnabled() {
+ @Override
+ public boolean isErrorEnabled() {
return this.logger.isErrorEnabled();
}
- @Override public void error(CharSequence content) {
+ @Override
+ public void error(CharSequence content) {
this.logger.error(content.toString());
}
- @Override public void error(CharSequence content, Throwable error) {
+ @Override
+ public void error(CharSequence content, Throwable error) {
this.logger.error(content.toString(), error);
}
- @Override public void error(Throwable error) {
+ @Override
+ public void error(Throwable error) {
this.error("Exception occurred", error);
}
-}
\ No newline at end of file
+
+}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectPomUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectPomUpdater.java
index 842d389b..13cd2a8b 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectPomUpdater.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectPomUpdater.java
@@ -1,18 +1,35 @@
/*
- * Copyright 2013-2019 the original author or authors.
+ * 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
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * 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.
*/
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.pom;
import java.io.File;
@@ -31,6 +48,7 @@ import java.util.stream.Collectors;
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.git.ProjectGitHandler;
@@ -43,15 +61,16 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
private static final List IGNORED_SNAPSHOT_LINE_PATTERNS = Arrays.asList(
"^.*replace=.*$",
// issue [#80]
- "^[\\s]*.*$"
- );
+ "^[\\s]*.*$");
private static final Logger log = LoggerFactory.getLogger(ProjectPomUpdater.class);
- private ReleaserProperties properties;
private final ProjectGitHandler gitRepo;
+
private final PomUpdater pomUpdater = new PomUpdater();
+ private ReleaserProperties properties;
+
public ProjectPomUpdater(ReleaserProperties properties) {
this.properties = properties;
this.gitRepo = new ProjectGitHandler(properties);
@@ -63,15 +82,17 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
}
/**
- * For the given root folder (typically the working directory) retrieves list of versions
- * for a given release version.
+ * For the given root folder (typically the working directory) retrieves list of
+ * versions for a given release version.
+ * @return projects retrieved from the release train bom
*/
public Projects retrieveVersionsFromReleaseTrainBom() {
File clonedScRelease = this.gitRepo.cloneReleaseTrainProject();
this.gitRepo.checkout(clonedScRelease, this.properties.getPom().getBranch());
BomParser sCReleasePomParser = new BomParser(this.properties, clonedScRelease);
Versions versions = sCReleasePomParser.allVersions();
- log.info("Will update the following versions manually [{}]", this.properties.getFixedVersions());
+ log.info("Will update the following versions manually [{}]",
+ this.properties.getFixedVersions());
this.properties.getFixedVersions().forEach(versions::setVersion);
log.info("Retrieved the following versions\n{}", versions);
return versions.toProjectVersions();
@@ -82,8 +103,7 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
*/
public Projects fixedVersions() {
Set projectVersions = this.properties.getFixedVersions()
- .entrySet()
- .stream()
+ .entrySet().stream()
.map(entry -> new ProjectVersion(entry.getKey(), entry.getValue()))
.collect(Collectors.toSet());
if (log.isDebugEnabled()) {
@@ -93,13 +113,13 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
}
/**
- * For the given root folder (typically the working directory) performs the whole
- * flow of updating {@code pom.xml} with values from release train
- * (e.g. Spring Cloud Release project.)
+ * For the given root folder (typically the working directory) performs the whole flow
+ * of updating {@code pom.xml} with values from release train (e.g. Spring Cloud
+ * Release project.)
* @param projectRoot - root folder with project to update
* @param projects - versions of projects used to update poms
- * @param versionFromReleaseTrain - version for the built project taken
- * from release train (e.g. Spring Cloud Release project)
+ * @param versionFromReleaseTrain - version for the built project taken from release
+ * train (e.g. Spring Cloud Release project)
* @param assertVersions - should version assertion take place
*/
public void updateProjectFromReleaseTrain(File projectRoot, Projects projects,
@@ -133,20 +153,27 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
}
}
- @Override public void setReleaserProperties(ReleaserProperties properties) {
+ @Override
+ public void setReleaserProperties(ReleaserProperties properties) {
this.properties = properties;
}
- private class PomWalker extends SimpleFileVisitor {
+ private final class PomWalker extends SimpleFileVisitor {
private static final String POM_XML = "pom.xml";
private final ModelWrapper rootPom;
+
private final Versions versions;
+
private final PomUpdater pomUpdater;
+
private final ReleaserProperties properties;
+
private final boolean skipVersionAssert;
+
private final boolean assertVersions;
+
private final List unacceptableVersionPatterns;
private PomWalker(ModelWrapper rootPom, Projects projects, PomUpdater pomUpdater,
@@ -156,9 +183,11 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
this.versions = new Versions(projects, properties);
this.pomUpdater = pomUpdater;
this.properties = properties;
- List unacceptableVersionPatterns = versionFromScRelease.unacceptableVersionPatterns();
+ List unacceptableVersionPatterns = versionFromScRelease
+ .unacceptableVersionPatterns();
this.unacceptableVersionPatterns = unacceptableVersionPatterns;
- this.skipVersionAssert = !assertVersions || unacceptableVersionPatterns.isEmpty();
+ this.skipVersionAssert = !assertVersions
+ || unacceptableVersionPatterns.isEmpty();
this.assertVersions = assertVersions;
}
@@ -167,25 +196,34 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
File file = path.toFile();
if (POM_XML.equals(file.getName())) {
if (pathIgnored(file)) {
- log.debug("Ignoring file [{}] since it's on a list of patterns to ignore", file);
+ log.debug(
+ "Ignoring file [{}] since it's on a list of patterns to ignore",
+ file);
return FileVisitResult.CONTINUE;
}
- ModelWrapper model = this.pomUpdater.updateModel(this.rootPom, file, this.versions);
+ ModelWrapper model = this.pomUpdater.updateModel(this.rootPom, file,
+ this.versions);
this.pomUpdater.overwritePomIfDirty(model, this.versions, 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");
+ 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));
int lineNumber = 0;
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
lineNumber++;
- Pattern matchingPattern = this.unacceptableVersionPatterns.stream()
- .filter(pattern ->
- IGNORED_SNAPSHOT_LINE_PATTERNS.stream().noneMatch(line::matches) &&
- pattern.matcher(line).matches())
+ Pattern matchingPattern = this.unacceptableVersionPatterns
+ .stream()
+ .filter(pattern -> IGNORED_SNAPSHOT_LINE_PATTERNS.stream()
+ .noneMatch(line::matches)
+ && pattern.matcher(line).matches())
.findFirst().orElse(null);
if (matchingPattern != null) {
- throw new IllegalStateException("The file [" + path + "] matches the [ " + matchingPattern.pattern() + "] pattern in line number [" + lineNumber + "]\n\n" + line);
+ throw new IllegalStateException("The file [" + path
+ + "] matches the [ " + matchingPattern.pattern()
+ + "] pattern in line number [" + lineNumber + "]\n\n"
+ + line);
}
}
log.info("No invalid versions remained in the pom");
@@ -196,8 +234,8 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
private boolean pathIgnored(File file) {
String path = file.getPath();
- return this.assertVersions &&
- this.properties.getPom().getIgnoredPomRegex().stream().anyMatch(path::matches);
+ return this.assertVersions && this.properties.getPom().getIgnoredPomRegex()
+ .stream().anyMatch(path::matches);
}
private String asString(Path path) {
@@ -208,7 +246,7 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
throw new IllegalStateException(e);
}
}
+
}
+
}
-
-
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectVersion.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectVersion.java
index 6a2f9177..b555d48f 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectVersion.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/ProjectVersion.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.pom;
import java.io.File;
@@ -12,18 +44,30 @@ import org.apache.maven.model.Model;
import org.springframework.util.StringUtils;
/**
- * Object representing a root project's version.
- * Knows how to provide a minor bumped version;
+ * Object representing a root project's version. Knows how to provide a minor bumped
+ * version;
*
* @author Marcin Grzejszczak
*/
public class ProjectVersion {
- private static final Pattern SNAPSHOT_PATTERN = Pattern.compile("^.*\\.(BUILD-)?SNAPSHOT.*$");
+ private static final Pattern SNAPSHOT_PATTERN = Pattern
+ .compile("^.*\\.(BUILD-)?SNAPSHOT.*$");
+
private static final String MILESTONE_REGEX = ".*\\.M[0-9]+";
+
private static final String RC_REGEX = "^.*\\.RC.*$";
+
+ /**
+ * Name of the project.
+ */
public final String projectName;
+
+ /**
+ * Version of the project.
+ */
public final String version;
+
private final Model model;
public ProjectVersion(String projectName, String version) {
@@ -38,7 +82,8 @@ public class ProjectVersion {
this.projectName = projectVersion.projectName;
this.version = projectVersion.version;
this.model = null;
- } else {
+ }
+ else {
PomReader pomReader = new PomReader();
Model model = pomReader.readPom(project);
this.projectName = nameWithoutParent(model.getArtifactId());
@@ -71,27 +116,28 @@ public class ProjectVersion {
return this.version;
}
Integer incrementedPatch = Integer.valueOf(splitVersion[2]) + 1;
- return String.format("%s.%s.%s.%s", splitVersion[0], splitVersion[1], incrementedPatch, splitVersion[3]);
+ return String.format("%s.%s.%s.%s", splitVersion[0], splitVersion[1],
+ incrementedPatch, splitVersion[3]);
}
-
private String[] assertVersion() {
if (this.version == null) {
throw new IllegalStateException("Version can't be null!");
}
// 1.0.0.BUILD-SNAPSHOT
String[] splitVersion = this.version.split("\\.");
- if (splitVersion.length < 4 && isNumeric(splitVersion[0]) ||
- splitVersion.length == 1 && !isNumeric(splitVersion[0])) {
- throw new IllegalStateException("Version is invalid. Should be of format [1.2.3.A]");
+ if (splitVersion.length < 4 && isNumeric(splitVersion[0])
+ || splitVersion.length == 1 && !isNumeric(splitVersion[0])) {
+ throw new IllegalStateException(
+ "Version is invalid. Should be of format [1.2.3.A]");
}
return splitVersion;
}
/**
- * For GA and SR will bump the snapshots
- * in the rest of cases will return snapshot of the current version
- * @return
+ * For GA and SR will bump the snapshots in the rest of cases will return snapshot of
+ * the current version.
+ * @return the post release snapshot version
*/
public String postReleaseSnapshotVersion() {
String[] strings = assertVersion();
@@ -118,7 +164,8 @@ public class ProjectVersion {
if (StringUtils.hasText(this.model.getGroupId())) {
return this.model.getGroupId();
}
- if (this.model.getParent() != null && StringUtils.hasText(this.model.getParent().getGroupId())) {
+ if (this.model.getParent() != null
+ && StringUtils.hasText(this.model.getParent().getGroupId())) {
return this.model.getParent().getGroupId();
}
return "";
@@ -128,7 +175,8 @@ public class ProjectVersion {
try {
assertVersion();
return true;
- } catch (IllegalStateException e) {
+ }
+ catch (IllegalStateException e) {
return false;
}
}
@@ -167,8 +215,8 @@ public class ProjectVersion {
}
String[] splitThis = this.version.split("\\.");
String[] splitThat = version.split("\\.");
- return splitThis.length == splitThat.length &&
- splitThis[0].equals(splitThat[0]) && splitThis[1].equals(splitThat[1]);
+ return splitThis.length == splitThat.length && splitThis[0].equals(splitThat[0])
+ && splitThis[1].equals(splitThat[1]);
}
public boolean isSameReleaseTrainName(String version) {
@@ -199,35 +247,44 @@ public class ProjectVersion {
return new VersionNumber(thisValue).compareTo(new VersionNumber(thatValue));
}
- @Override public String toString() {
+ @Override
+ public String toString() {
return this.version;
}
- @Override public boolean equals(Object o) {
- if (this == o)
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
return true;
- if (o == null || getClass() != o.getClass())
+ }
+ if (o == null || getClass() != o.getClass()) {
return false;
+ }
ProjectVersion that = (ProjectVersion) o;
return Objects.equals(this.projectName, that.projectName);
}
- @Override public int hashCode() {
+ @Override
+ public int hashCode() {
return Objects.hash(this.projectName);
}
public List unacceptableVersionPatterns() {
if (isSnapshot()) {
return Collections.emptyList();
- } else if (isMilestone() || isRc()) {
+ }
+ else if (isMilestone() || isRc()) {
return Collections.singletonList(SNAPSHOT_PATTERN);
}
// treat like GA
- return Arrays.asList(SNAPSHOT_PATTERN, Pattern.compile(MILESTONE_REGEX), Pattern.compile(RC_REGEX));
+ return Arrays.asList(SNAPSHOT_PATTERN, Pattern.compile(MILESTONE_REGEX),
+ Pattern.compile(RC_REGEX));
}
+
}
class VersionNumber implements Comparable {
+
private final String version;
VersionNumber(String version) {
@@ -256,4 +313,5 @@ class VersionNumber implements Comparable {
Integer thatNumber = Integer.valueOf(thatVersion);
return thisNumber.compareTo(thatNumber);
}
-}
\ No newline at end of file
+
+}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Projects.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Projects.java
index 58f5b6fa..d76482be 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Projects.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Projects.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.pom;
import java.io.File;
@@ -11,7 +43,7 @@ import java.util.stream.Collectors;
import org.springframework.cloud.release.internal.ReleaserProperties;
/**
- * Abstraction over collection of projects
+ * Abstraction over collection of projects.
*
* @author Marcin Grzejszczak
*/
@@ -23,21 +55,38 @@ public class Projects extends HashSet {
@SuppressWarnings("unchecked")
public Projects(ProjectVersion... versions) {
- addAll(new HashSet<>(Arrays.stream(versions).filter(Objects::nonNull).collect(Collectors.toList())));
+ addAll(new HashSet<>(Arrays.stream(versions).filter(Objects::nonNull)
+ .collect(Collectors.toList())));
}
- public static Projects forRollback(Projects projects, ProjectVersion originalVersion) {
+ public static Projects forRollback(Projects projects,
+ ProjectVersion originalVersion) {
Projects newProjects = new Projects();
- newProjects.add(new ProjectVersion(originalVersion.projectName, originalVersion.bumpedVersion()));
- newProjects.addAll(projects.forNameStartingWith(SpringCloudConstants.SPRING_BOOT));
+ newProjects.add(new ProjectVersion(originalVersion.projectName,
+ originalVersion.bumpedVersion()));
+ newProjects
+ .addAll(projects.forNameStartingWith(SpringCloudConstants.SPRING_BOOT));
return newProjects;
}
+ private static IllegalStateException exception(Projects projects,
+ String projectName) {
+ return new IllegalStateException("Project with name [" + projectName
+ + "] is not present in the list of projects [" + projects.asList()
+ + "] . " + additionalErrorMessage(projectName));
+ }
+
+ private static String additionalErrorMessage(String projectName) {
+ return "Either put it in the Spring Cloud Release project or set it via the [--releaser.fixed-versions["
+ + projectName + "]=1.0.0.RELEASE] property";
+ }
+
public ProjectVersion releaseTrain(ReleaserProperties properties) {
return this.forName(properties.getMetaRelease().getReleaseTrainProjectName());
}
- @Override public boolean add(ProjectVersion projectVersion) {
+ @Override
+ public boolean add(ProjectVersion projectVersion) {
if (projectVersion == null) {
return false;
}
@@ -45,17 +94,15 @@ public class Projects extends HashSet {
}
public Projects filter(List projectsToSkip) {
- return this.stream()
- .filter(v -> !projectsToSkip.contains(v.projectName))
+ return this.stream().filter(v -> !projectsToSkip.contains(v.projectName))
.collect(Collectors.toCollection(Projects::new));
}
public Projects postReleaseSnapshotVersion(List projectsToSkip) {
- Projects projects = this.stream()
- .filter(v -> projectsToSkip(projectsToSkip, v))
+ Projects projects = this.stream().filter(v -> projectsToSkip(projectsToSkip, v))
.collect(Collectors.toCollection(Projects::new));
- Projects bumped = this.stream()
- .map(v -> new ProjectVersion(v.projectName, v.postReleaseSnapshotVersion()))
+ Projects bumped = this.stream().map(
+ v -> new ProjectVersion(v.projectName, v.postReleaseSnapshotVersion()))
.collect(Collectors.toCollection(Projects::new));
Projects merged = new Projects(projects);
merged.addAll(bumped);
@@ -73,35 +120,26 @@ public class Projects extends HashSet {
public ProjectVersion forFile(File projectRoot) {
final ProjectVersion thisProject = new ProjectVersion(projectRoot);
- return this.stream().filter(projectVersion -> projectVersion.projectName.equals(thisProject.projectName))
- .findFirst()
- .orElseThrow(() -> exception(this, thisProject.projectName));
- }
-
- private static IllegalStateException exception(Projects projects, String projectName) {
- return new IllegalStateException(
- "Project with name [" + projectName + "] is not present in the list of projects [" + projects.asList() + "] . "
- + additionalErrorMessage(projectName));
- }
-
- private static String additionalErrorMessage(String projectName) {
- return "Either put it in the Spring Cloud Release project or set it via the [--releaser.fixed-versions["
- + projectName + "]=1.0.0.RELEASE] property";
+ return this.stream()
+ .filter(projectVersion -> projectVersion.projectName
+ .equals(thisProject.projectName))
+ .findFirst().orElseThrow(() -> exception(this, thisProject.projectName));
}
public ProjectVersion forName(String projectName) {
- return this.stream().filter(projectVersion -> projectVersion.projectName.equals(projectName))
- .findFirst()
- .orElseThrow(() -> exception(this, projectName));
+ return this.stream()
+ .filter(projectVersion -> projectVersion.projectName.equals(projectName))
+ .findFirst().orElseThrow(() -> exception(this, projectName));
}
public boolean containsProject(String projectName) {
- return this.stream()
- .anyMatch(projectVersion -> projectVersion.projectName.equals(projectName));
+ return this.stream().anyMatch(
+ projectVersion -> projectVersion.projectName.equals(projectName));
}
public List forNameStartingWith(String projectName) {
- return this.stream().filter(projectVersion -> projectVersion.projectName.startsWith(projectName))
+ return this.stream().filter(
+ projectVersion -> projectVersion.projectName.startsWith(projectName))
.collect(Collectors.toList());
}
@@ -110,6 +148,8 @@ public class Projects extends HashSet {
}
public String asList() {
- return this.stream().map(version -> version.projectName + ":" + version.version).collect(Collectors.joining(","));
+ return this.stream().map(version -> version.projectName + ":" + version.version)
+ .collect(Collectors.joining(","));
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/SpringCloudConstants.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/SpringCloudConstants.java
index 0fc8e70e..54e367d1 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/SpringCloudConstants.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/SpringCloudConstants.java
@@ -1,17 +1,33 @@
/*
- * Copyright 2013-2019 the original author or authors.
+ * 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
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * 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.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.springframework.cloud.release.internal.pom;
@@ -20,9 +36,11 @@ package org.springframework.cloud.release.internal.pom;
* @author Marcin Grzejszczak
*/
final class SpringCloudConstants {
+
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_STARTER_PARENT_ARTIFACT_ID = BOOT_STARTER_ARTIFACT_ID
+ + "-parent";
static final String BOOT_DEPENDENCIES_ARTIFACT_ID = "spring-boot-dependencies";
static final String CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID = "spring-cloud-dependencies-parent";
static final String BUILD_ARTIFACT_ID = "spring-cloud-build";
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Versions.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Versions.java
index 51ded225..5798e587 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Versions.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/pom/Versions.java
@@ -1,18 +1,35 @@
/*
- * Copyright 2013-2019 the original author or authors.
+ * 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
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * 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.
*/
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.pom;
import java.io.File;
@@ -31,18 +48,22 @@ import static org.springframework.cloud.release.internal.pom.SpringCloudConstant
import static org.springframework.cloud.release.internal.pom.SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID;
/**
- * Represents versions taken out from Spring Cloud Release pom
+ * Represents versions taken out from Spring Cloud Release pom.
*
* @author Marcin Grzejszczak
*/
class Versions {
- private static final String SPRING_BOOT_PROJECT_NAME = "spring-boot";
static final Versions EMPTY_VERSION = new Versions("");
+ private static final String SPRING_BOOT_PROJECT_NAME = "spring-boot";
+
String bootVersion;
+
String scBuildVersion;
+
Set projects = new HashSet<>();
+
ReleaserProperties properties;
Versions(String bootVersion) {
@@ -65,7 +86,8 @@ class Versions {
this(new ReleaserProperties(), bootVersion, scBuildVersion, projects);
}
- Versions(ReleaserProperties properties, String bootVersion, String scBuildVersion, Set projects) {
+ Versions(ReleaserProperties properties, String bootVersion, String scBuildVersion,
+ Set projects) {
this.properties = properties;
this.bootVersion = bootVersion;
this.scBuildVersion = scBuildVersion;
@@ -79,11 +101,16 @@ class Versions {
Versions(Set 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))
+ 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));
+ versions.forEach(projectVersion -> setVersion(projectVersion.projectName,
+ projectVersion.version));
}
private String bomProjectName() {
@@ -100,11 +127,8 @@ class Versions {
}
String versionForProject(String projectName) {
- return this.projects.stream()
- .filter(project -> nameMatches(projectName, project))
- .findFirst()
- .orElse(Project.EMPTY_PROJECT)
- .version;
+ return this.projects.stream().filter(project -> nameMatches(projectName, project))
+ .findFirst().orElse(Project.EMPTY_PROJECT).version;
}
boolean shouldBeUpdated(String projectName) {
@@ -133,20 +157,23 @@ class Versions {
}
boolean parent = matchesNameWithSuffix(projectName, "-parent", project);
boolean bomArtifactId = comparisonOfBomArtifactAndParent(projectName, project);
- return !bomArtifactId &&
- (parent || matchesNameWithSuffix(projectName, "-dependencies", 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 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());
+ return projectName.equals(dependenciesArtifactId())
+ && otherProjectName.equals(dependenciesParentArtifactId());
}
- private boolean matchesNameWithSuffix(String projectName, String suffix, Project project) {
+ private boolean matchesNameWithSuffix(String projectName, String suffix,
+ Project project) {
boolean containsSuffix = projectName.endsWith(suffix);
if (!containsSuffix) {
return false;
@@ -157,29 +184,30 @@ class Versions {
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);
- }
+ 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 bomVersionProjectNames() {
- List names = new ArrayList<>(this.properties.getMetaRelease()
- .getReleaseTrainDependencyNames());
+ List names = new ArrayList<>(
+ this.properties.getMetaRelease().getReleaseTrainDependencyNames());
names.add(this.properties.getMetaRelease().getReleaseTrainProjectName());
return names;
}
@@ -217,11 +245,14 @@ class Versions {
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"));
+ @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"));
}
+
}
/**
@@ -232,6 +263,7 @@ class Project {
static Project EMPTY_PROJECT = new Project("", "");
final String name;
+
final String version;
Project(String name, String version) {
@@ -239,26 +271,32 @@ class Project {
this.version = version;
}
- @Override public boolean equals(Object o) {
- if (this == o)
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
return true;
- if (o == null || getClass() != o.getClass())
+ }
+ if (o == null || getClass() != o.getClass()) {
return false;
+ }
Project project = (Project) o;
- if (this.name != null ? !this.name.equals(project.name) : project.name != null)
+ 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;
+ }
+ return this.version != null ? this.version.equals(project.version)
+ : project.version == null;
}
- @Override public int hashCode() {
+ @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() {
+ @Override
+ public String toString() {
return "name=[" + this.name + "], version=[" + this.version + ']';
}
-}
\ No newline at end of file
+
+}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/post/PostReleaseActions.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/post/PostReleaseActions.java
index bd444dcb..3217e82d 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/post/PostReleaseActions.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/post/PostReleaseActions.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.post;
import java.io.Closeable;
@@ -35,14 +67,18 @@ public class PostReleaseActions implements Closeable {
private static final ExecutorService SERVICE = Executors.newCachedThreadPool();
private final ProjectGitHandler projectGitHandler;
+
private final ProjectPomUpdater projectPomUpdater;
+
private final GradleUpdater gradleUpdater;
+
private final ProjectBuilder projectBuilder;
+
private final ReleaserProperties properties;
public PostReleaseActions(ProjectGitHandler projectGitHandler,
- ProjectPomUpdater projectPomUpdater, GradleUpdater gradleUpdater, ProjectBuilder projectBuilder,
- ReleaserProperties properties) {
+ ProjectPomUpdater projectPomUpdater, GradleUpdater gradleUpdater,
+ ProjectBuilder projectBuilder, ReleaserProperties properties) {
this.projectGitHandler = projectGitHandler;
this.projectPomUpdater = projectPomUpdater;
this.gradleUpdater = gradleUpdater;
@@ -51,123 +87,128 @@ public class PostReleaseActions implements Closeable {
}
/**
- * Clones the test project, updates it and runs tests
- *
+ * Clones the test project, updates it and runs tests.
* @param projects - set of project with versions to assert against
*/
public void runUpdatedTests(Projects projects) {
- if (!this.properties.getGit().isRunUpdatedSamples() ||
- !this.properties.getMetaRelease().isEnabled()) {
+ if (!this.properties.getGit().isRunUpdatedSamples()
+ || !this.properties.getMetaRelease().isEnabled()) {
log.info("Will not update and run test samples, since the switch to do so "
+ "is off. Set [releaser.git.run-updated-samples] to [true] to change that");
return;
}
File file = this.projectGitHandler.cloneTestSamplesProject();
ProjectVersion projectVersion = newProjectVersion(file);
- String releaseTrainVersion = projects.releaseTrain(this.properties).version;
- Projects newProjects = addVersionForTestsProject(projects, projectVersion, releaseTrainVersion);
+ String releaseTrainVersion = projects.releaseTrain(this.properties).version;
+ Projects newProjects = addVersionForTestsProject(projects, projectVersion,
+ releaseTrainVersion);
updateWithVersions(file, newProjects);
this.projectBuilder.build(projectVersion, file.getAbsolutePath());
}
/**
* Clones all samples for the given project. For each of them, checks out the proper
- * branch, updates all the poms with the new, bumped versions of release train projects,
- * commits the changes and pushes them.
- *
+ * branch, updates all the poms with the new, bumped versions of release train
+ * projects, commits the changes and pushes them.
* @param projects - set of project with versions to assert against
*/
public void updateAllTestSamples(Projects projects) {
- if (!this.properties.getGit().isUpdateAllTestSamples() ||
- !this.properties.getMetaRelease().isEnabled()) {
+ if (!this.properties.getGit().isUpdateAllTestSamples()
+ || !this.properties.getMetaRelease().isEnabled()) {
log.info("Will not update all test samples, since the switch to do so "
+ "is off. Set [releaser.git.update-all-test-samples] to [true] to change that");
return;
}
List projectUrlAndExceptions = this.properties.getGit()
- .getAllTestSampleUrls()
- .entrySet()
- .stream()
- .map(e -> updateAllProjects(projects, e))
- .map(this::getResult)
- .flatMap(Collection::stream)
- .collect(Collectors.toList());
+ .getAllTestSampleUrls().entrySet().stream()
+ .map(e -> updateAllProjects(projects, e)).map(this::getResult)
+ .flatMap(Collection::stream).collect(Collectors.toList());
log.info("Updated all samples!");
String exceptionMessages = projectUrlAndExceptions.stream()
.filter(ProjectUrlAndException::hasException)
.map(e -> "Project [" + e.key + "] for url [" + e.url + "] "
- + "has exception [\n\n" + Arrays
- .stream(NestedExceptionUtils.getMostSpecificCause(e.ex)
- .getStackTrace())
- .map(StackTraceElement::toString)
- .collect(Collectors.joining("\n")) + "]")
+ + "has exception [\n\n"
+ + Arrays.stream(NestedExceptionUtils.getMostSpecificCause(e.ex)
+ .getStackTrace()).map(StackTraceElement::toString)
+ .collect(Collectors.joining("\n"))
+ + "]")
.collect(Collectors.joining("\n"));
if (StringUtils.hasText(exceptionMessages)) {
- throw new IllegalStateException("Exceptions were found while updating samples\n" + exceptionMessages);
- } else {
+ throw new IllegalStateException(
+ "Exceptions were found while updating samples\n" + exceptionMessages);
+ }
+ else {
log.info("No exceptions were found while updating the samples");
}
}
- private Future]> updateAllProjects(Projects projects, Map.Entry> e) {
+ private Future> updateAllProjects(Projects projects,
+ Map.Entry> e) {
return SERVICE.submit(() -> {
String key = e.getKey();
List value = e.getValue();
- log.info("Running version update for project [{}] and samples {}", key, value);
+ log.info("Running version update for project [{}] and samples {}", key,
+ value);
ProjectVersion projectVersionForReleaseTrain = projects.forName(key);
Projects postRelease = getPostReleaseProjects(projects);
log.info("Versions to update the samples with \n" + postRelease.stream()
.map(v -> "[" + v.projectName + " => " + v.version + "]")
.collect(Collectors.joining("\n")));
return value.stream()
- .map(url -> run(key, url, () ->
- commitUpdatedProject(projects, key, projectVersionForReleaseTrain, postRelease, url)))
- .map(this::getResult)
- .collect(Collectors.toList());
+ .map(url -> run(key, url,
+ () -> commitUpdatedProject(projects, key,
+ projectVersionForReleaseTrain, postRelease, url)))
+ .map(this::getResult).collect(Collectors.toList());
});
}
Projects getPostReleaseProjects(Projects projects) {
- return projects
- .postReleaseSnapshotVersion(this.properties.getMetaRelease().getProjectsToSkip());
+ return projects.postReleaseSnapshotVersion(
+ this.properties.getMetaRelease().getProjectsToSkip());
}
- private void commitUpdatedProject(Projects projects, String key, ProjectVersion projectVersionForReleaseTrain, Projects postRelease, String url) {
- String releaseTrainVersion = projects
- .forName(this.properties.getMetaRelease().getReleaseTrainProjectName()).version;
+ private void commitUpdatedProject(Projects projects, String key,
+ ProjectVersion projectVersionForReleaseTrain, Projects postRelease,
+ String url) {
+ String releaseTrainVersion = projects.forName(
+ this.properties.getMetaRelease().getReleaseTrainProjectName()).version;
String projectVersion = projects.forName(key).version;
- log.info("Running version update for project [{}], url [{}], "
- + "release train version [{}] and project version [{}]", key, url,
- releaseTrainVersion, projectVersion);
- File file = this.projectGitHandler
- .cloneAndGuessBranch(url, releaseTrainVersion, projectVersion);
+ log.info(
+ "Running version update for project [{}], url [{}], "
+ + "release train version [{}] and project version [{}]",
+ key, url, releaseTrainVersion, projectVersion);
+ File file = this.projectGitHandler.cloneAndGuessBranch(url, releaseTrainVersion,
+ projectVersion);
Projects newPostRelease = new Projects(postRelease);
ProjectVersion newProjectVersion = newProjectVersion(file);
newPostRelease.add(newProjectVersion);
updateWithVersions(file, newPostRelease);
- this.projectGitHandler
- .commit(file, "Updated versions after [" + releaseTrainVersion + "] "
- + "release train and [" + projectVersionForReleaseTrain.version + "] ["
- + key + "] project release");
+ this.projectGitHandler.commit(file,
+ "Updated versions after [" + releaseTrainVersion + "] "
+ + "release train and [" + projectVersionForReleaseTrain.version
+ + "] [" + key + "] project release");
this.projectGitHandler.pushCurrentBranch(file);
}
private ProjectVersion newProjectVersion(File file) {
try {
return new ProjectVersion(file);
- } catch (Exception ex) {
+ }
+ catch (Exception ex) {
ProjectVersion projectVersion = ProjectVersion.notMavenProject(file);
String name = projectVersion.projectName;
String version = projectVersion.version;
- log.warn("Exception occurred while trying to read the pom file. Will assume that the project name is [" + name + "] and version [" + version + "]", ex);
+ log.warn(
+ "Exception occurred while trying to read the pom file. Will assume that the project name is ["
+ + name + "] and version [" + version + "]",
+ ex);
return projectVersion;
}
}
private void updateWithVersions(File file, Projects newPostRelease) {
- this.projectPomUpdater
- .updateProjectFromReleaseTrain(file, newPostRelease,
- newProjectVersion(file), false);
+ this.projectPomUpdater.updateProjectFromReleaseTrain(file, newPostRelease,
+ newProjectVersion(file), false);
this.gradleUpdater.updateProjectFromBom(file, newPostRelease,
newProjectVersion(file), false);
}
@@ -188,7 +229,8 @@ public class PostReleaseActions implements Closeable {
return new ProjectUrlAndException(projectAndFuture.key, projectAndFuture.url, e);
}
- private List getResult(Future> future) {
+ private List getResult(
+ Future> future) {
try {
return future.get(10, TimeUnit.MINUTES);
}
@@ -198,29 +240,32 @@ public class PostReleaseActions implements Closeable {
}
/**
- * Clones the release train documentation project
- *
+ * Clones the release train documentation project.
* @param projects - set of project with versions to assert against
*/
public void generateReleaseTrainDocumentation(Projects projects) {
- if (!this.properties.getGit().isUpdateReleaseTrainDocs() ||
- !this.properties.getMetaRelease().isEnabled()) {
- log.info("Will not update the release train documentation, since the switch to do so "
- + "is off. Set [releaser.git.update-release-train-docs] to [true] to change that");
+ if (!this.properties.getGit().isUpdateReleaseTrainDocs()
+ || !this.properties.getMetaRelease().isEnabled()) {
+ log.info(
+ "Will not update the release train documentation, since the switch to do so "
+ + "is off. Set [releaser.git.update-release-train-docs] to [true] to change that");
return;
}
File file = this.projectGitHandler.cloneReleaseTrainDocumentationProject();
ProjectVersion projectVersion = newProjectVersion(file);
- String releaseTrainVersion = projects.releaseTrain(this.properties).version;
- Projects newProjects = addVersionForTestsProject(projects, projectVersion, releaseTrainVersion);
+ String releaseTrainVersion = projects.releaseTrain(this.properties).version;
+ Projects newProjects = addVersionForTestsProject(projects, projectVersion,
+ releaseTrainVersion);
updateWithVersions(file, newProjects);
- this.projectBuilder.generateReleaseTrainDocs(releaseTrainVersion, file.getAbsolutePath());
+ this.projectBuilder.generateReleaseTrainDocs(releaseTrainVersion,
+ file.getAbsolutePath());
}
- private Projects addVersionForTestsProject(Projects projects, ProjectVersion projectVersion,
- String releaseTrainVersion) {
+ private Projects addVersionForTestsProject(Projects projects,
+ ProjectVersion projectVersion, String releaseTrainVersion) {
Projects newProjects = new Projects(projects);
- newProjects.add(new ProjectVersion(projectVersion.projectName, releaseTrainVersion));
+ newProjects
+ .add(new ProjectVersion(projectVersion.projectName, releaseTrainVersion));
return newProjects;
}
@@ -228,12 +273,15 @@ public class PostReleaseActions implements Closeable {
public void close() {
SERVICE.shutdown();
}
+
}
-
class ProjectAndFuture {
+
final String key;
+
final String url;
+
final Future future;
ProjectAndFuture(String key, String url, Future future) {
@@ -241,11 +289,15 @@ class ProjectAndFuture {
this.url = url;
this.future = future;
}
+
}
class ProjectUrlAndException {
+
final String key;
+
final String url;
+
final Exception ex;
ProjectUrlAndException(String key, String url, Exception ex) {
@@ -257,4 +309,5 @@ class ProjectUrlAndException {
boolean hasException() {
return this.ex != null;
}
-}
\ No newline at end of file
+
+}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/project/ProjectBuilder.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/project/ProjectBuilder.java
index 1867f577..35b75669 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/project/ProjectBuilder.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/project/ProjectBuilder.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.project;
import java.io.File;
@@ -17,8 +49,9 @@ import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.cloud.release.internal.ReleaserPropertiesAware;
+
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;
@@ -28,6 +61,7 @@ import org.springframework.util.StringUtils;
public class ProjectBuilder implements ReleaserPropertiesAware {
private static final Logger log = LoggerFactory.getLogger(ProjectBuilder.class);
+
private static final String VERSION_MUSTACHE = "{{version}}";
private ReleaserProperties properties;
@@ -42,34 +76,38 @@ public class ProjectBuilder implements ReleaserPropertiesAware {
public void build(ProjectVersion versionFromReleaseTrain, String projectRoot) {
try {
- String[] commands = commandWithSystemProps(this.properties.getMaven().getBuildCommand(),
- versionFromReleaseTrain).split(" ");
+ String[] commands = commandWithSystemProps(
+ this.properties.getMaven().getBuildCommand(), versionFromReleaseTrain)
+ .split(" ");
runCommand(projectRoot, commands);
assertNoHtmlFilesInDocsContainUnresolvedTags(projectRoot);
log.info("No HTML files from docs contain unresolved tags");
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new IllegalStateException(e);
}
}
public void generateReleaseTrainDocs(String version, String projectRoot) {
try {
- String updatedCommand =
- this.properties.getMaven().getGenerateReleaseTrainDocsCommand().replace(VERSION_MUSTACHE, version);
+ String updatedCommand = this.properties.getMaven()
+ .getGenerateReleaseTrainDocsCommand()
+ .replace(VERSION_MUSTACHE, version);
runCommand(projectRoot, updatedCommand.split(" "));
assertNoHtmlFilesInDocsContainUnresolvedTags(this.properties.getWorkingDir());
log.info("No HTML files from docs contain unresolved tags");
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new IllegalStateException(e);
}
}
- private String commandWithSystemProps(String command,
- ProjectVersion version) {
+ private String commandWithSystemProps(String command, ProjectVersion version) {
if (command.contains(ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER)) {
return appendProfile(command, version);
}
- return appendProfile(command, version) + " " + ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER;
+ return appendProfile(command, version) + " "
+ + ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER;
}
private String appendProfile(String command, ProjectVersion version) {
@@ -77,10 +115,12 @@ public class ProjectBuilder implements ReleaserPropertiesAware {
if (version.isMilestone() || version.isRc()) {
log.info("Adding the milestone profile to the Maven build");
return trimmedCommand + " -Pmilestone";
- } else if (version.isRelease() || version.isServiceRelease()) {
+ }
+ else if (version.isRelease() || version.isServiceRelease()) {
log.info("Adding the central profile to the Maven build");
return trimmedCommand + " -Pcentral";
- } else {
+ }
+ else {
log.info("The build is a snapshot one - will not add any profiles");
}
return trimmedCommand;
@@ -101,11 +141,12 @@ public class ProjectBuilder implements ReleaserPropertiesAware {
public void deploy(ProjectVersion version) {
try {
- String[] commands = commandWithSystemProps(this.properties.getMaven().getDeployCommand(),
- version).split(" ");
+ String[] commands = commandWithSystemProps(
+ this.properties.getMaven().getDeployCommand(), version).split(" ");
runCommand(commands);
log.info("The project has successfully been deployed");
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new IllegalStateException(e);
}
}
@@ -132,29 +173,31 @@ public class ProjectBuilder implements ReleaserPropertiesAware {
runCommand(commands);
}
log.info("The docs got published successfully");
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new IllegalStateException(e);
}
}
/**
- * We need to insert the system properties as a list of -Dkey=value entries
- * instead of just pasting the String that contains these values
+ * We need to insert the system properties as a list of -Dkey=value entries instead of
+ * 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");
+ boolean containsSystemProps = this.properties.getMaven().getSystemProperties()
+ .contains("-D");
+ String[] splitSystemProps = StringUtils.delimitedListToStringArray(
+ this.properties.getMaven().getSystemProperties(), "-D");
// first element might be empty even though the second one contains values
if (splitSystemProps.length > 1) {
- splitSystemProps = StringUtils.isEmpty(splitSystemProps[0]) ?
- Arrays.copyOfRange(splitSystemProps, 1, splitSystemProps.length) :
- splitSystemProps;
+ splitSystemProps = StringUtils.isEmpty(splitSystemProps[0])
+ ? Arrays.copyOfRange(splitSystemProps, 1, splitSystemProps.length)
+ : splitSystemProps;
}
- String[] systemPropsWithPrefix = containsSystemProps ? Arrays.stream(splitSystemProps)
- .map(s -> "-D" + s.trim())
- .collect(Collectors.toList())
- .toArray(new String[splitSystemProps.length]) : splitSystemProps;
+ String[] systemPropsWithPrefix = containsSystemProps ? Arrays
+ .stream(splitSystemProps).map(s -> "-D" + s.trim())
+ .collect(Collectors.toList()).toArray(new String[splitSystemProps.length])
+ : splitSystemProps;
final AtomicInteger index = new AtomicInteger(-1);
for (int i = 0; i < commands.length; i++) {
if (commands[i].contains(ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER)) {
@@ -168,8 +211,10 @@ public class ProjectBuilder implements ReleaserPropertiesAware {
commandsList.remove(index.get());
if (index.get() >= commandsList.size()) {
commandsList.addAll(systemPropsList);
- } else {
- // we need to reverse to set the objects in the same order as passed in the prop
+ }
+ else {
+ // we need to reverse to set the objects in the same order as passed in
+ // the prop
List reversedSystemProps = new ArrayList<>(systemPropsList);
Collections.reverse(reversedSystemProps);
reversedSystemProps.forEach(s -> commandsList.add(index.get(), s));
@@ -178,12 +223,15 @@ public class ProjectBuilder implements ReleaserPropertiesAware {
return commandsList.toArray(new String[commandsList.size()]);
}
- @Override public void setReleaserProperties(ReleaserProperties properties) {
+ @Override
+ public void setReleaserProperties(ReleaserProperties properties) {
this.properties = properties;
}
+
}
class ProcessExecutor implements ReleaserPropertiesAware {
+
private static final Logger log = LoggerFactory.getLogger(ProcessExecutor.class);
private String workingDir;
@@ -195,18 +243,22 @@ class ProcessExecutor implements ReleaserPropertiesAware {
void runCommand(String[] commands, long waitTimeInMinutes) {
try {
String workingDir = this.workingDir;
- log.debug("Will run the command from [{}] via {} and wait for result for [{}] minutes",
+ log.debug(
+ "Will run the command from [{}] via {} and wait for result for [{}] minutes",
workingDir, commands, waitTimeInMinutes);
ProcessBuilder builder = builder(commands, workingDir);
Process process = startProcess(builder);
boolean finished = process.waitFor(waitTimeInMinutes, TimeUnit.MINUTES);
if (!finished) {
- log.error("The command hasn't managed to finish in [{}] minutes", waitTimeInMinutes);
+ log.error("The command hasn't managed to finish in [{}] minutes",
+ waitTimeInMinutes);
process.destroyForcibly();
- throw new IllegalStateException("Process waiting time of [" + waitTimeInMinutes + "] minutes exceeded");
+ throw new IllegalStateException("Process waiting time of ["
+ + waitTimeInMinutes + "] minutes exceeded");
}
if (process.exitValue() != 0) {
- throw new IllegalStateException("The process has exited with exit code [" + process.exitValue() + "]");
+ throw new IllegalStateException("The process has exited with exit code ["
+ + process.exitValue() + "]");
}
}
catch (InterruptedException | IOException e) {
@@ -219,24 +271,27 @@ class ProcessExecutor implements ReleaserPropertiesAware {
}
ProcessBuilder builder(String[] commands, String workingDir) {
- return new ProcessBuilder(commands)
- .directory(new File(workingDir))
- .inheritIO();
+ return new ProcessBuilder(commands).directory(new File(workingDir)).inheritIO();
}
- @Override public void setReleaserProperties(ReleaserProperties properties) {
+ @Override
+ public void setReleaserProperties(ReleaserProperties properties) {
this.workingDir = properties.getWorkingDir();
}
+
}
class HtmlFileWalker extends SimpleFileVisitor {
private static final String HTML_EXTENSION = ".html";
- @Override public FileVisitResult visitFile(Path path, BasicFileAttributes attr) {
+ @Override
+ public FileVisitResult visitFile(Path path, BasicFileAttributes attr) {
File file = path.toFile();
- if (file.getName().endsWith(HTML_EXTENSION) && asString(file).contains("Unresolved")) {
- throw new IllegalStateException("File [" + file + "] contains a tag that wasn't resolved properly");
+ if (file.getName().endsWith(HTML_EXTENSION)
+ && asString(file).contains("Unresolved")) {
+ throw new IllegalStateException(
+ "File [" + file + "] contains a tag that wasn't resolved properly");
}
return FileVisitResult.CONTINUE;
}
@@ -249,4 +304,5 @@ class HtmlFileWalker extends SimpleFileVisitor {
throw new IllegalStateException(e);
}
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Project.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Project.java
index a6eb5157..47edfd21 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Project.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Project.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.sagan;
import java.util.ArrayList;
@@ -8,23 +40,41 @@ import com.fasterxml.jackson.annotation.JsonInclude;
/**
* @author Marcin Grzejszczak
*/
-@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
public class Project {
+
public String id = "";
+
public String name = "";
+
public String repoUrl = "";
+
public String siteUrl = "";
+
public String category = "";
+
public String stackOverflowTags;
+
public List projectReleases = new ArrayList<>();
+
public List stackOverflowTagList = new ArrayList<>();
+
public Boolean aggregator;
- @Override public String toString() {
- return "Project{" + "id='" + this.id + '\'' + ", name='" + this.name + '\'' + ", repoUrl='"
- + this.repoUrl + '\'' + ", siteUrl='" + this.siteUrl + '\'' + ", category='"
- + this.category + '\'' + ", stackOverflowTags='" + this.stackOverflowTags + '\''
- + ", projectReleases=" + this.projectReleases + ", stackOverflowTagList="
- + this.stackOverflowTagList + ", aggregator=" + this.aggregator + '}';
+ public String rawBootConfig;
+
+ public String rawOverview;
+
+ @Override
+ public String toString() {
+ return "Project{" + "id='" + this.id + '\'' + ", name='" + this.name + '\''
+ + ", repoUrl='" + this.repoUrl + '\'' + ", siteUrl='" + this.siteUrl
+ + '\'' + ", category='" + this.category + '\'' + ", stackOverflowTags='"
+ + this.stackOverflowTags + '\'' + ", projectReleases="
+ + this.projectReleases + ", stackOverflowTagList="
+ + this.stackOverflowTagList + ", aggregator=" + this.aggregator
+ + ", rawBootConfig='" + this.rawBootConfig + '\'' + ", rawOverview='"
+ + this.rawOverview + '\'' + '}';
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Release.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Release.java
index 6711226b..93d5ced6 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Release.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Release.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.sagan;
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -5,28 +37,43 @@ import com.fasterxml.jackson.annotation.JsonInclude;
/**
* @author Marcin Grzejszczak
*/
-@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
public class Release {
+
public String releaseStatus = "";
+
public String refDocUrl = "";
+
public String apiDocUrl = "";
+
public String groupId = "";
+
public String artifactId = "";
+
public Repository repository;
+
public String version = "";
+
public boolean current;
+
public boolean generalAvailability;
+
public boolean preRelease;
+
public String versionDisplayName = "";
+
public boolean snapshot;
- @Override public String toString() {
- return "Release{" + "releaseStatus='" + this.releaseStatus + '\'' + ", refDocUrl='"
- + this.refDocUrl + '\'' + ", apiDocUrl='" + this.apiDocUrl + '\'' + ", groupId='"
- + this.groupId + '\'' + ", artifactId='" + this.artifactId + '\'' + ", repository="
- + this.repository + ", version='" + this.version + '\'' + ", current=" + this.current
- + ", generalAvailability=" + this.generalAvailability + ", preRelease="
- + this.preRelease + ", versionDisplayName='" + this.versionDisplayName + '\''
- + ", snapshot=" + this.snapshot + '}';
+ @Override
+ public String toString() {
+ return "Release{" + "releaseStatus='" + this.releaseStatus + '\''
+ + ", refDocUrl='" + this.refDocUrl + '\'' + ", apiDocUrl='"
+ + this.apiDocUrl + '\'' + ", groupId='" + this.groupId + '\''
+ + ", artifactId='" + this.artifactId + '\'' + ", repository="
+ + this.repository + ", version='" + this.version + '\'' + ", current="
+ + this.current + ", generalAvailability=" + this.generalAvailability
+ + ", preRelease=" + this.preRelease + ", versionDisplayName='"
+ + this.versionDisplayName + '\'' + ", snapshot=" + this.snapshot + '}';
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/ReleaseUpdate.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/ReleaseUpdate.java
index 35ca3401..2e71a31d 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/ReleaseUpdate.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/ReleaseUpdate.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.sagan;
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -5,21 +37,32 @@ import com.fasterxml.jackson.annotation.JsonInclude;
/**
* @author Marcin Grzejszczak
*/
-@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
public class ReleaseUpdate {
+
public String groupId = "";
+
public String artifactId = "";
+
public String version = "";
+
public String releaseStatus = "";
+
public String refDocUrl = "";
+
public String apiDocUrl = "";
+
public Boolean current;
+
public Repository repository;
- @Override public String toString() {
+ @Override
+ public String toString() {
return "ReleaseUpdate{" + "groupId='" + this.groupId + '\'' + ", artifactId='"
- + this.artifactId + '\'' + ", version='" + this.version + '\'' + ", releaseStatus='"
- + this.releaseStatus + '\'' + ", refDocUrl='" + this.refDocUrl + '\''
- + ", apiDocUrl='" + this.apiDocUrl + '\'' + ", repository=" + this.repository + '}';
+ + this.artifactId + '\'' + ", version='" + this.version + '\''
+ + ", releaseStatus='" + this.releaseStatus + '\'' + ", refDocUrl='"
+ + this.refDocUrl + '\'' + ", apiDocUrl='" + this.apiDocUrl + '\''
+ + ", repository=" + this.repository + '}';
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Repository.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Repository.java
index 984d5e46..3394f983 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Repository.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/Repository.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.sagan;
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -5,15 +37,22 @@ import com.fasterxml.jackson.annotation.JsonInclude;
/**
* @author Marcin Grzejszczak
*/
-@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@JsonInclude(JsonInclude.Include.NON_NULL)
public class Repository {
+
public String id;
+
public String name;
+
public String url;
+
public Boolean snapshotsEnabled;
- @Override public String toString() {
- return "Repository{" + "id='" + this.id + '\'' + ", name='" + this.name + '\'' + ", url='"
- + this.url + '\'' + ", snapshotsEnabled=" + this.snapshotsEnabled + '}';
+ @Override
+ public String toString() {
+ return "Repository{" + "id='" + this.id + '\'' + ", name='" + this.name + '\''
+ + ", url='" + this.url + '\'' + ", snapshotsEnabled="
+ + this.snapshotsEnabled + '}';
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/RestTemplateSaganClient.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/RestTemplateSaganClient.java
index 8ab8c156..7c3475eb 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/RestTemplateSaganClient.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/RestTemplateSaganClient.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.sagan;
import java.net.URI;
@@ -5,6 +37,7 @@ import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
import org.springframework.cloud.release.internal.ReleaserProperties;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
@@ -19,9 +52,11 @@ import org.springframework.web.client.RestTemplate;
*/
class RestTemplateSaganClient implements SaganClient {
- private static final Logger log = LoggerFactory.getLogger(RestTemplateSaganClient.class);
+ private static final Logger log = LoggerFactory
+ .getLogger(RestTemplateSaganClient.class);
private final RestTemplate restTemplate;
+
private final String baseUrl;
RestTemplateSaganClient(RestTemplate restTemplate, ReleaserProperties properties) {
@@ -29,17 +64,28 @@ class RestTemplateSaganClient implements SaganClient {
this.baseUrl = properties.getSagan().getBaseUrl();
}
- @Override public Project getProject(String projectName) {
- return this.restTemplate.getForObject(this.baseUrl + "/project_metadata/{projectName}", Project.class, projectName);
+ @Override
+ public Project getProject(String projectName) {
+ return this.restTemplate.getForObject(
+ this.baseUrl + "/project_metadata/{projectName}", Project.class,
+ projectName);
}
- @Override public Release getRelease(String projectName, String releaseVersion) {
- return this.restTemplate.getForObject(this.baseUrl + "/project_metadata/{projectName}/releases/{releaseVersion}", Release.class, projectName, releaseVersion);
+ @Override
+ public Release getRelease(String projectName, String releaseVersion) {
+ return this.restTemplate.getForObject(
+ this.baseUrl
+ + "/project_metadata/{projectName}/releases/{releaseVersion}",
+ Release.class, projectName, releaseVersion);
}
- @Override public Release deleteRelease(String projectName, String releaseVersion) {
- ResponseEntity entity = this.restTemplate.exchange(this.baseUrl + "/project_metadata/{projectName}/releases/{releaseVersion}",
- HttpMethod.DELETE, new HttpEntity<>(""), Release.class, projectName, releaseVersion);
+ @Override
+ public Release deleteRelease(String projectName, String releaseVersion) {
+ ResponseEntity entity = this.restTemplate.exchange(
+ this.baseUrl
+ + "/project_metadata/{projectName}/releases/{releaseVersion}",
+ HttpMethod.DELETE, new HttpEntity<>(""), Release.class, projectName,
+ releaseVersion);
Release release = entity.getBody();
log.info("Response from Sagan\n\n[{}] \n with body [{}]", entity, release);
return release;
@@ -48,13 +94,28 @@ class RestTemplateSaganClient implements SaganClient {
@Override
public Project updateRelease(String projectName, List releaseUpdates) {
RequestEntity> request = RequestEntity
- .put(URI.create(this.baseUrl +"/project_metadata/" + projectName + "/releases"))
+ .put(URI.create(
+ this.baseUrl + "/project_metadata/" + projectName + "/releases"))
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE)
.body(releaseUpdates);
- ResponseEntity entity = this.restTemplate
- .exchange(request, Project.class);
+ ResponseEntity entity = this.restTemplate.exchange(request,
+ Project.class);
Project project = entity.getBody();
log.info("Response from Sagan\n\n[{}] \n with body [{}]", entity, project);
return project;
}
+
+ @Override
+ public void patchProject(Project project) {
+ RequestEntity request = RequestEntity
+ .patch(URI
+ .create(this.baseUrl + "/project_metadata/" + project.name + "/"))
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE)
+ .body(project);
+ ResponseEntity entity = this.restTemplate.exchange(request,
+ Project.class);
+ Project updatedProject = entity.getBody();
+ log.info("Response from Sagan\n\n[{}] \n with body [{}]", entity, updatedProject);
+ }
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganClient.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganClient.java
index 8af74e42..bf71decf 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganClient.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganClient.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.sagan;
import java.util.List;
@@ -6,6 +38,7 @@ import java.util.List;
* @author Marcin Grzejszczak
*/
public interface SaganClient {
+
Project getProject(String projectName);
Release getRelease(String projectName, String releaseVersion);
@@ -13,4 +46,7 @@ public interface SaganClient {
Release deleteRelease(String projectName, String releaseVersion);
Project updateRelease(String projectName, List releaseUpdate);
+
+ void patchProject(Project project);
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganUpdater.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganUpdater.java
index c2d80dec..f67a7074 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganUpdater.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/sagan/SaganUpdater.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.sagan;
import java.util.stream.Collectors;
@@ -17,6 +49,7 @@ public class SaganUpdater {
private static final Logger log = LoggerFactory.getLogger(SaganUpdater.class);
private final SaganClient saganClient;
+
private final ReleaserProperties releaserProperties;
public SaganUpdater(SaganClient saganClient, ReleaserProperties releaserProperties) {
@@ -24,7 +57,8 @@ public class SaganUpdater {
this.releaserProperties = releaserProperties;
}
- public void updateSagan(String branch, ProjectVersion originalVersion, ProjectVersion version) {
+ public void updateSagan(String branch, ProjectVersion originalVersion,
+ ProjectVersion version) {
if (!this.releaserProperties.getSagan().isUpdateSagan()) {
log.info("Will not update sagan, since the switch to do so "
+ "is off. Set [releaser.sagan.update-sagan] to [true] to change that");
@@ -33,13 +67,16 @@ public class SaganUpdater {
ReleaseUpdate update = releaseUpdate(branch, originalVersion, version);
updateSaganForNonSnapshot(branch, originalVersion, version);
log.info("Updating Sagan with \n\n{}", update);
- this.saganClient.updateRelease(version.projectName, Collections.singletonList(update));
+ this.saganClient.updateRelease(version.projectName,
+ Collections.singletonList(update));
}
private void updateSaganForNonSnapshot(String branch, ProjectVersion originalVersion,
ProjectVersion version) {
if (!version.isSnapshot()) {
- log.info("Version is non snapshot [{}]. Will remove all older versions and mark this as current", version);
+ log.info(
+ "Version is non snapshot [{}]. Will remove all older versions and mark this as current",
+ version);
Project project = this.saganClient.getProject(version.projectName);
if (project != null) {
removeAllSameMinorVersions(version, project);
@@ -48,10 +85,11 @@ public class SaganUpdater {
removeVersionFromSagan(version, snapshot);
if (version.isRelease() || version.isServiceRelease()) {
String bumpedSnapshot = toSnapshot(version.bumpedVersion());
- ReleaseUpdate snapshotUpdate =
- releaseUpdate(branch, originalVersion, new ProjectVersion(version.projectName, bumpedSnapshot));
+ ReleaseUpdate snapshotUpdate = releaseUpdate(branch, originalVersion,
+ new ProjectVersion(version.projectName, bumpedSnapshot));
log.info("Updating Sagan with bumped snapshot \n\n[{}]", snapshotUpdate);
- this.saganClient.updateRelease(version.projectName, Collections.singletonList(snapshotUpdate));
+ this.saganClient.updateRelease(version.projectName,
+ Collections.singletonList(snapshotUpdate));
}
}
}
@@ -67,8 +105,10 @@ public class SaganUpdater {
log.info("Removing [{}/{}] from Sagan", version.projectName, snapshot);
try {
this.saganClient.deleteRelease(version.projectName, snapshot);
- } catch (Exception e) {
- log.error("Failed to remove [" + version.projectName + "/" + snapshot + "] from Sagan", e);
+ }
+ catch (Exception e) {
+ log.error("Failed to remove [" + version.projectName + "/" + snapshot
+ + "] from Sagan", e);
}
}
@@ -88,7 +128,8 @@ public class SaganUpdater {
private String toSnapshot(String version) {
if (version.contains("RELEASE")) {
return version.replace("RELEASE", "BUILD-SNAPSHOT");
- } else if (version.matches(".*SR[0-9]+")) {
+ }
+ else if (version.matches(".*SR[0-9]+")) {
return version.substring(0, version.lastIndexOf(".")) + ".BUILD-SNAPSHOT";
}
return version;
@@ -97,9 +138,11 @@ public class SaganUpdater {
private String version(ProjectVersion version) {
if (version.isSnapshot()) {
return "SNAPSHOT";
- } else if (version.isMilestone() || version.isRc()) {
+ }
+ else if (version.isMilestone() || version.isRc()) {
return "PRERELEASE";
- } else if (version.isRelease() || version.isServiceRelease()) {
+ }
+ else if (version.isRelease() || version.isServiceRelease()) {
return "GENERAL_AVAILABILITY";
}
return "";
@@ -108,13 +151,16 @@ public class SaganUpdater {
private String referenceUrl(String branch, ProjectVersion version) {
if (!version.isSnapshot()) {
// static/sleuth/{version}/
- return "http://cloud.spring.io/spring-cloud-static/" + version.projectName + "/{version}/";
+ return "http://cloud.spring.io/spring-cloud-static/" + version.projectName
+ + "/{version}/";
}
if (branch.toLowerCase().contains("master")) {
// sleuth/
- return "http://cloud.spring.io/" + version.projectName + "/" + version.projectName + ".html";
+ return "http://cloud.spring.io/" + version.projectName + "/"
+ + version.projectName + ".html";
}
// sleuth/1.1.x/
return "http://cloud.spring.io/" + version.projectName + "/" + branch + "/";
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/tech/HandlebarsHelper.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/tech/HandlebarsHelper.java
index 6e29af25..0a365381 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/tech/HandlebarsHelper.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/tech/HandlebarsHelper.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.tech;
import java.io.IOException;
@@ -12,10 +44,14 @@ import com.github.jknack.handlebars.io.ClassPathTemplateLoader;
*/
public final class HandlebarsHelper {
+ private HandlebarsHelper() {
+ throw new IllegalStateException("Can't instantiate a utility class");
+ }
+
public static Template template(String templateSubFolder, String templateName) {
try {
- Handlebars handlebars = new Handlebars(new ClassPathTemplateLoader("/templates/" +
- templateSubFolder));
+ Handlebars handlebars = new Handlebars(
+ new ClassPathTemplateLoader("/templates/" + templateSubFolder));
handlebars.registerHelper("replace", StringHelpers.replace);
handlebars.registerHelper("capitalizeFirst", StringHelpers.capitalizeFirst);
return handlebars.compile(templateName);
@@ -24,4 +60,5 @@ public final class HandlebarsHelper {
throw new IllegalStateException(e);
}
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/tech/MakeBuildUnstableException.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/tech/MakeBuildUnstableException.java
index 4be3d2df..029baad8 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/tech/MakeBuildUnstableException.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/tech/MakeBuildUnstableException.java
@@ -5,7 +5,23 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,12 +36,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Exception to be thrown if one wants to continue with the build
- * and throw this exception at the end of the release
+ * Exception to be thrown if one wants to continue with the build and throw this exception
+ * at the end of the release.
+ *
+ * @author Marcin Grzejszczak
*/
public class MakeBuildUnstableException extends RuntimeException {
- private static final Logger log = LoggerFactory.getLogger(MakeBuildUnstableException.class);
+ private static final Logger log = LoggerFactory
+ .getLogger(MakeBuildUnstableException.class);
public MakeBuildUnstableException(Throwable cause) {
super(cause);
@@ -41,4 +60,5 @@ public class MakeBuildUnstableException extends RuntimeException {
super(message, cause);
log.error("\n\n[BUILD UNSTABLE] WARNING! " + message, cause);
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/BlogTemplateGenerator.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/BlogTemplateGenerator.java
index b420c2e1..2bc4b78c 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/BlogTemplateGenerator.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/BlogTemplateGenerator.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.template;
import java.io.File;
@@ -19,16 +51,23 @@ import org.springframework.cloud.release.internal.pom.Projects;
*/
class BlogTemplateGenerator {
- private static final Logger log = LoggerFactory.getLogger(BlogTemplateGenerator.class);
+ private static final Logger log = LoggerFactory
+ .getLogger(BlogTemplateGenerator.class);
private static final Pattern RC_PATTERN = Pattern.compile("(.*)(RC)([0-9]+)");
+
private static final Pattern MILESTONE_PATTERN = Pattern.compile("(.*)(M)([0-9]+)");
+
private static final Pattern SR_PATTERN = Pattern.compile("(.*)(SR)([0-9]+)");
private final Template template;
+
private final String releaseVersion;
+
private final File blogOutput;
+
private final Projects projects;
+
private final NotesGenerator notesGenerator;
BlogTemplateGenerator(Template template, String releaseVersion, File blogOutput,
@@ -42,31 +81,33 @@ class BlogTemplateGenerator {
File blog() {
try {
- // availability - General Availability (RELEASE) / Service Release 1 (SR1) / Milestone 1 (M1)
+ // availability - General Availability (RELEASE) / Service Release 1 (SR1) /
+ // Milestone 1 (M1)
// releaseName - Dalston
// releaseLink
- // - [Maven Central](http://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-dependencies/Dalston.RELEASE/)
+ // - [Maven Central](http://repo1.maven.org/maven2/org/
+ // springframework/cloud/spring-cloud-dependencies/Dalston.RELEASE/)
// - [Spring Milestone](https://repo.spring.io/milestone/) repository
// releaseVersion '- Dalston.RELEASE
boolean release = this.releaseVersion.contains("RELEASE");
- boolean nonRelease = !(release || SR_PATTERN.matcher(this.releaseVersion).matches());
+ boolean nonRelease = !(release
+ || SR_PATTERN.matcher(this.releaseVersion).matches());
String availability = availability(release);
String releaseName = parsedReleaseName(this.releaseVersion);
String releaseLink = link(nonRelease);
Map map = ImmutableMap.builder()
- .put("availability", availability)
- .put("releaseName", releaseName)
+ .put("availability", availability).put("releaseName", releaseName)
.put("releaseLink", releaseLink)
.put("releaseVersion", this.releaseVersion)
.put("projects", this.notesGenerator.fromProjects(this.projects))
- .put("nonRelease", nonRelease)
- .build();
+ .put("nonRelease", nonRelease).build();
String blog = this.template.apply(map);
Files.write(this.blogOutput.toPath(), blog.getBytes());
return this.blogOutput;
}
catch (Exception e) {
- throw new IllegalStateException("Exception occurred while trying to create a blog entry", e);
+ throw new IllegalStateException(
+ "Exception occurred while trying to create a blog entry", e);
}
}
@@ -80,15 +121,20 @@ class BlogTemplateGenerator {
Matcher milestone = MILESTONE_PATTERN.matcher(this.releaseVersion);
if (release) {
return "General Availability (RELEASE)";
- } else if (sr.matches()) {
+ }
+ else if (sr.matches()) {
return availabilityText(sr, "Service Release", "SR");
- } else if (rc.matches()) {
+ }
+ else if (rc.matches()) {
return availabilityText(rc, "Release Candidate", "RC");
- } else if (milestone.matches()) {
+ }
+ else if (milestone.matches()) {
return milestone(milestone);
}
if (log.isWarnEnabled()) {
- log.warn("Unrecognized release [{}] . Hopefully, you know what you're doing. Will treat it as milestone", this.releaseVersion);
+ log.warn("Unrecognized release [{}] . "
+ + "Hopefully, you know what you're doing. Will treat it as milestone",
+ this.releaseVersion);
}
return milestone(milestone);
}
@@ -106,6 +152,9 @@ class BlogTemplateGenerator {
if (nonRelease) {
return "[Spring Milestone](https://repo.spring.io/milestone/) repository";
}
- return "[Maven Central](http://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-dependencies/" + this.releaseVersion + "/)";
+ return "[Maven Central](http://repo1.maven.org/maven2/"
+ + "org/springframework/cloud/spring-cloud-dependencies/"
+ + this.releaseVersion + "/)";
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/EmailTemplateGenerator.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/EmailTemplateGenerator.java
index b22738a2..b36c840c 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/EmailTemplateGenerator.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/EmailTemplateGenerator.java
@@ -1,22 +1,56 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.template;
import java.io.File;
import java.nio.file.Files;
+import com.github.jknack.handlebars.Template;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.github.jknack.handlebars.Template;
-
/**
* @author Marcin Grzejszczak
*/
class EmailTemplateGenerator {
- private static final Logger log = LoggerFactory.getLogger(EmailTemplateGenerator.class);
+ private static final Logger log = LoggerFactory
+ .getLogger(EmailTemplateGenerator.class);
private final Template template;
+
private final String releaseVersion;
+
private final File emailOutput;
EmailTemplateGenerator(Template template, String releaseVersion, File emailOutput) {
@@ -32,7 +66,9 @@ class EmailTemplateGenerator {
return this.emailOutput;
}
catch (Exception e) {
- throw new IllegalStateException("Exception occurred while trying to generate an email template", e);
+ throw new IllegalStateException(
+ "Exception occurred while trying to generate an email template", e);
}
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/NotesGenerator.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/NotesGenerator.java
index cdde234f..e950a3e5 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/NotesGenerator.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/NotesGenerator.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.template;
import java.util.Arrays;
@@ -20,22 +52,26 @@ class NotesGenerator {
}
Set fromProjects(Projects projects) {
- return projects.stream().filter(projectVersion ->
- !projectVersion.projectName.toLowerCase().contains("boot")
- ).map(projectVersion -> {
- String name = projectVersion.projectName;
- String version = projectVersion.version;
- String closedMilestoneUrl = this.handler.milestoneUrl(projectVersion);
- String convertedName = Arrays.stream(name.split("-"))
- .map(StringUtils::capitalize).collect(Collectors.joining(" "));
- return new Notes(convertedName, version, closedMilestoneUrl);
- }).collect(Collectors.toSet());
+ return projects.stream().filter(projectVersion -> !projectVersion.projectName
+ .toLowerCase().contains("boot")).map(projectVersion -> {
+ String name = projectVersion.projectName;
+ String version = projectVersion.version;
+ String closedMilestoneUrl = this.handler.milestoneUrl(projectVersion);
+ String convertedName = Arrays.stream(name.split("-"))
+ .map(StringUtils::capitalize)
+ .collect(Collectors.joining(" "));
+ return new Notes(convertedName, version, closedMilestoneUrl);
+ }).collect(Collectors.toSet());
}
+
}
class Notes {
+
private final String name;
+
private final String version;
+
private final String closedMilestoneUrl;
Notes(String name, String version, String closedMilestoneUrl) {
@@ -57,22 +93,27 @@ class Notes {
return this.closedMilestoneUrl;
}
- @Override public boolean equals(Object o) {
- if (this == o)
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
return true;
- if (o == null || getClass() != o.getClass())
+ }
+ if (o == null || getClass() != o.getClass()) {
return false;
+ }
Notes notes = (Notes) o;
- if (this.name != null ? !this.name.equals(notes.name) : notes.name != null)
+ if (this.name != null ? !this.name.equals(notes.name) : notes.name != null) {
return false;
- return this.version != null ?
- this.version.equals(notes.version) :
- notes.version == null;
+ }
+ return this.version != null ? this.version.equals(notes.version)
+ : notes.version == null;
}
- @Override public int hashCode() {
+ @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;
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/ReleaseNotesTemplateGenerator.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/ReleaseNotesTemplateGenerator.java
index 5e3b8168..63bc7d22 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/ReleaseNotesTemplateGenerator.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/ReleaseNotesTemplateGenerator.java
@@ -1,3 +1,35 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.template;
import java.io.File;
@@ -20,12 +52,17 @@ import org.springframework.cloud.release.internal.pom.Projects;
*/
class ReleaseNotesTemplateGenerator {
- private static final Logger log = LoggerFactory.getLogger(ReleaseNotesTemplateGenerator.class);
+ private static final Logger log = LoggerFactory
+ .getLogger(ReleaseNotesTemplateGenerator.class);
private final Template template;
+
private final String releaseVersion;
+
private final File blogOutput;
+
private final Projects projects;
+
private final NotesGenerator notesGenerator;
ReleaseNotesTemplateGenerator(Template template, String releaseVersion,
@@ -49,7 +86,9 @@ class ReleaseNotesTemplateGenerator {
return this.blogOutput;
}
catch (IOException e) {
- throw new IllegalStateException("Exception occurred while trying to generate release notes", e);
+ throw new IllegalStateException(
+ "Exception occurred while trying to generate release notes", e);
}
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/TemplateGenerator.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/TemplateGenerator.java
index f7f50d49..28d39470 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/TemplateGenerator.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/TemplateGenerator.java
@@ -1,32 +1,73 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.template;
import java.io.File;
import java.io.IOException;
+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.tech.HandlebarsHelper;
-import com.github.jknack.handlebars.Template;
-
/**
* @author Marcin Grzejszczak
*/
public class TemplateGenerator implements ReleaserPropertiesAware {
private static final String EMAIL_TEMPLATE = "email";
+
private static final String BLOG_TEMPLATE = "blog";
+
private static final String TWITTER_TEMPLATE = "tweet";
+
private static final String RELEASE_NOTES_TEMPLATE = "notes";
+
private final File emailOutput;
+
private final File blogOutput;
+
private final File tweetOutput;
+
private final File releaseNotesOutput;
- private ReleaserProperties props;
+
private final ProjectGitHandler handler;
+ private ReleaserProperties props;
+
public TemplateGenerator(ReleaserProperties props, ProjectGitHandler handler) {
this.props = props;
this.handler = handler;
@@ -63,7 +104,8 @@ public class TemplateGenerator implements ReleaserPropertiesAware {
throw new IllegalStateException("Couldn't create a file [" + file + "]");
}
return file;
- } catch (IOException e) {
+ }
+ catch (IOException e) {
throw new IllegalStateException(e);
}
}
@@ -72,7 +114,8 @@ public class TemplateGenerator implements ReleaserPropertiesAware {
File blogOutput = file(this.blogOutput);
String releaseVersion = parsedVersion(projects);
Template template = template(BLOG_TEMPLATE);
- return new BlogTemplateGenerator(template, releaseVersion, blogOutput, projects, this.handler).blog();
+ return new BlogTemplateGenerator(template, releaseVersion, blogOutput, projects,
+ this.handler).blog();
}
public File tweet(Projects projects) {
@@ -86,8 +129,8 @@ public class TemplateGenerator implements ReleaserPropertiesAware {
File output = file(this.releaseNotesOutput);
String releaseVersion = parsedVersion(projects);
Template template = template(RELEASE_NOTES_TEMPLATE);
- return new ReleaseNotesTemplateGenerator(template, releaseVersion,
- output, projects, this.handler).releaseNotes();
+ return new ReleaseNotesTemplateGenerator(template, releaseVersion, output,
+ projects, this.handler).releaseNotes();
}
private String parsedVersion(Projects projects) {
@@ -102,10 +145,13 @@ public class TemplateGenerator implements ReleaserPropertiesAware {
}
private Template template(String template) {
- return HandlebarsHelper.template(this.props.getTemplate().getTemplateFolder(), template);
+ return HandlebarsHelper.template(this.props.getTemplate().getTemplateFolder(),
+ template);
}
- @Override public void setReleaserProperties(ReleaserProperties properties) {
+ @Override
+ public void setReleaserProperties(ReleaserProperties properties) {
this.props = properties;
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/TwitterTemplateGenerator.java b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/TwitterTemplateGenerator.java
index 4921f17a..4b6ff0fe 100644
--- a/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/TwitterTemplateGenerator.java
+++ b/spring-cloud-release-tools-core/src/main/java/org/springframework/cloud/release/internal/template/TwitterTemplateGenerator.java
@@ -1,21 +1,56 @@
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright 2013-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cloud.release.internal.template;
import java.io.File;
import java.nio.file.Files;
+import com.github.jknack.handlebars.Template;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.github.jknack.handlebars.Template;
-
/**
* @author Marcin Grzejszczak
*/
class TwitterTemplateGenerator {
- private static final Logger log = LoggerFactory.getLogger(TwitterTemplateGenerator.class);
+
+ private static final Logger log = LoggerFactory
+ .getLogger(TwitterTemplateGenerator.class);
private final Template template;
+
private final String releaseVersion;
+
private final File output;
TwitterTemplateGenerator(Template template, String releaseVersion, File output) {
@@ -31,7 +66,9 @@ class TwitterTemplateGenerator {
return this.output;
}
catch (Exception e) {
- throw new IllegalStateException("Exception occurred while trying to generate a twitter template", e);
+ throw new IllegalStateException(
+ "Exception occurred while trying to generate a twitter template", e);
}
}
+
}
diff --git a/spring-cloud-release-tools-core/src/main/resources/templates/cloud/email.hbs b/spring-cloud-release-tools-core/src/main/resources/templates/cloud/email.hbs
index 31a9a8d7..5b75dfd5 100644
--- a/spring-cloud-release-tools-core/src/main/resources/templates/cloud/email.hbs
+++ b/spring-cloud-release-tools-core/src/main/resources/templates/cloud/email.hbs
@@ -9,4 +9,4 @@ On behalf of the team and the community, I'm excited to announce Spring Cloud {{
link to blog post
link to twitter
-Cheers,
\ No newline at end of file
+Cheers,
diff --git a/spring-cloud-release-tools-core/src/main/resources/templates/cloud/notes.hbs b/spring-cloud-release-tools-core/src/main/resources/templates/cloud/notes.hbs
index 88000e3a..1b21b9c1 100644
--- a/spring-cloud-release-tools-core/src/main/resources/templates/cloud/notes.hbs
+++ b/spring-cloud-release-tools-core/src/main/resources/templates/cloud/notes.hbs
@@ -3,4 +3,4 @@
{{ date }}
{{#each projects}} - {{name}} `{{version}}` {{#if closedMilestoneUrl}}([issues]({{{ closedMilestoneUrl }}})){{/if}}
-{{/each}}
\ No newline at end of file
+{{/each}}
diff --git a/spring-cloud-release-tools-core/src/main/resources/templates/cloud/spring-project.hbs b/spring-cloud-release-tools-core/src/main/resources/templates/cloud/spring-project.hbs
index aa92b0a5..d133e52c 100644
--- a/spring-cloud-release-tools-core/src/main/resources/templates/cloud/spring-project.hbs
+++ b/spring-cloud-release-tools-core/src/main/resources/templates/cloud/spring-project.hbs
@@ -356,4 +356,4 @@ Spring dependency management plugin.
{% endcapture %}
{% include project_page.html %}
-