Automatically add system properties if they weren't added; fixes #60
This commit is contained in:
16
README.adoc
16
README.adoc
@@ -40,6 +40,10 @@ why this tool makes it easy to automate the release / dependency update process
|
||||
- Generates a blog template under `target/blog.md` (ONLY FOR NON-SNAPSHOT VERSIONS)
|
||||
- Generates a tweet template under `target/tweet.txt` (ONLY FOR NON-SNAPSHOT VERSIONS)
|
||||
- Generates a release notes template under `target/notes.md` (ONLY FOR NON-SNAPSHOT VERSIONS)
|
||||
- Updates project information in Sagan (http://spring.io) (ONLY FOR SNAPSHOT / RELEASE VERSIONS)
|
||||
|
||||
IMPORTANT: Starting with version that does Sagan integration, you MUST pass the OAuth token,
|
||||
otherwise the application will fail to start
|
||||
|
||||
=== What should I do first?
|
||||
|
||||
@@ -90,7 +94,7 @@ You will see text similar to this one
|
||||
|
||||
You can pick a range of options by using the hyphen - e.g. '2-4' will execute jobs [2,3,4]
|
||||
You can execute all tasks starting from a job by using a hyphen and providing only one number - e.g. '8-' will execute jobs [8,9,10]
|
||||
You can execute given tasks by providing a colon separated list of tasks - e.g. '3,7,8' will execute jobs [3,7,8]
|
||||
You can execute given tasks by providing a comma separated list of tasks - e.g. '3,7,8' will execute jobs [3,7,8]
|
||||
|
||||
You can press 'q' to quit
|
||||
----
|
||||
@@ -215,12 +219,15 @@ the `spring-cloud-cli.version` to `1.0.0.RELEASE` regardless of what was set in
|
||||
- `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.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`
|
||||
- `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.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
|
||||
@@ -234,6 +241,13 @@ TIP: You can pass the options either via system properties or via application ar
|
||||
Example for system properties: `java -Dreleaser.pom.branch=Camden.SR6 -jar target/spring-cloud-release-tools-spring-1.0.0.M1.jar`
|
||||
Example for application argumemts: `java -jar target/spring-cloud-release-tools-spring-1.0.0.M1.jar --releaser.pom.branch=Camden.SR6`
|
||||
|
||||
IMPORTANT: For the GA release to be successful, it's important that if the `build` / `deploy` command
|
||||
run a script (e.g. `scripts/foo.sh`) then inside `foo.sh` if you call a Maven build `./mvnw clean install`
|
||||
then *remember to pass all arguments of the script there too*. E.g. `./mvnw clean install ${@}`. That's because
|
||||
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
|
||||
|
||||
@@ -231,6 +231,13 @@ TIP: You can pass the options either via system properties or via application ar
|
||||
Example for system properties: `java -Dreleaser.pom.branch=Camden.SR6 -jar target/spring-cloud-release-tools-spring-1.0.0.M1.jar`
|
||||
Example for application argumemts: `java -jar target/spring-cloud-release-tools-spring-1.0.0.M1.jar --releaser.pom.branch=Camden.SR6`
|
||||
|
||||
IMPORTANT: For the GA release to be successful, it's important that if the `build` / `deploy` command
|
||||
run a script (e.g. `scripts/foo.sh`) then inside `foo.sh` if you call a Maven build `./mvnw clean install`
|
||||
then *remember to pass all arguments of the script there too*. E.g. `./mvnw clean install ${@}`. That's because
|
||||
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
|
||||
|
||||
@@ -168,12 +168,12 @@ public class ReleaserProperties {
|
||||
/**
|
||||
* Command to be executed to build the project
|
||||
*/
|
||||
private String buildCommand = "./mvnw clean install -B -Pdocs {{systemProps}}";
|
||||
private String buildCommand = "./mvnw clean install -B -Pdocs";
|
||||
|
||||
/**
|
||||
* Command to be executed to deploy a built project
|
||||
*/
|
||||
private String deployCommand = "./mvnw deploy -DskipTests -B -Pfast {{systemProps}}";
|
||||
private String deployCommand = "./mvnw deploy -DskipTests -B -Pfast";
|
||||
|
||||
/**
|
||||
* Command to be executed to publish documentation. If present "{{version}}" will be replaced by the
|
||||
|
||||
@@ -19,7 +19,6 @@ 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.pom.ProjectPomUpdater;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -32,23 +31,21 @@ public class ProjectBuilder {
|
||||
|
||||
private final ReleaserProperties properties;
|
||||
private final ProcessExecutor executor;
|
||||
private final ProjectPomUpdater pomUpdater;
|
||||
|
||||
public ProjectBuilder(ReleaserProperties properties, ProjectPomUpdater pomUpdater) {
|
||||
public ProjectBuilder(ReleaserProperties properties) {
|
||||
this.properties = properties;
|
||||
this.executor = new ProcessExecutor(properties);
|
||||
this.pomUpdater = pomUpdater;
|
||||
}
|
||||
|
||||
ProjectBuilder(ReleaserProperties properties, ProcessExecutor executor) {
|
||||
this.properties = properties;
|
||||
this.executor = executor;
|
||||
this.pomUpdater = new ProjectPomUpdater(properties);
|
||||
}
|
||||
|
||||
public void build() {
|
||||
try {
|
||||
String[] commands = this.properties.getMaven().getBuildCommand().split(" ");
|
||||
String[] commands = commandWithSystemProps(this.properties.getMaven().getBuildCommand())
|
||||
.split(" ");
|
||||
runCommand(commands);
|
||||
assertNoHtmlFilesInDocsContainUnresolvedTags();
|
||||
log.info("No HTML files from docs contain unresolved tags");
|
||||
@@ -57,6 +54,13 @@ public class ProjectBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private String commandWithSystemProps(String command) {
|
||||
if (command.contains(ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER)) {
|
||||
return command;
|
||||
}
|
||||
return command.trim() + " " + ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER;
|
||||
}
|
||||
|
||||
private void assertNoHtmlFilesInDocsContainUnresolvedTags() {
|
||||
String workingDir = this.properties.getWorkingDir();
|
||||
try {
|
||||
@@ -73,7 +77,8 @@ public class ProjectBuilder {
|
||||
|
||||
public void deploy() {
|
||||
try {
|
||||
String[] commands = this.properties.getMaven().getDeployCommand().split(" ");
|
||||
String[] commands = commandWithSystemProps(this.properties.getMaven().getDeployCommand())
|
||||
.split(" ");
|
||||
runCommand(commands);
|
||||
log.info("The project has successfully been deployed");
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -95,6 +95,20 @@ public class ProjectBuilderTests {
|
||||
.contains("-Dhello=world -Dfoo=bar bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_successfully_pass_system_props_when_build_gets_executed_without_explicit_system_props() throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setBuildCommand("echo bar");
|
||||
properties.getMaven().setSystemProperties("-Dhello=world -Dfoo=bar");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = new ProjectBuilder(properties, executor(properties));
|
||||
|
||||
builder.build();
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("bar -Dhello=world -Dfoo=bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_throw_exception_when_after_running_there_is_an_html_file_with_unresolved_tag() throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
@@ -143,6 +157,20 @@ public class ProjectBuilderTests {
|
||||
.contains("-Dhello=hello-world");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_successfully_pass_system_props_when_deploy_gets_executed_without_explicit_system_props() throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setDeployCommand("echo ");
|
||||
properties.getMaven().setSystemProperties("-Dhello=hello-world");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
ProjectBuilder builder = new ProjectBuilder(properties, executor(properties));
|
||||
|
||||
builder.deploy();
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("-Dhello=hello-world");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_throw_exception_when_deploy_command_took_too_long_to_execute() throws Exception {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
|
||||
@@ -37,7 +37,7 @@ class ReleaserConfiguration {
|
||||
ProjectPomUpdater pomUpdater = new ProjectPomUpdater(properties);
|
||||
ProjectGitHandler handler = new ProjectGitHandler(properties);
|
||||
SaganUpdater saganUpdater = new SaganUpdater(saganClient);
|
||||
return new SpringReleaser(new Releaser(pomUpdater, new ProjectBuilder(properties, pomUpdater),
|
||||
return new SpringReleaser(new Releaser(pomUpdater, new ProjectBuilder(properties),
|
||||
handler, new TemplateGenerator(properties, handler),
|
||||
new GradleUpdater(properties), saganUpdater), properties);
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ public class AcceptanceTests {
|
||||
|
||||
private Releaser defaultReleaser(String expectedVersion, ReleaserProperties properties) throws Exception {
|
||||
ProjectPomUpdater pomUpdater = new ProjectPomUpdater(properties);
|
||||
ProjectBuilder projectBuilder = new ProjectBuilder(properties, pomUpdater);
|
||||
ProjectBuilder projectBuilder = new ProjectBuilder(properties);
|
||||
TestProjectGitHandler handler = new TestProjectGitHandler(properties,
|
||||
expectedVersion);
|
||||
TemplateGenerator templateGenerator = new TemplateGenerator(properties, handler);
|
||||
|
||||
Reference in New Issue
Block a user