Introducing the git properties

This commit is contained in:
Marcin Grzejszczak
2017-03-09 15:38:50 +01:00
parent 442a7234eb
commit bb3f6c1888
5 changed files with 64 additions and 36 deletions

View File

@@ -33,11 +33,14 @@ public class ReleaserProperties {
*/
private String workingDir;
private Git git = new Git();
private Pom pom = new Pom();
private Build build = new Build();
private Maven maven = new Maven();
public static class Git {
public static class Pom {
/**
* URL to Spring Cloud Release Git repository
*/
@@ -48,20 +51,6 @@ public class ReleaserProperties {
*/
private String cloneDestinationDir;
/**
* Which branch of Spring Cloud Release should be checked out. Defaults to {@code master}
*/
private String branch = "master";
/**
* List of regular expressions of ignored poms. Defaults to test projects and samples.
*/
@SuppressWarnings("unchecked")
private List<String> ignoredPomRegex = Arrays.asList(new String[] {
"^.*spring-cloud-contract-maven-plugin/src/test/projects/.*$",
"^.*samples/standalone.*$"
});
public String getSpringCloudReleaseGitUrl() {
return this.springCloudReleaseGitUrl;
}
@@ -78,6 +67,24 @@ public class ReleaserProperties {
this.cloneDestinationDir = cloneDestinationDir;
}
}
public static class Pom {
/**
* Which branch of Spring Cloud Release should be checked out. Defaults to {@code master}
*/
private String branch = "master";
/**
* List of regular expressions of ignored poms. Defaults to test projects and samples.
*/
@SuppressWarnings("unchecked")
private List<String> ignoredPomRegex = Arrays.asList(new String[] {
"^.*spring-cloud-contract-maven-plugin/src/test/projects/.*$",
"^.*samples/standalone.*$"
});
public String getBranch() {
return this.branch;
}
@@ -95,24 +102,29 @@ public class ReleaserProperties {
}
}
public static class Build {
public static class Maven {
/**
* Command to be executed to build the project
*/
private String command = "./mvnw clean install -Pdocs";
private String buildCommand = "./mvnw clean install -Pdocs";
/**
* Command to be executed to deploy a built project
*/
private String deployCommand = "./mvnw deploy -DskipTests -Pfast";
/**
* Max wait time in minutes for the build to finish
*/
private long waitTimeInMinutes = 20;
public String getCommand() {
return this.command;
public String getBuildCommand() {
return this.buildCommand;
}
public void setCommand(String command) {
this.command = command;
public void setBuildCommand(String buildCommand) {
this.buildCommand = buildCommand;
}
public long getWaitTimeInMinutes() {
@@ -122,6 +134,14 @@ public class ReleaserProperties {
public void setWaitTimeInMinutes(long waitTimeInMinutes) {
this.waitTimeInMinutes = waitTimeInMinutes;
}
public String getDeployCommand() {
return deployCommand;
}
public void setDeployCommand(String deployCommand) {
this.deployCommand = deployCommand;
}
}
public String getWorkingDir() {
@@ -132,6 +152,14 @@ public class ReleaserProperties {
this.workingDir = workingDir;
}
public Git getGit() {
return this.git;
}
public void setGit(Git git) {
this.git = git;
}
public Pom getPom() {
return this.pom;
}
@@ -140,11 +168,11 @@ public class ReleaserProperties {
this.pom = pom;
}
public Build getBuild() {
return this.build;
public Maven getMaven() {
return this.maven;
}
public void setBuild(Build build) {
this.build = build;
public void setMaven(Maven maven) {
this.maven = maven;
}
}

View File

@@ -37,8 +37,8 @@ public class ProjectBuilder {
public void build() {
try {
String[] commands = this.properties.getBuild().getCommand().split(" ");
long waitTimeInMinutes = this.properties.getBuild().getWaitTimeInMinutes();
String[] commands = this.properties.getMaven().getBuildCommand().split(" ");
long waitTimeInMinutes = this.properties.getMaven().getWaitTimeInMinutes();
this.executor.runCommand(commands, waitTimeInMinutes);
assertNoHtmlFilesContainUnresolvedTags();
log.info("No HTML files from docs contain unresolved tags");

View File

@@ -44,8 +44,8 @@ public class ProjectUpdater {
public ProjectUpdater(ReleaserProperties properties) {
try {
this.destinationDir = properties.getPom().getCloneDestinationDir() != null ?
new File(properties.getPom().getCloneDestinationDir()) :
this.destinationDir = properties.getGit().getCloneDestinationDir() != null ?
new File(properties.getGit().getCloneDestinationDir()) :
Files.createTempDirectory("releaser").toFile();
this.properties = properties;
this.gitRepo = new GitRepo(this.destinationDir);
@@ -63,7 +63,7 @@ public class ProjectUpdater {
*/
public void updateProject(File projectRoot) {
File clonedScRelease = this.gitRepo.cloneProject(
URI.create(this.properties.getPom().getSpringCloudReleaseGitUrl()));
URI.create(this.properties.getGit().getSpringCloudReleaseGitUrl()));
this.gitRepo.checkout(clonedScRelease, this.properties.getPom().getBranch());
SCReleasePomParser sCReleasePomParser = new SCReleasePomParser(clonedScRelease);
Versions versions = sCReleasePomParser.allVersions();

View File

@@ -73,7 +73,7 @@ public class AcceptanceTests {
private ReleaserProperties releaserProperties() throws URISyntaxException {
ReleaserProperties releaserProperties = new ReleaserProperties();
releaserProperties.getPom().setSpringCloudReleaseGitUrl(file("/projects/spring-cloud-release/").toURI().getPath());
releaserProperties.getGit().setSpringCloudReleaseGitUrl(file("/projects/spring-cloud-release/").toURI().getPath());
return releaserProperties;
}

View File

@@ -26,7 +26,7 @@ public class ProjectBuilderTests {
@Test
public void should_successfully_execute_a_command_when_after_running_there_is_no_html_file_with_unresolved_tag() throws Exception {
ReleaserProperties properties = new ReleaserProperties();
properties.getBuild().setCommand("ls -al");
properties.getMaven().setBuildCommand("ls -al");
properties.setWorkingDir(file("/projects/builder/resolved").getPath());
ProjectBuilder builder = new ProjectBuilder(properties, executor(properties));
@@ -40,7 +40,7 @@ public class ProjectBuilderTests {
@Test
public void should_throw_exception_when_after_running_there_is_an_html_file_with_unresolved_tag() throws Exception {
ReleaserProperties properties = new ReleaserProperties();
properties.getBuild().setCommand("ls -al");
properties.getMaven().setBuildCommand("ls -al");
properties.setWorkingDir(file("/projects/builder/unresolved").getPath());
ProjectBuilder builder = new ProjectBuilder(properties, executor(properties));
@@ -50,8 +50,8 @@ public class ProjectBuilderTests {
@Test
public void should_throw_exception_when_command_took_too_long_to_execute() throws Exception {
ReleaserProperties properties = new ReleaserProperties();
properties.getBuild().setCommand("sleep 1");
properties.getBuild().setWaitTimeInMinutes(0);
properties.getMaven().setBuildCommand("sleep 1");
properties.getMaven().setWaitTimeInMinutes(0);
properties.setWorkingDir(file("/projects/builder/unresolved").getPath());
ProjectBuilder builder = new ProjectBuilder(properties, executor(properties));