Added skip project names feature; fixes gh-87

This commit is contained in:
Marcin Grzejszczak
2018-06-25 10:39:54 +02:00
parent 9578294fbd
commit 2a4cf036c6
5 changed files with 50 additions and 8 deletions

View File

@@ -268,6 +268,8 @@ Use these properties to provide versions for the meta release.
- `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-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

View File

@@ -258,6 +258,8 @@ Use these properties to provide versions for the meta release.
- `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-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

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.cloud.release.internal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -70,6 +71,16 @@ public class ReleaserProperties {
*/
private String gitOrgUrl = "https://github.com/spring-cloud";
/**
* Names of projects to skip deployment for meta-release
*/
private List<String> projectsToSkip = new ArrayList<String>() {
{
this.add("spring-cloud-stream");
this.add("spring-cloud-task");
}
};
public boolean isEnabled() {
return this.enabled;
}
@@ -93,6 +104,14 @@ public class ReleaserProperties {
public void setReleaseTrainProjectName(String releaseTrainProjectName) {
this.releaseTrainProjectName = releaseTrainProjectName;
}
public List<String> getProjectsToSkip() {
return this.projectsToSkip;
}
public void setProjectsToSkip(List<String> projectsToSkip) {
this.projectsToSkip = projectsToSkip;
}
}
public static class Git {

View File

@@ -62,9 +62,8 @@ public class SpringReleaser {
if (options.metaRelease) {
log.info("Meta Release picked. Will iterate over all projects and perform release of each one");
this.properties.getGit().setFetchVersionsFromGit(false);
metaReleaseProjects(options).forEach(project -> {
processProjectForMetaRelease(options, project);
});
metaReleaseProjects(options)
.forEach(project -> processProjectForMetaRelease(options, project));
} else {
log.info("Single project release picked. Will release only the current project");
File projectFolder = projectFolder();
@@ -115,19 +114,23 @@ public class SpringReleaser {
private List<String> metaReleaseProjects(Options options) {
List<String> projects = new ArrayList<>(this.properties.getFixedVersions().keySet());
log.info("List of projects that should not be cloned {}", this.properties.getMetaRelease().getProjectsToSkip());
List<String> filteredProjects = projects.stream()
.filter(project -> !this.properties.getMetaRelease().getProjectsToSkip().contains(project))
.collect(Collectors.toList());
if (StringUtils.hasText(options.startFrom)) {
int projectIndex = projects.indexOf(options.startFrom);
int projectIndex = filteredProjects.indexOf(options.startFrom);
if (projectIndex < 0) throw new IllegalStateException("Project [" + options.startFrom + "] not found");
projects = projects.subList(projectIndex, projects.size());
filteredProjects = filteredProjects.subList(projectIndex, projects.size());
options.startFrom = "";
} else if (!options.taskNames.isEmpty()) {
projects = projects.stream()
filteredProjects = filteredProjects.stream()
.filter(project -> options.taskNames.contains(project))
.collect(Collectors.toList());
options.taskNames = new ArrayList<>();
}
log.info("\n\n\nFor meta-release, will release the projects {}\n\n\n", projects);
return projects;
log.info("\n\n\nFor meta-release, will release the projects {}\n\n\n", filteredProjects);
return filteredProjects;
}
private File projectFolder() {

View File

@@ -203,6 +203,22 @@ public class AcceptanceTests {
.updateDocsRepo(BDDMockito.any(ProjectVersion.class), BDDMockito.anyString());
}
@Test
public void should_not_clone_any_projects_when_they_are_on_list_of_projects_to_skip() throws Exception {
Map<String, String> versions = new HashMap<>();
versions.put("spring-cloud-release", "Camden.BUILD-SNAPSHOT");
versions.put("spring-cloud-consul", "1.1.2.BUILD-SNAPSHOT");
SpringReleaser releaser = metaReleaser(versions);
this.releaserProperties.getMetaRelease().getProjectsToSkip().add("spring-cloud-release");
this.releaserProperties.getMetaRelease().getProjectsToSkip().add("spring-cloud-consul");
File temporaryDestination = tmp.newFolder();
this.releaserProperties.getGit().setCloneDestinationDir(temporaryDestination.getAbsolutePath());
releaser.release(new OptionsBuilder().metaRelease(true).options());
then(temporaryDestination.list()).isEmpty();
}
@Test
public void should_perform_a_meta_release_of_consul_only_when_run_from_got_passed() throws Exception {
// simulates an org