BOM parametrization

* Allow parametrization of versions patterns, fixes gh-99
* Customize the BOM pom location, fixes gh-98
This commit is contained in:
Marcin Grzejszczak
2018-10-17 09:15:45 +02:00
parent 1f7edff29f
commit 1b7a162ebe
10 changed files with 301 additions and 113 deletions

View File

@@ -30,7 +30,7 @@ why this tool makes it easy to automate the release / dependency update process
For a single project
- Clones the Spring Cloud Release project and picks all versions (Boot + Cloud projects)
- Modifies the project versions with values from SC-Release
- Modifies the project versions with values from a BOM (e.g. for Spring Cloud it's Spring Cloud Release)
* throws an exception when we bump versions to release and there's a SNAPSHOT version referenced in the POM
- Performs the build and checks if the `docs` modules have properly created the documentation
* throws an exception when in the `docs` module there's an unresolved tag in any HTML file
@@ -270,39 +270,44 @@ the `spring-cloud-cli.version` to `1.0.0.RELEASE` regardless of what was set in
Use these properties to provide versions for the meta release.
- `releaser.meta-release.enabled` - You have to turn it on to enable a meta release. Defaults to `false`
- `releaser.meta-release.release-train-project-name` - Name of the project that represents the BOM of the release train. Defaults to `spring-cloud-release`
- `releaser.meta-release.git-org-url` - The URL of the Git organization. We'll append each project's name to it.
Defaults to `https://github.com/spring-cloud`
- `releaser.meta-release.projects-to-skip` - List of projects that we should not clone and release. Spring Cloud release
train depends on projects that got already released. We default this list to `[spring-boot, spring-cloud-stream, spring-cloud-task]`.
- `releaser.git.fetch-versions-from-git` - If `true` then should fill the map of versions from Git. If `false` then picks fixed versions
- `releaser.git.clone-destination-dir` - Where should the Spring Cloud Release repo get cloned to. If null defaults to a temporary directory
- `releaser.git.spring-cloud-release-git-url` - URL to Spring Cloud Release Git repository. Defaults to `https://github.com/spring-cloud/spring-cloud-release`
- `releaser.git.documentation-url` - URL to the documentation Git repository. Defaults to `https://github.com/spring-cloud/spring-cloud-static`
- `releaser.git.documentation-branch` - Branch to check out for the documentation project. Defaults to `gh-pages`
- `releaser.git.update-documentation-repo` - If `true` then will update documentation repository with the `current` URL. Defaults to `true`
- `releaser.git.update-spring-guides` - If `true` then will update Spring Guides with the current release train. Defaults to `true`
The following properties are used for both meta release and a release of an individual module.
- `releaser.meta-release.release-train-project-name` - Name of the project that represents the BOM of the release train. Defaults to `spring-cloud-release`.
- `releaser.git.fetch-versions-from-git` - If `true` then should fill the map of versions from Git. If `false` then picks fixed versions.
- `releaser.git.clone-destination-dir` - Where should the Spring Cloud Release repo get cloned to. If null defaults to a temporary directory.
- `releaser.git.release-train-bom-url` - URL to a project containing a BOM. Defaults to Spring Cloud Release Git repository: `https://github.com/spring-cloud/spring-cloud-release`.
- `releaser.git.documentation-url` - URL to the documentation Git repository. Defaults to `https://github.com/spring-cloud/spring-cloud-static`.
- `releaser.git.documentation-branch` - Branch to check out for the documentation project. Defaults to `gh-pages`.
- `releaser.git.update-documentation-repo` - If `true` then will update documentation repository with the `current` URL. Defaults to `true`.
- `releaser.git.update-spring-guides` - If `true` then will update Spring Guides with the current release train. Defaults to `true`.
- `releaser.git.oauth-token` - GitHub OAuth token to be used to interact with GitHub repo.
- `releaser.git.username` - Optional Git username. If not passed keys will be used for authentication.
- `releaser.git.password` - Optional Git password. If not passed keys will be used for authentication.
- `releaser.git.number-of-checked-milestones` - In order not to iterate endlessly over milestones we introduce a threshold of milestones that
we will go through to find the matching milestone. Defaults to `10`
- `releaser.maven.build-command` - Command to be executed to build the project. Defaults to `./mvnw clean install -Pdocs`
- `releaser.maven.deploy-command` - Command to be executed to deploy a built project". Defaults to `./mvnw deploy -DskipTests -Pfast`
we will go through to find the matching milestone. Defaults to `10`.
- `releaser.maven.build-command` - Command to be executed to build the project. Defaults to `./mvnw clean install -Pdocs`.
- `releaser.maven.deploy-command` - Command to be executed to deploy a built project". Defaults to `./mvnw deploy -DskipTests -Pfast`.
- `releaser.maven.publish-docs-commands` - Command to be executed to deploy a built project. If present `{{version}}` will be replaced by the proper version.
Defaults to the standard Spring Cloud wget and execution of ghpages.
- `releaser.maven.system-properties` - Additional system properties that should be passed to any commands. If present `{{systemProps}}` will be replaced by the contents of this property.
- `releaser.maven.wait-time-in-minutes` - Max wait time in minutes for the process to finish. Defaults to `20`
- `releaser.maven.wait-time-in-minutes` - Max wait time in minutes for the process to finish. Defaults to `20`.
- `releaser.gradle.gradle-props-substitution` - a map containing a `key` which is a property key inside `gradle.properties` and a `value` of
a project name. E.g. in `gradle.properties` you have `foo=1.0.0.BUILD-SNAPSHOT` and you would like `spring-cloud-contract` version to
be set there. Just provide a mapping for the `gradle-props-substition` looking like this `foo=spring-cloud-contract` and the result
(e.g for sc-contract version `2.0.0.RELEASE`) will be an updated `gradle.properties` with entry `foo=2.0.0.RELEASE`
- `releaser.pom.branch` - Which branch of Spring Cloud Release should be checked out. Defaults to "master",
(e.g for sc-contract version `2.0.0.RELEASE`) will be an updated `gradle.properties` with entry `foo=2.0.0.RELEASE`.
- `releaser.pom.branch` - Which branch of Spring Cloud Release should be checked out. Defaults to `master`.
- `releaser.pom.pom-with-boot-starter-parent` - What is the location of the `pom.xml` that contains the `spring-boot-starter-parent` as its parent pom. Defaults to `spring-cloud-starter-parent/pom.xml`.
- `releaser.pom.this-train-bom` - What is the location of the `pom.xml` that contains all the versions for the release train. Defaults to `spring-cloud-dependencies/pom.xml`.
- `releaser.pom.bom-version-pattern` - Regular expression that will match the versions of projects in the BOM pom.xml. Defaults to `^(spring-cloud-.*)\.version$`.
- `releaser.pom.ignored-pom-regex` - List of regular expressions of ignored poms. Defaults to test projects and samples.
Example: `"--releaser.pom.ignored-pom-regex=".{asterisk}\\.git/.{asterisk}$,.\{asterisk}spring-cloud-contract-maven-plugin/src/test/projects/.{asterisk}$,.{asterisk}spring-cloud-contract-maven-plugin/target/.{asterisk}$,.{asterisk}samples/standalone/[a-z]+/.{asterisk}$"`
Example: `"--releaser.pom.ignored-pom-regex=".{asterisk}\\.git/.{asterisk}$,.\{asterisk}spring-cloud-contract-maven-plugin/src/test/projects/.{asterisk}$,.{asterisk}spring-cloud-contract-maven-plugin/target/.{asterisk}$,.{asterisk}samples/standalone/[a-z]+/.{asterisk}$"`.
- `releaser.working-dir` - By default Releaser assumes running the program from the current working directory.
- `releaser.template.template-folder` - Tells which subfolder with templates to pick for blog, email etc. generation. Defaults to `cloud`
- `releaser.template.template-folder` - Tells which subfolder with templates to pick for blog, email etc. generation. Defaults to `cloud`.
TIP: You can pass the options either via system properties or via application arguments.
Example for system properties: `java -Dreleaser.pom.branch=Camden.SR6 -jar target/spring-cloud-release-tools-spring-1.0.0.M1.jar`
@@ -314,7 +319,6 @@ IMPORTANT: For the GA release to be successful, it's important that if the `buil
the releaser will pass any system properties to the `build` / `deploy` command, such as system properties
with keys and we need them to be passed inside the command executed by the releaser.
=== Examples
==== Keeping configuration in the project
@@ -397,7 +401,95 @@ before running the app
== Building
Unresolved directive in README.adoc - include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/building.adoc[]
:jdkversion: 1.7
=== Basic Compile and Test
To build the source you will need to install JDK {jdkversion}.
Spring Cloud uses Maven for most build-related activities, and you
should be able to get off the ground quite quickly by cloning the
project you are interested in and typing
----
$ ./mvnw install
----
NOTE: You can also install Maven (>=3.3.3) yourself and run the `mvn` command
in place of `./mvnw` in the examples below. If you do that you also
might need to add `-P spring` if your local Maven settings do not
contain repository declarations for spring pre-release artifacts.
NOTE: Be aware that you might need to increase the amount of memory
available to Maven by setting a `MAVEN_OPTS` environment variable with
a value like `-Xmx512m -XX:MaxPermSize=128m`. We try to cover this in
the `.mvn` configuration, so if you find you have to do it to make a
build succeed, please raise a ticket to get the settings added to
source control.
For hints on how to build the project look in `.travis.yml` if there
is one. There should be a "script" and maybe "install" command. Also
look at the "services" section to see if any services need to be
running locally (e.g. mongo or rabbit). Ignore the git-related bits
that you might find in "before_install" since they're related to setting git
credentials and you already have those.
The projects that require middleware generally include a
`docker-compose.yml`, so consider using
http://compose.docker.io/[Docker Compose] to run the middeware servers
in Docker containers. See the README in the
https://github.com/spring-cloud-samples/scripts[scripts demo
repository] for specific instructions about the common cases of mongo,
rabbit and redis.
NOTE: If all else fails, build with the command from `.travis.yml` (usually
`./mvnw install`).
=== Documentation
The spring-cloud-build module has a "docs" profile, and if you switch
that on it will try to build asciidoc sources from
`src/main/asciidoc`. As part of that process it will look for a
`README.adoc` and process it by loading all the includes, but not
parsing or rendering it, just copying it to `${main.basedir}`
(defaults to `${basedir}`, i.e. the root of the project). If there are
any changes in the README it will then show up after a Maven build as
a modified file in the correct place. Just commit it and push the change.
=== Working with the code
If you don't have an IDE preference we would recommend that you use
http://www.springsource.com/developer/sts[Spring Tools Suite] or
http://eclipse.org[Eclipse] when working with the code. We use the
http://eclipse.org/m2e/[m2eclipse] eclipse plugin for maven support. Other IDEs and tools
should also work without issue as long as they use Maven 3.3.3 or better.
==== Importing into eclipse with m2eclipse
We recommend the http://eclipse.org/m2e/[m2eclipse] eclipse plugin when working with
eclipse. If you don't already have m2eclipse installed it is available from the "eclipse
marketplace".
NOTE: Older versions of m2e do not support Maven 3.3, so once the
projects are imported into Eclipse you will also need to tell
m2eclipse to use the right profile for the projects. If you
see many different errors related to the POMs in the projects, check
that you have an up to date installation. If you can't upgrade m2e,
add the "spring" profile to your `settings.xml`. Alternatively you can
copy the repository settings from the "spring" profile of the parent
pom into your `settings.xml`.
==== Importing into eclipse without m2eclipse
If you prefer not to use m2eclipse you can generate eclipse project metadata using the
following command:
[indent=0]
----
$ ./mvnw eclipse:eclipse
----
The generated eclipse projects can be imported by selecting `import existing projects`
from the `file` menu.
IMPORTANT: There are 2 different versions of language level used in Spring Cloud Sleuth. Java 1.7 is used for main sources and
Java 1.8 is used for tests. When importing your project to an IDE please activate the `ide` Maven profile to turn on
Java 1.8 for both main and test sources. Of course remember that you MUST NOT use Java 1.8 features in the main sources. If you do
@@ -405,4 +497,47 @@ so your app will break during the Maven build.
== Contributing
Unresolved directive in README.adoc - include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/contributing.adoc[]
Spring Cloud is released under the non-restrictive Apache 2.0 license,
and follows a very standard Github development process, using Github
tracker for issues and merging pull requests into master. If you want
to contribute even something trivial please do not hesitate, but
follow the guidelines below.
=== Sign the Contributor License Agreement
Before we accept a non-trivial patch or pull request we will need you to sign the
https://cla.pivotal.io/sign/spring[Contributor License Agreement].
Signing the contributor's agreement does not grant anyone commit rights to the main
repository, but it does mean that we can accept your contributions, and you will get an
author credit if we do. Active contributors might be asked to join the core team, and
given the ability to merge pull requests.
=== Code of Conduct
This project adheres to the Contributor Covenant https://github.com/spring-cloud/spring-cloud-build/blob/master/docs/src/main/asciidoc/code-of-conduct.adoc[code of
conduct]. By participating, you are expected to uphold this code. Please report
unacceptable behavior to spring-code-of-conduct@pivotal.io.
=== Code Conventions and Housekeeping
None of these is essential for a pull request, but they will all help. They can also be
added after the original pull request but before a merge.
* Use the Spring Framework code format conventions. If you use Eclipse
you can import formatter settings using the
`eclipse-code-formatter.xml` file from the
https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-dependencies-parent/eclipse-code-formatter.xml[Spring
Cloud Build] project. If using IntelliJ, you can use the
http://plugins.jetbrains.com/plugin/6546[Eclipse Code Formatter
Plugin] to import the same file.
* Make sure all new `.java` files to have a simple Javadoc class comment with at least an
`@author` tag identifying you, and preferably at least a paragraph on what the class is
for.
* Add the ASF license header comment to all new `.java` files (copy from existing files
in the project)
* Add yourself as an `@author` to the .java files that you modify substantially (more
than cosmetic changes).
* Add some Javadocs and, if you change the namespace, some XSD doc elements.
* A few unit tests would help a lot as well -- someone has to do it.
* If no-one else is using your branch, please rebase it against the current master (or
other target branch in the main project).
* When writing a commit message please follow http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html[these conventions],
if you are fixing an existing issue please add `Fixes gh-XXXX` at the end of the commit
message (where XXXX is the issue number).

