Added profiles
This commit is contained in:
@@ -75,6 +75,12 @@ class GithubIssues {
|
||||
releaseVersion);
|
||||
return;
|
||||
}
|
||||
fileAGithubIssue(projects, releaseVersion);
|
||||
// iterate over projects, checkout the tag, build the guides project
|
||||
// only with -Pintegration,guides profile
|
||||
}
|
||||
|
||||
private void fileAGithubIssue(Projects projects, String releaseVersion) {
|
||||
Repo springGuides = this.github.repos()
|
||||
.get(new Coordinates.Simple("spring-guides", "getting-started-guides"));
|
||||
String issueTitle = StringUtils.capitalize(releaseVersion) + " "
|
||||
|
||||
@@ -37,7 +37,6 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.ReleaserPropertiesAware;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.versions.VersionsFetcher;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -45,29 +44,58 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class ProjectBuilder implements ReleaserPropertiesAware {
|
||||
|
||||
public enum MavenProfile {
|
||||
|
||||
/**
|
||||
* Profile used for milestone versions.
|
||||
*/
|
||||
MILESTONE,
|
||||
|
||||
/**
|
||||
* Profile used for ga versions.
|
||||
*/
|
||||
CENTRAL,
|
||||
|
||||
/**
|
||||
* Profile used to run integration tests.
|
||||
*/
|
||||
INTEGRATION,
|
||||
|
||||
/**
|
||||
* Profile used to run guides publishing.
|
||||
*/
|
||||
GUIDES;
|
||||
|
||||
/**
|
||||
* Converts the profile to lowercase, maven command line property.
|
||||
* @return profile with prepended -P
|
||||
*/
|
||||
public String asMavenProfile() {
|
||||
return "-P" + this.name().toLowerCase();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ProjectBuilder.class);
|
||||
|
||||
private static final String VERSION_MUSTACHE = "{{version}}";
|
||||
|
||||
private ReleaserProperties properties;
|
||||
|
||||
private final VersionsFetcher versionsFetcher;
|
||||
|
||||
public ProjectBuilder(ReleaserProperties properties,
|
||||
VersionsFetcher versionsFetcher) {
|
||||
public ProjectBuilder(ReleaserProperties properties) {
|
||||
this.properties = properties;
|
||||
this.versionsFetcher = versionsFetcher;
|
||||
}
|
||||
|
||||
public void build(ProjectVersion versionFromReleaseTrain) {
|
||||
build(versionFromReleaseTrain, this.properties.getWorkingDir());
|
||||
public void build(ProjectVersion versionFromReleaseTrain, MavenProfile... profiles) {
|
||||
build(versionFromReleaseTrain, this.properties.getWorkingDir(), profiles);
|
||||
}
|
||||
|
||||
public void build(ProjectVersion versionFromReleaseTrain, String projectRoot) {
|
||||
public void build(ProjectVersion versionFromReleaseTrain, String projectRoot,
|
||||
MavenProfile... profiles) {
|
||||
try {
|
||||
String[] commands = commandWithSystemProps(
|
||||
this.properties.getMaven().getBuildCommand(), versionFromReleaseTrain)
|
||||
.split(" ");
|
||||
this.properties.getMaven().getBuildCommand(), versionFromReleaseTrain,
|
||||
profiles).split(" ");
|
||||
runCommand(projectRoot, commands);
|
||||
assertNoHtmlFilesInDocsContainUnresolvedTags(projectRoot);
|
||||
log.info("No HTML files from docs contain unresolved tags");
|
||||
@@ -91,23 +119,27 @@ public class ProjectBuilder implements ReleaserPropertiesAware {
|
||||
}
|
||||
}
|
||||
|
||||
private String commandWithSystemProps(String command, ProjectVersion version) {
|
||||
private String commandWithSystemProps(String command, ProjectVersion version,
|
||||
MavenProfile... profiles) {
|
||||
if (command.contains(ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER)) {
|
||||
return appendProfile(command, version);
|
||||
return appendProfile(command, version, profiles);
|
||||
}
|
||||
return appendProfile(command, version) + " "
|
||||
return appendProfile(command, version, profiles) + " "
|
||||
+ ReleaserProperties.Maven.SYSTEM_PROPS_PLACEHOLDER;
|
||||
}
|
||||
|
||||
private String appendProfile(String command, ProjectVersion version) {
|
||||
private String appendProfile(String command, ProjectVersion version,
|
||||
MavenProfile... profiles) {
|
||||
String trimmedCommand = command.trim();
|
||||
if (version.isMilestone() || version.isRc()) {
|
||||
log.info("Adding the milestone profile to the Maven build");
|
||||
return trimmedCommand + " -Pmilestone";
|
||||
return trimmedCommand + " " + MavenProfile.MILESTONE.asMavenProfile()
|
||||
+ profilesToString(profiles);
|
||||
}
|
||||
else if (version.isRelease() || version.isServiceRelease()) {
|
||||
log.info("Adding the central profile to the Maven build");
|
||||
return trimmedCommand + " -Pcentral" + profilesForLatestVersion(version);
|
||||
return trimmedCommand + " " + MavenProfile.CENTRAL.asMavenProfile()
|
||||
+ profilesToString(profiles);
|
||||
}
|
||||
else {
|
||||
log.info("The build is a snapshot one - will not add any profiles");
|
||||
@@ -115,14 +147,9 @@ public class ProjectBuilder implements ReleaserPropertiesAware {
|
||||
return trimmedCommand;
|
||||
}
|
||||
|
||||
private String profilesForLatestVersion(ProjectVersion projectVersion) {
|
||||
boolean latestGa = this.versionsFetcher.isLatestGa(projectVersion);
|
||||
if (latestGa) {
|
||||
log.info("Version [" + projectVersion.version
|
||||
+ "] is the latest GA! Will append additional profiles");
|
||||
return " -Pguides";
|
||||
}
|
||||
return "";
|
||||
private String profilesToString(MavenProfile... profiles) {
|
||||
return Arrays.stream(profiles).map(profile -> "-P" + profile)
|
||||
.collect(Collectors.joining(" "));
|
||||
}
|
||||
|
||||
private void assertNoHtmlFilesInDocsContainUnresolvedTags(String workingDir) {
|
||||
@@ -138,10 +165,11 @@ public class ProjectBuilder implements ReleaserPropertiesAware {
|
||||
}
|
||||
}
|
||||
|
||||
public void deploy(ProjectVersion version) {
|
||||
public void deploy(ProjectVersion version, MavenProfile... profiles) {
|
||||
try {
|
||||
String[] commands = commandWithSystemProps(
|
||||
this.properties.getMaven().getDeployCommand(), version).split(" ");
|
||||
this.properties.getMaven().getDeployCommand(), version, profiles)
|
||||
.split(" ");
|
||||
runCommand(commands);
|
||||
log.info("The project has successfully been deployed");
|
||||
}
|
||||
@@ -204,6 +232,11 @@ public class ProjectBuilder implements ReleaserPropertiesAware {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return toCommandList(systemPropsWithPrefix, index, commands);
|
||||
}
|
||||
|
||||
private String[] toCommandList(String[] systemPropsWithPrefix, AtomicInteger index,
|
||||
String[] commands) {
|
||||
List<String> commandsList = new ArrayList<>(Arrays.asList(commands));
|
||||
List<String> systemPropsList = Arrays.asList(systemPropsWithPrefix);
|
||||
if (index.get() != -1) {
|
||||
|
||||
@@ -94,7 +94,7 @@ public class PostReleaseActionsTests {
|
||||
|
||||
VersionsFetcher versionsFetcher = new VersionsFetcher(properties, updater);
|
||||
|
||||
ProjectBuilder builder = new ProjectBuilder(this.properties, versionsFetcher);
|
||||
ProjectBuilder builder = new ProjectBuilder(this.properties);
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
|
||||
@@ -32,10 +32,8 @@ import org.junit.rules.TemporaryFolder;
|
||||
import org.springframework.boot.test.rule.OutputCapture;
|
||||
import org.springframework.cloud.release.internal.PomUpdateAcceptanceTests;
|
||||
import org.springframework.cloud.release.internal.ReleaserProperties;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectPomUpdater;
|
||||
import org.springframework.cloud.release.internal.pom.ProjectVersion;
|
||||
import org.springframework.cloud.release.internal.pom.TestUtils;
|
||||
import org.springframework.cloud.release.internal.versions.VersionsFetcher;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
@@ -63,7 +61,7 @@ public class ProjectBuilderTests {
|
||||
}
|
||||
|
||||
ProjectBuilder projectBuilder(ReleaserProperties properties) {
|
||||
return new ProjectBuilder(properties, versionsFetcher(properties)) {
|
||||
return new ProjectBuilder(properties) {
|
||||
@Override
|
||||
ProcessExecutor executor(String workingDir) {
|
||||
return testExecutor(workingDir);
|
||||
@@ -139,7 +137,7 @@ public class ProjectBuilderTests {
|
||||
builder.build(new ProjectVersion("foo", "1.0.0.RELEASE"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("foo -Pcentral -Pguides");
|
||||
.contains("foo -Pcentral");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -308,7 +306,7 @@ public class ProjectBuilderTests {
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.RELEASE"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("foo -Pcentral -Pguides");
|
||||
.contains("foo -Pcentral");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -322,7 +320,7 @@ public class ProjectBuilderTests {
|
||||
builder.deploy(new ProjectVersion("foo", "1.0.0.SR1"));
|
||||
|
||||
then(asString(tmpFile("/builder/resolved/resolved.log")))
|
||||
.contains("foo -Pcentral -Pguides");
|
||||
.contains("foo -Pcentral");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -375,8 +373,7 @@ public class ProjectBuilderTests {
|
||||
properties.getMaven().setPublishDocsCommands(new String[] { "ls -al", "ls -al" });
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
TestProcessExecutor executor = testExecutor(properties.getWorkingDir());
|
||||
ProjectBuilder builder = new ProjectBuilder(properties,
|
||||
versionsFetcher(properties)) {
|
||||
ProjectBuilder builder = new ProjectBuilder(properties) {
|
||||
@Override
|
||||
ProcessExecutor executor(String workingDir) {
|
||||
return executor;
|
||||
@@ -390,16 +387,6 @@ public class ProjectBuilderTests {
|
||||
then(executor.counter).isEqualTo(2);
|
||||
}
|
||||
|
||||
private VersionsFetcher versionsFetcher(ReleaserProperties properties) {
|
||||
ProjectPomUpdater pomUpdater = new ProjectPomUpdater(properties);
|
||||
return new VersionsFetcher(properties, pomUpdater) {
|
||||
@Override
|
||||
public boolean isLatestGa(ProjectVersion version) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_successfully_execute_a_publish_docs_command_with_sys_props_placeholder()
|
||||
throws Exception {
|
||||
@@ -409,8 +396,7 @@ public class ProjectBuilderTests {
|
||||
properties.getMaven().setSystemProperties("-Dhello=world -Dfoo=bar");
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
TestProcessExecutor executor = testExecutor(properties.getWorkingDir());
|
||||
ProjectBuilder builder = new ProjectBuilder(properties,
|
||||
versionsFetcher(properties)) {
|
||||
ProjectBuilder builder = new ProjectBuilder(properties) {
|
||||
@Override
|
||||
ProcessExecutor executor(String workingDir) {
|
||||
return executor;
|
||||
@@ -432,8 +418,7 @@ public class ProjectBuilderTests {
|
||||
.setPublishDocsCommands(new String[] { "echo '{{version}}'" });
|
||||
properties.setWorkingDir(tmpFile("/builder/resolved").getPath());
|
||||
TestProcessExecutor executor = testExecutor(properties.getWorkingDir());
|
||||
ProjectBuilder builder = new ProjectBuilder(properties,
|
||||
versionsFetcher(properties)) {
|
||||
ProjectBuilder builder = new ProjectBuilder(properties) {
|
||||
@Override
|
||||
ProcessExecutor executor(String workingDir) {
|
||||
return executor;
|
||||
@@ -454,8 +439,7 @@ public class ProjectBuilderTests {
|
||||
File resolved = tmpFile("/builder/resolved");
|
||||
properties.setWorkingDir(resolved.getPath());
|
||||
TestProcessExecutor executor = testExecutor(properties.getWorkingDir());
|
||||
ProjectBuilder builder = new ProjectBuilder(properties,
|
||||
versionsFetcher(properties)) {
|
||||
ProjectBuilder builder = new ProjectBuilder(properties) {
|
||||
@Override
|
||||
ProcessExecutor executor(String workingDir) {
|
||||
return executor;
|
||||
@@ -486,8 +470,7 @@ public class ProjectBuilderTests {
|
||||
ReleaserProperties properties = new ReleaserProperties();
|
||||
properties.getMaven().setBuildCommand("exit 1");
|
||||
properties.setWorkingDir(tmpFile("/builder/unresolved").getPath());
|
||||
ProjectBuilder builder = new ProjectBuilder(properties,
|
||||
versionsFetcher(properties)) {
|
||||
ProjectBuilder builder = new ProjectBuilder(properties) {
|
||||
@Override
|
||||
ProcessExecutor executor(String workingDir) {
|
||||
return new ProcessExecutor(properties.getWorkingDir()) {
|
||||
|
||||
@@ -56,8 +56,8 @@ class ReleaserConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
ProjectBuilder projectBuilder(VersionsFetcher versionsFetcher) {
|
||||
return new ProjectBuilder(this.properties, versionsFetcher);
|
||||
ProjectBuilder projectBuilder() {
|
||||
return new ProjectBuilder(this.properties);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -65,7 +65,6 @@ import org.springframework.cloud.release.internal.sagan.Release;
|
||||
import org.springframework.cloud.release.internal.sagan.SaganClient;
|
||||
import org.springframework.cloud.release.internal.sagan.SaganUpdater;
|
||||
import org.springframework.cloud.release.internal.template.TemplateGenerator;
|
||||
import org.springframework.cloud.release.internal.versions.VersionsFetcher;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
@@ -696,8 +695,7 @@ public class AcceptanceTests {
|
||||
private Releaser defaultReleaser(String expectedVersion, String projectName,
|
||||
ReleaserProperties properties) {
|
||||
ProjectPomUpdater pomUpdater = new ProjectPomUpdater(properties);
|
||||
VersionsFetcher versionsFetcher = new VersionsFetcher(properties, pomUpdater);
|
||||
ProjectBuilder projectBuilder = new ProjectBuilder(properties, versionsFetcher);
|
||||
ProjectBuilder projectBuilder = new ProjectBuilder(properties);
|
||||
TestProjectGitHandler handler = new TestProjectGitHandler(properties,
|
||||
expectedVersion, projectName);
|
||||
TemplateGenerator templateGenerator = new TemplateGenerator(properties, handler);
|
||||
@@ -727,8 +725,7 @@ public class AcceptanceTests {
|
||||
|
||||
private Releaser defaultMetaReleaser(ReleaserProperties properties) {
|
||||
ProjectPomUpdater pomUpdater = new ProjectPomUpdater(properties);
|
||||
VersionsFetcher versionsFetcher = new VersionsFetcher(properties, pomUpdater);
|
||||
ProjectBuilder projectBuilder = new ProjectBuilder(properties, versionsFetcher);
|
||||
ProjectBuilder projectBuilder = new ProjectBuilder(properties);
|
||||
NonAssertingTestProjectGitHandler handler = new NonAssertingTestProjectGitHandler(
|
||||
properties);
|
||||
TemplateGenerator templateGenerator = Mockito
|
||||
|
||||
Reference in New Issue
Block a user