WIP
This commit is contained in:
@@ -61,16 +61,13 @@ class GitProjectRepo {
|
||||
*/
|
||||
File cloneProject(URI projectUri) {
|
||||
try {
|
||||
File file = new File(projectUri.getPath());
|
||||
URI modifiedUri = file.getName().endsWith(File.separator) ?
|
||||
projectUri : new File(file.getPath() + File.separator).toURI();
|
||||
log.debug("Cloning repo from [{}] to [{}]", modifiedUri, this.basedir);
|
||||
Git git = cloneToBasedir(modifiedUri, this.basedir);
|
||||
log.info("Cloning repo from [{}] to [{}]", projectUri, this.basedir);
|
||||
Git git = cloneToBasedir(projectUri, this.basedir);
|
||||
if (git != null) {
|
||||
git.close();
|
||||
}
|
||||
File clonedRepo = git.getRepository().getWorkTree();
|
||||
log.debug("Cloned repo to [{}]", clonedRepo);
|
||||
log.info("Cloned repo to [{}]", clonedRepo);
|
||||
return clonedRepo;
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -85,9 +82,9 @@ class GitProjectRepo {
|
||||
*/
|
||||
void checkout(File project, String branch) {
|
||||
try {
|
||||
log.debug("Checking out branch [{}] for repo [{}] to [{}]", this.basedir, branch);
|
||||
log.info("Checking out branch [{}] for repo [{}] to [{}]", this.basedir, branch);
|
||||
checkoutBranch(project, branch);
|
||||
log.debug("Successfully checked out the branch [{}]", branch);
|
||||
log.info("Successfully checked out the branch [{}]", branch);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
|
||||
@@ -53,6 +53,9 @@ class PomUpdater {
|
||||
if (!versions.shouldBeUpdated(model.getArtifactId())) {
|
||||
log.info("Skipping project [{}] since it's not on the list of projects to update", model.getArtifactId());
|
||||
return false;
|
||||
} else if (versions.versionAlreadySet(model.getArtifactId(), model.getVersion())) {
|
||||
log.info("Version has already been set. The project shouldn't be updated.");
|
||||
return false;
|
||||
}
|
||||
log.info("Project [{}] will have its dependencies updated", model.getArtifactId());
|
||||
return true;
|
||||
@@ -112,6 +115,9 @@ class PomUpdater {
|
||||
}
|
||||
|
||||
private boolean updateParentIfPossible(String rootProjectName, Versions versions, Model model) {
|
||||
if (model.getParent() == null || StringUtils.isEmpty(model.getParent().getVersion())) {
|
||||
return false;
|
||||
}
|
||||
String parentArtifactId = model.getParent().getArtifactId();
|
||||
String version = versions.versionForProject(parentArtifactId);
|
||||
if (StringUtils.isEmpty(version)) {
|
||||
@@ -129,7 +135,7 @@ class PomUpdater {
|
||||
|
||||
private boolean updateVersionIfPossible(String rootProjectName, Versions versions, Model model) {
|
||||
String version = versions.versionForProject(rootProjectName);
|
||||
if (StringUtils.isEmpty(version)) {
|
||||
if (StringUtils.isEmpty(version) || StringUtils.isEmpty(model.getVersion())) {
|
||||
log.warn("There was no version set for project [{}], skipping version setting for module [{}]", rootProjectName, model.getArtifactId());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ProjectUpdater {
|
||||
SCReleasePomParser SCReleasePomParser = new SCReleasePomParser(clonedScRelease);
|
||||
Versions versions = SCReleasePomParser.allVersions();
|
||||
if (!this.pomUpdater.shouldProjectBeUpdated(projectRoot, versions)) {
|
||||
log.info("Project is not on the list of projects to be updated. Skipping.");
|
||||
log.info("Skipping project updating");
|
||||
return;
|
||||
}
|
||||
File rootPom = new File(projectRoot, "pom.xml");
|
||||
|
||||
@@ -11,7 +11,7 @@ public class ReleaserProperties {
|
||||
/**
|
||||
* URL to Spring Cloud Release Git repository
|
||||
*/
|
||||
private String springCloudReleaseGitUrl = "https://github.com/spring-cloud/spring-cloud-release.git";
|
||||
private String springCloudReleaseGitUrl = "https://github.com/spring-cloud/spring-cloud-release";
|
||||
|
||||
/**
|
||||
* Where should the Spring Cloud Release repo get cloned to. If {@code null} defaults to a temporary directory
|
||||
|
||||
@@ -51,6 +51,11 @@ class Versions {
|
||||
return this.projects.stream()
|
||||
.anyMatch(project -> project.name.equals(projectName));
|
||||
}
|
||||
|
||||
boolean versionAlreadySet(String projectName, String version) {
|
||||
String versionForProject = versionForProject(projectName);
|
||||
return version.equals(versionForProject);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -73,7 +73,7 @@ public class AcceptanceTests {
|
||||
|
||||
private ReleaserProperties releaserProperties() throws URISyntaxException {
|
||||
ReleaserProperties releaserProperties = new ReleaserProperties();
|
||||
releaserProperties.setSpringCloudReleaseGitUrl(file("/projects/spring-cloud-release/").getPath());
|
||||
releaserProperties.setSpringCloudReleaseGitUrl(file("/projects/spring-cloud-release/").toURI().getPath());
|
||||
return releaserProperties;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user