View File

@@ -20,7 +20,7 @@ why this tool makes it easy to automate the release / dependency update process
For a single project
- Clones the Spring Cloud Release project and picks all versions (Boot + Cloud projects)
- Modifies the project versions with values from SC-Release
- Modifies the project versions with values from a BOM (e.g. for Spring Cloud it's Spring Cloud Release)
* throws an exception when we bump versions to release and there's a SNAPSHOT version referenced in the POM
- Performs the build and checks if the `docs` modules have properly created the documentation
* throws an exception when in the `docs` module there's an unresolved tag in any HTML file
@@ -260,39 +260,44 @@ the `spring-cloud-cli.version` to `1.0.0.RELEASE` regardless of what was set in
Use these properties to provide versions for the meta release.
- `releaser.meta-release.enabled` - You have to turn it on to enable a meta release. Defaults to `false`
- `releaser.meta-release.release-train-project-name` - Name of the project that represents the BOM of the release train. Defaults to `spring-cloud-release`
- `releaser.meta-release.git-org-url` - The URL of the Git organization. We'll append each project's name to it.
Defaults to `https://github.com/spring-cloud`
- `releaser.meta-release.projects-to-skip` - List of projects that we should not clone and release. Spring Cloud release
train depends on projects that got already released. We default this list to `[spring-boot, spring-cloud-stream, spring-cloud-task]`.
- `releaser.git.fetch-versions-from-git` - If `true` then should fill the map of versions from Git. If `false` then picks fixed versions
- `releaser.git.clone-destination-dir` - Where should the Spring Cloud Release repo get cloned to. If null defaults to a temporary directory
- `releaser.git.spring-cloud-release-git-url` - URL to Spring Cloud Release Git repository. Defaults to `https://github.com/spring-cloud/spring-cloud-release`
- `releaser.git.documentation-url` - URL to the documentation Git repository. Defaults to `https://github.com/spring-cloud/spring-cloud-static`
- `releaser.git.documentation-branch` - Branch to check out for the documentation project. Defaults to `gh-pages`
- `releaser.git.update-documentation-repo` - If `true` then will update documentation repository with the `current` URL. Defaults to `true`
- `releaser.git.update-spring-guides` - If `true` then will update Spring Guides with the current release train. Defaults to `true`
The following properties are used for both meta release and a release of an individual module.
- `releaser.meta-release.release-train-project-name` - Name of the project that represents the BOM of the release train. Defaults to `spring-cloud-release`.
- `releaser.git.fetch-versions-from-git` - If `true` then should fill the map of versions from Git. If `false` then picks fixed versions.
- `releaser.git.clone-destination-dir` - Where should the Spring Cloud Release repo get cloned to. If null defaults to a temporary directory.
- `releaser.git.release-train-bom-url` - URL to a project containing a BOM. Defaults to Spring Cloud Release Git repository: `https://github.com/spring-cloud/spring-cloud-release`.
- `releaser.git.documentation-url` - URL to the documentation Git repository. Defaults to `https://github.com/spring-cloud/spring-cloud-static`.
- `releaser.git.documentation-branch` - Branch to check out for the documentation project. Defaults to `gh-pages`.
- `releaser.git.update-documentation-repo` - If `true` then will update documentation repository with the `current` URL. Defaults to `true`.
- `releaser.git.update-spring-guides` - If `true` then will update Spring Guides with the current release train. Defaults to `true`.
- `releaser.git.oauth-token` - GitHub OAuth token to be used to interact with GitHub repo.
- `releaser.git.username` - Optional Git username. If not passed keys will be used for authentication.
- `releaser.git.password` - Optional Git password. If not passed keys will be used for authentication.
- `releaser.git.number-of-checked-milestones` - In order not to iterate endlessly over milestones we introduce a threshold of milestones that
we will go through to find the matching milestone. Defaults to `10`
- `releaser.maven.build-command` - Command to be executed to build the project. Defaults to `./mvnw clean install -Pdocs`
- `releaser.maven.deploy-command` - Command to be executed to deploy a built project". Defaults to `./mvnw deploy -DskipTests -Pfast`
we will go through to find the matching milestone. Defaults to `10`.
- `releaser.maven.build-command` - Command to be executed to build the project. Defaults to `./mvnw clean install -Pdocs`.
- `releaser.maven.deploy-command` - Command to be executed to deploy a built project". Defaults to `./mvnw deploy -DskipTests -Pfast`.
- `releaser.maven.publish-docs-commands` - Command to be executed to deploy a built project. If present `{{version}}` will be replaced by the proper version.
Defaults to the standard Spring Cloud wget and execution of ghpages.
- `releaser.maven.system-properties` - Additional system properties that should be passed to any commands. If present `{{systemProps}}` will be replaced by the contents of this property.
- `releaser.maven.wait-time-in-minutes` - Max wait time in minutes for the process to finish. Defaults to `20`
- `releaser.maven.wait-time-in-minutes` - Max wait time in minutes for the process to finish. Defaults to `20`.
- `releaser.gradle.gradle-props-substitution` - a map containing a `key` which is a property key inside `gradle.properties` and a `value` of
a project name. E.g. in `gradle.properties` you have `foo=1.0.0.BUILD-SNAPSHOT` and you would like `spring-cloud-contract` version to
be set there. Just provide a mapping for the `gradle-props-substition` looking like this `foo=spring-cloud-contract` and the result
(e.g for sc-contract version `2.0.0.RELEASE`) will be an updated `gradle.properties` with entry `foo=2.0.0.RELEASE`
- `releaser.pom.branch` - Which branch of Spring Cloud Release should be checked out. Defaults to "master",
(e.g for sc-contract version `2.0.0.RELEASE`) will be an updated `gradle.properties` with entry `foo=2.0.0.RELEASE`.
- `releaser.pom.branch` - Which branch of Spring Cloud Release should be checked out. Defaults to `master`.
- `releaser.pom.pom-with-boot-starter-parent` - What is the location of the `pom.xml` that contains the `spring-boot-starter-parent` as its parent pom. Defaults to `spring-cloud-starter-parent/pom.xml`.
- `releaser.pom.this-train-bom` - What is the location of the `pom.xml` that contains all the versions for the release train. Defaults to `spring-cloud-dependencies/pom.xml`.
- `releaser.pom.bom-version-pattern` - Regular expression that will match the versions of projects in the BOM pom.xml. Defaults to `^(spring-cloud-.*)\.version$`.
- `releaser.pom.ignored-pom-regex` - List of regular expressions of ignored poms. Defaults to test projects and samples.
Example: `"--releaser.pom.ignored-pom-regex=".{asterisk}\\.git/.{asterisk}$,.\{asterisk}spring-cloud-contract-maven-plugin/src/test/projects/.{asterisk}$,.{asterisk}spring-cloud-contract-maven-plugin/target/.{asterisk}$,.{asterisk}samples/standalone/[a-z]+/.{asterisk}$"`
Example: `"--releaser.pom.ignored-pom-regex=".{asterisk}\\.git/.{asterisk}$,.\{asterisk}spring-cloud-contract-maven-plugin/src/test/projects/.{asterisk}$,.{asterisk}spring-cloud-contract-maven-plugin/target/.{asterisk}$,.{asterisk}samples/standalone/[a-z]+/.{asterisk}$"`.
- `releaser.working-dir` - By default Releaser assumes running the program from the current working directory.
- `releaser.template.template-folder` - Tells which subfolder with templates to pick for blog, email etc. generation. Defaults to `cloud`
- `releaser.template.template-folder` - Tells which subfolder with templates to pick for blog, email etc. generation. Defaults to `cloud`.
TIP: You can pass the options either via system properties or via application arguments.
Example for system properties: `java -Dreleaser.pom.branch=Camden.SR6 -jar target/spring-cloud-release-tools-spring-1.0.0.M1.jar`
@@ -304,7 +309,6 @@ IMPORTANT: For the GA release to be successful, it's important that if the `buil
the releaser will pass any system properties to the `build` / `deploy` command, such as system properties
with keys and we need them to be passed inside the command executed by the releaser.
=== Examples
==== Keeping configuration in the project

View File

@@ -1,7 +1,6 @@
package org.springframework.cloud.release.internal;
import java.io.File;
import java.lang.invoke.MethodHandles;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,7 +50,7 @@ public class Releaser {
}
public Projects retrieveVersionsFromSCRelease() {
return this.projectPomUpdater.retrieveVersionsFromSCRelease();
return this.projectPomUpdater.retrieveVersionsFromReleaseTrainBom();
}
public Projects fixedVersions() {

View File

@@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import org.apache.commons.lang.SerializationUtils;
@@ -139,7 +140,7 @@ public class ReleaserProperties implements Serializable {
/**
* URL to Spring Cloud Release Git repository
*/
private String springCloudReleaseGitUrl = "https://github.com/spring-cloud/spring-cloud-release";
private String releaseTrainBomUrl = "https://github.com/spring-cloud/spring-cloud-release";
/**
* URL to the documentation Git repository
@@ -192,12 +193,12 @@ public class ReleaserProperties implements Serializable {
*/
private boolean updateSpringGuides = true;
public String getSpringCloudReleaseGitUrl() {
return this.springCloudReleaseGitUrl;
public String getReleaseTrainBomUrl() {
return this.releaseTrainBomUrl;
}
public void setSpringCloudReleaseGitUrl(String springCloudReleaseGitUrl) {
this.springCloudReleaseGitUrl = springCloudReleaseGitUrl;
public void setReleaseTrainBomUrl(String releaseTrainBomUrl) {
this.releaseTrainBomUrl = releaseTrainBomUrl;
}
public String getDocumentationUrl() {
@@ -283,7 +284,7 @@ public class ReleaserProperties implements Serializable {
@Override
public String toString() {
return "Git{" +
"springCloudReleaseGitUrl='" + this.springCloudReleaseGitUrl + '\'' +
"releaseTrainBomUrl='" + this.releaseTrainBomUrl + '\'' +
", documentationUrl='" + this.documentationUrl + '\'' +
", documentationBranch='" + this.documentationBranch + '\'' +
", updateDocumentationRepo=" + this.updateDocumentationRepo +
@@ -299,10 +300,25 @@ public class ReleaserProperties implements Serializable {
public static class Pom implements Serializable {
/**
* Which branch of Spring Cloud Release should be checked out. Defaults to {@code master}
* Which branch of release train BOM should be checked out. Defaults to {@code master}
*/
private String branch = "master";
/**
* Subfolder of the pom that contains the {@code spring-boot-starer-parent} dependency
*/
private String pomWithBootStarterParent = "spring-cloud-starter-parent/pom.xml";
/**
* Subfolder of the pom that contains the versions for the release train
*/
private String thisTrainBom = "spring-cloud-dependencies/pom.xml";
/**
* The pattern to match a version property in a BOM
*/
private String bomVersionPattern = "^(spring-cloud-.*)\\.version$";
/**
* List of regular expressions of ignored poms. Defaults to test projects and samples.
*/
@@ -330,9 +346,39 @@ public class ReleaserProperties implements Serializable {
this.ignoredPomRegex = ignoredPomRegex;
}
@Override public String toString() {
return "Pom{" + "branch='" + this.branch + '\'' + ", ignoredPomRegex="
+ this.ignoredPomRegex + '}';
public String getPomWithBootStarterParent() {
return this.pomWithBootStarterParent;
}
public void setPomWithBootStarterParent(String pomWithBootStarterParent) {
this.pomWithBootStarterParent = pomWithBootStarterParent;
}
public String getThisTrainBom() {
return this.thisTrainBom;
}
public void setThisTrainBom(String thisTrainBom) {
this.thisTrainBom = thisTrainBom;
}
public String getBomVersionPattern() {
return this.bomVersionPattern;
}
public void setBomVersionPattern(String bomVersionPattern) {
this.bomVersionPattern = bomVersionPattern;
}
@Override
public String toString() {
return "Pom{" +
"branch='" + this.branch + '\'' +
", pomWithBootStarterParent='" + this.pomWithBootStarterParent + '\'' +
", thisTrainBom='" + this.thisTrainBom + '\'' +
", bomVersionPattern='" + this.bomVersionPattern + '\'' +
", ignoredPomRegex=" + this.ignoredPomRegex +
'}';
}
}

View File

@@ -1,9 +1,6 @@
package org.springframework.cloud.release.internal.git;
import java.io.File;
import java.lang.invoke.MethodHandles;
import java.net.URI;
import java.net.URL;
import java.nio.file.Files;
import org.eclipse.jgit.transport.URIish;
@@ -67,8 +64,8 @@ public class ProjectGitHandler implements ReleaserPropertiesAware {
gitRepo.commit(message);
}
public File cloneScReleaseProject() {
return cloneProject(this.properties.getGit().getSpringCloudReleaseGitUrl());
public File cloneReleaseTrainProject() {
return cloneProject(this.properties.getGit().getReleaseTrainBomUrl());
}
public File cloneDocumentationProject() {

View File

@@ -16,7 +16,6 @@
package org.springframework.cloud.release.internal.pom;
import java.io.File;
import java.lang.invoke.MethodHandles;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -30,37 +29,36 @@ import org.apache.maven.model.Model;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.release.internal.ReleaserProperties;
/**
* Parses the poms for a given project and populates versions from Spring Cloud Release
* Parses the poms for a given project and populates versions from a release train
*
* @author Marcin Grzejszczak
*/
class SCReleasePomParser {
class BomParser {
private static final Logger log = LoggerFactory.getLogger(SCReleasePomParser.class);
private static final Logger log = LoggerFactory.getLogger(BomParser.class);
private static final String STARTER_POM = "spring-cloud-starter-parent/pom.xml";
private static final String DEPENDENCIES_POM = "spring-cloud-dependencies/pom.xml";
private static final Pattern SC_VERSION_PATTERN = Pattern.compile("^(spring-cloud-.*)\\.version$");
private final File springCloudReleaseDir;
private final String bootPom;
private final String dependenciesPomPath;
private final File thisProjectRoot;
private final String pomWithBootStarterParent;
private final String thisTrainBom;
private final PomReader pomReader = new PomReader();
private final Pattern versionPattern;
private final ReleaserProperties properties;
SCReleasePomParser(File springCloudReleaseDir) {
this(springCloudReleaseDir, STARTER_POM, DEPENDENCIES_POM);
}
SCReleasePomParser(File springCloudReleaseDir, String bootPom, String dependenciesPom) {
this.springCloudReleaseDir = springCloudReleaseDir;
this.bootPom = bootPom;
this.dependenciesPomPath = dependenciesPom;
BomParser(ReleaserProperties properties, File thisProjectRoot) {
this.thisProjectRoot = thisProjectRoot;
this.pomWithBootStarterParent = properties.getPom().getPomWithBootStarterParent();
this.thisTrainBom = properties.getPom().getThisTrainBom();
this.versionPattern = Pattern.compile(properties.getPom().getBomVersionPattern());
this.properties = properties;
}
Versions allVersions() {
Versions boot = bootVersion();
Versions cloud = springCloudVersions();
Versions cloud = versionsFromSpringCloudBom();
return new Versions(boot.bootVersion, cloud.scBuildVersion, allProjects(boot, cloud));
}
@@ -72,7 +70,7 @@ class SCReleasePomParser {
}
Versions bootVersion() {
Model model = pom(this.bootPom);
Model model = pom(this.pomWithBootStarterParent);
String bootArtifactId = model.getParent().getArtifactId();
log.debug("Boot artifact id is equal to [{}]", bootArtifactId);
if (!SpringCloudConstants.BOOT_STARTER_PARENT_ARTIFACT_ID.equals(bootArtifactId)) {
@@ -88,15 +86,16 @@ class SCReleasePomParser {
if (pom == null) {
throw new IllegalStateException("Pom is not present");
}
File pomFile = new File(this.springCloudReleaseDir, pom);
File pomFile = new File(this.thisProjectRoot, pom);
if (!pomFile.exists()) {
throw new IllegalStateException("Pom is not present");
}
return this.pomReader.readPom(pomFile);
}
Versions springCloudVersions() {
Model model = pom(this.dependenciesPomPath);
// the BOM contains all versions of projects and its parent MUST be Spring Cloud Dependencies Parent
Versions versionsFromSpringCloudBom() {
Model model = pom(this.thisTrainBom);
String buildArtifact = model.getParent().getArtifactId();
log.debug("[{}] artifact id is equal to [{}]", SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID, buildArtifact);
if (!SpringCloudConstants.CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID.equals(buildArtifact)) {
@@ -110,18 +109,18 @@ class SCReleasePomParser {
.filter(propertyMatchesSCPattern())
.map(toProject())
.collect(Collectors.toSet());
String scReleaseVersion = model.getVersion();
projects.add(new Project("spring-cloud-release", scReleaseVersion));
String releaseTrainProjectVersion = model.getVersion();
projects.add(new Project(this.properties.getMetaRelease().getReleaseTrainProjectName(), releaseTrainProjectVersion));
return new Versions(buildVersion, projects);
}
private Predicate<Map.Entry<Object, Object>> propertyMatchesSCPattern() {
return entry -> SC_VERSION_PATTERN.matcher(entry.getKey().toString()).matches();
return entry -> this.versionPattern.matcher(entry.getKey().toString()).matches();
}
private Function<Map.Entry<Object, Object>, Project> toProject() {
return entry -> {
Matcher matcher = SC_VERSION_PATTERN.matcher(entry.getKey().toString());
Matcher matcher = this.versionPattern.matcher(entry.getKey().toString());
// you have to first match to get info about the group
matcher.matches();
String name = matcher.group(1);

View File

@@ -24,10 +24,8 @@ import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.slf4j.Logger;
@@ -62,10 +60,10 @@ public class ProjectPomUpdater implements ReleaserPropertiesAware {
* For the given root folder (typically the working directory) retrieves list of versions
* for a given release version.
*/
public Projects retrieveVersionsFromSCRelease() {
File clonedScRelease = this.gitRepo.cloneScReleaseProject();
public Projects retrieveVersionsFromReleaseTrainBom() {
File clonedScRelease = this.gitRepo.cloneReleaseTrainProject();
this.gitRepo.checkout(clonedScRelease, this.properties.getPom().getBranch());
SCReleasePomParser sCReleasePomParser = new SCReleasePomParser(clonedScRelease);
BomParser sCReleasePomParser = new BomParser(this.properties, clonedScRelease);
Versions versions = sCReleasePomParser.allVersions();
log.info("Will update the following versions manually [{}]", this.properties.getFixedVersions());
this.properties.getFixedVersions().forEach(versions::setVersion);

View File

@@ -4,7 +4,6 @@ import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.util.HashSet;
import org.apache.maven.model.Model;
import org.assertj.core.api.BDDAssertions;
@@ -42,7 +41,7 @@ public class PomUpdateAcceptanceTests {
ReleaserProperties releaserProperties = releaserProperties();
releaserProperties.getFixedVersions().put("checkstyle", "100.0.0.RELEASE");
ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties);
Projects projects = projectPomUpdater.retrieveVersionsFromSCRelease();
Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom();
File project = new File(this.temporaryFolder, "/spring-cloud-sleuth");
projectPomUpdater
@@ -70,7 +69,7 @@ public class PomUpdateAcceptanceTests {
public void should_not_fail_when_after_updating_a_release_version_there_still_is_a_snapshot_version() throws Exception {
ReleaserProperties releaserProperties = branchReleaserProperties();
ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties);
Projects projects = projectPomUpdater.retrieveVersionsFromSCRelease();
Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom();
projects.add(new ProjectVersion("spring-cloud-sleuth-samples", "0.0.5.RELEASE"));
File project = new File(this.temporaryFolder, "/spring-cloud-sleuth-with-unmatched-property/spring-cloud-sleuth-samples");
addBuildSnapshotToChildPom(project);
@@ -89,7 +88,7 @@ public class PomUpdateAcceptanceTests {
public void should_not_fail_update_when_after_updating_a_release_version_there_still_is_a_snapshot_version_in_a_non_deployable_module() throws Exception {
ReleaserProperties releaserProperties = branchReleaserProperties();
ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties);
Projects projects = projectPomUpdater.retrieveVersionsFromSCRelease();
Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom();
File project = new File(this.temporaryFolder, "/spring-cloud-sleuth-with-unmatched-property");
BDDAssertions.thenThrownBy(() ->
@@ -102,7 +101,7 @@ public class PomUpdateAcceptanceTests {
public void should_update_fail_when_after_updating_a_release_version_there_still_is_a_snapshot_version_for_boot_snapshot_version() throws Exception {
ReleaserProperties releaserProperties = branchReleaserProperties();
ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties);
Projects projects = projectPomUpdater.retrieveVersionsFromSCRelease();
Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom();
projects.removeIf(projectVersion -> projectVersion.projectName.contains("spring-cloud-build"));
projects.add(new ProjectVersion("spring-cloud-build", "1.4.2.BUILD-SNAPSHOT"));
File project = new File(this.temporaryFolder, "/spring-cloud-sleuth");
@@ -118,7 +117,7 @@ public class PomUpdateAcceptanceTests {
ReleaserProperties releaserProperties = releaserProperties();
ProjectPomUpdater projectPomUpdater = new ProjectPomUpdater(releaserProperties);
File beforeProcessing = pom("/projects/project/");
Projects projects = projectPomUpdater.retrieveVersionsFromSCRelease();
Projects projects = projectPomUpdater.retrieveVersionsFromReleaseTrainBom();
File project = tmpFile("/project/");
projectPomUpdater.updateProjectFromSCRelease(project, projects,
@@ -131,7 +130,7 @@ public class PomUpdateAcceptanceTests {
private ReleaserProperties releaserProperties() throws URISyntaxException {
ReleaserProperties releaserProperties = new ReleaserProperties();
releaserProperties.getGit().setSpringCloudReleaseGitUrl(file("/projects/spring-cloud-release/").toURI().toString());
releaserProperties.getGit().setReleaseTrainBomUrl(file("/projects/spring-cloud-release/").toURI().toString());
return releaserProperties;
}

View File

@@ -6,6 +6,8 @@ import java.net.URISyntaxException;
import org.junit.Before;
import org.junit.Test;
import org.springframework.cloud.release.internal.ReleaserProperties;
import org.springframework.cloud.release.internal.git.GitRepoTests;
import static org.assertj.core.api.BDDAssertions.then;
@@ -14,9 +16,10 @@ import static org.assertj.core.api.BDDAssertions.thenThrownBy;
/**
* @author Marcin Grzejszczak
*/
public class SCReleasePomParserTests {
public class BomParserTests {
File springCloudReleaseProject;
ReleaserProperties properties = new ReleaserProperties();
@Before
public void setup() throws IOException, URISyntaxException {
@@ -25,7 +28,7 @@ public class SCReleasePomParserTests {
@Test
public void should_throw_exception_when_boot_pom_is_missing() {
SCReleasePomParser parser = new SCReleasePomParser(new File("."));
BomParser parser = new BomParser(this.properties, new File("."));
thenThrownBy(parser::bootVersion)
.isInstanceOf(IllegalStateException.class)
@@ -34,7 +37,9 @@ public class SCReleasePomParserTests {
@Test
public void should_throw_exception_when_null_is_passed_to_boot() {
SCReleasePomParser parser = new SCReleasePomParser(this.springCloudReleaseProject, null, null);
this.properties.getPom().setPomWithBootStarterParent(null);
this.properties.getPom().setThisTrainBom(null);
BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject);
thenThrownBy(parser::bootVersion)
.isInstanceOf(IllegalStateException.class)
@@ -43,7 +48,9 @@ public class SCReleasePomParserTests {
@Test
public void should_throw_exception_when_boot_version_is_missing_in_pom() {
SCReleasePomParser parser = new SCReleasePomParser(this.springCloudReleaseProject, "pom.xml", null);
this.properties.getPom().setPomWithBootStarterParent("pom.xml");
this.properties.getPom().setThisTrainBom(null);
BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject);
thenThrownBy(parser::bootVersion)
.isInstanceOf(IllegalStateException.class)
@@ -52,7 +59,7 @@ public class SCReleasePomParserTests {
@Test
public void should_populate_sc_release_version() {
SCReleasePomParser parser = new SCReleasePomParser(this.springCloudReleaseProject);
BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject);
String scReleaseVersion = parser.allVersions().versionForProject("spring-cloud-release");
@@ -61,7 +68,7 @@ public class SCReleasePomParserTests {
@Test
public void should_populate_boot_version() {
SCReleasePomParser parser = new SCReleasePomParser(this.springCloudReleaseProject);
BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject);
String bootVersion = parser.bootVersion().bootVersion;
@@ -70,36 +77,40 @@ public class SCReleasePomParserTests {
@Test
public void should_throw_exception_when_cloud_pom_is_missing() {
SCReleasePomParser parser = new SCReleasePomParser(new File("."));
BomParser parser = new BomParser(this.properties, new File("."));
thenThrownBy(parser::springCloudVersions)
thenThrownBy(parser::versionsFromSpringCloudBom)
.isInstanceOf(IllegalStateException.class)
.hasMessageContaining("Pom is not present");
}
@Test
public void should_throw_exception_when_null_is_passed_to_cloud() {
SCReleasePomParser parser = new SCReleasePomParser(this.springCloudReleaseProject, null, null);
this.properties.getPom().setPomWithBootStarterParent(null);
this.properties.getPom().setThisTrainBom(null);
BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject);
thenThrownBy(parser::springCloudVersions)
thenThrownBy(parser::versionsFromSpringCloudBom)
.isInstanceOf(IllegalStateException.class)
.hasMessageContaining("Pom is not present");
}
@Test
public void should_throw_exception_when_cloud_version_is_missing_in_pom() {
SCReleasePomParser parser = new SCReleasePomParser(this.springCloudReleaseProject, null, "pom.xml");
this.properties.getPom().setPomWithBootStarterParent(null);
this.properties.getPom().setThisTrainBom("pom.xml");
BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject);
thenThrownBy(parser::springCloudVersions)
thenThrownBy(parser::versionsFromSpringCloudBom)
.isInstanceOf(IllegalStateException.class)
.hasMessageContaining("The pom doesn't have a [spring-cloud-dependencies-parent] artifact id");
}
@Test
public void should_populate_cloud_version() {
SCReleasePomParser parser = new SCReleasePomParser(this.springCloudReleaseProject);
BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject);
Versions cloudVersions = parser.springCloudVersions();
Versions cloudVersions = parser.versionsFromSpringCloudBom();
then(cloudVersions.scBuildVersion).isEqualTo("1.3.1.BUILD-SNAPSHOT");
then(cloudVersions.projects).contains(allProjects());
@@ -107,7 +118,7 @@ public class SCReleasePomParserTests {
@Test
public void should_populate_boot_and_cloud_version() {
SCReleasePomParser parser = new SCReleasePomParser(this.springCloudReleaseProject);
BomParser parser = new BomParser(this.properties, this.springCloudReleaseProject);
Versions cloudVersions = parser.allVersions();

View File

@@ -633,7 +633,7 @@ public class AcceptanceTests {
private ReleaserProperties releaserProperties(File project, String branch) throws URISyntaxException {
ReleaserProperties releaserProperties = new ReleaserProperties();
releaserProperties.getGit().setSpringCloudReleaseGitUrl(file("/projects/spring-cloud-release/").toURI().toString());
releaserProperties.getGit().setReleaseTrainBomUrl(file("/projects/spring-cloud-release/").toURI().toString());
releaserProperties.getGit().setDocumentationUrl(file("/projects/spring-cloud-static-angel/").toURI().toString());
releaserProperties.getMaven().setBuildCommand("echo build");
releaserProperties.getMaven().setDeployCommand("echo deploy");
@@ -666,7 +666,7 @@ public class AcceptanceTests {
private ReleaserProperties snapshotScReleaseReleaserProperties(File project, String branch) throws URISyntaxException {
ReleaserProperties releaserProperties = releaserProperties(project, branch);
releaserProperties.getGit().setSpringCloudReleaseGitUrl(file("/projects/spring-cloud-release-with-snapshot/").toURI().toString());
releaserProperties.getGit().setReleaseTrainBomUrl(file("/projects/spring-cloud-release-with-snapshot/").toURI().toString());
releaserProperties.getGit().setDocumentationUrl(file("/projects/spring-cloud-static/").toURI().toString());
this.releaserProperties = releaserProperties;
return releaserProperties;
@@ -725,8 +725,8 @@ public class AcceptanceTests {
return "http://foo.bar.com/" + releaseVersion.toString();
}
@Override public File cloneScReleaseProject() {
File file = super.cloneScReleaseProject();
@Override public File cloneReleaseTrainProject() {
File file = super.cloneReleaseTrainProject();
this.clonedProjects.add(file);
return file;
}