Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public static Reactor fromProjects(BaseMojo mojo, Log log, LocalGitRepo gitRepo,
resolveVersionsDefinedThroughProperties(mojo.getProjects());

AnnotatedTagFinder annotatedTagFinder = new AnnotatedTagFinder(mojo.getVersionNamer());
List<String> moduleReleaseLogMessages = new ArrayList<>();

for (MavenProject project : mojo.getProjects()) {
String relativePathToModule = calculateModulePath(mojo.getProject(), project);
String artifactId = project.getArtifactId();
Expand Down Expand Up @@ -92,29 +94,34 @@ public static Reactor fromProjects(BaseMojo mojo, Log log, LocalGitRepo gitRepo,
String equivalentVersion = null;

if (mojo.getModulesToForceRelease() != null && mojo.getModulesToForceRelease().contains(artifactId)) {
log.info("Releasing " + artifactId + " " + newVersion.releaseVersion() + " as we were asked to force release.");
moduleReleaseLogMessages.add("Releasing " + artifactId + " " + newVersion.releaseVersion() + " as we were asked to force release.");
} else if (oneOfTheDependenciesHasChanged) {
log.info("Releasing " + artifactId + " " + newVersion.releaseVersion() + " as " + changedDependency + " has changed.");
moduleReleaseLogMessages.add("Releasing " + artifactId + " " + newVersion.releaseVersion() + " as " + changedDependency + " has changed.");
} else {
AnnotatedTag previousTagThatIsTheSameAsHEADForThisModule = hasChangedSinceLastRelease(previousTagsForThisModule, detector, project, relativePathToModule);
if (previousTagThatIsTheSameAsHEADForThisModule != null) {
equivalentVersion = previousTagThatIsTheSameAsHEADForThisModule.version() + mojo.getVersionNamer().getDelimiter() + previousTagThatIsTheSameAsHEADForThisModule.buildNumber();
// attempt to resolve
if (resolverWrapper.isResolvable(project.getGroupId(), project.getArtifactId(), equivalentVersion, project.getPackaging(), log)) {
log.info("Will use version " + equivalentVersion + " for " + artifactId + " as it has not been changed since that release.");
moduleReleaseLogMessages.add("Will use version " + equivalentVersion + " for " + artifactId + " as it has not been changed since that release.");
} else {
log.info("Will use version " + newVersion.releaseVersion() + " for " + artifactId + " as although no change was detected, the artifact cannot be resolved!");
moduleReleaseLogMessages.add("Will use version " + newVersion.releaseVersion() + " for " + artifactId + " as although no change was detected, the artifact cannot be resolved!");
equivalentVersion = null;
}
} else {
log.info("Will use version " + newVersion.releaseVersion() + " for " + artifactId + " as it has changed since the last release.");
moduleReleaseLogMessages.add("Will use version " + newVersion.releaseVersion() + " for " + artifactId + " as it has changed since the last release.");
}
}
ReleasableModule module = new ReleasableModule(project, newVersion, equivalentVersion, relativePathToModule, mojo.getTagNameFormat(), log);
modules.add(module);
}

if (!atLeastOneBeingReleased(modules)) {
if (atLeastOneBeingReleased(modules)) {
for (String moduleReleaseLogMessage : moduleReleaseLogMessages) {
log.info(moduleReleaseLogMessage);
}
}
else {
switch (actionWhenNoChangesDetected) {
case ReleaseNone:
log.warn("No changes have been detected in any modules so will not perform release");
Expand All @@ -125,6 +132,7 @@ public static Reactor fromProjects(BaseMojo mojo, Log log, LocalGitRepo gitRepo,
log.warn("No changes have been detected in any modules so will re-release them all");
List<ReleasableModule> newList = new ArrayList<ReleasableModule>();
for (ReleasableModule module : modules) {
log.info("Will use version " + module.getNewVersion() + " for " + module.getArtifactId() + " as it has not been changed since that release.");
newList.add(module.createReleasableVersion(log));
}
modules = newList;
Expand Down
15 changes: 5 additions & 10 deletions src/test/java/e2e/NextMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ public void ifThereHaveBeenNoChangesThenReReleaseAllModules() throws Exception {
assertTagDoesNotExist("more-utils-10.0.2");
assertTagDoesNotExist("deep-dependencies-aggregator-1.0.2");

assertThat(output, oneOf(containsString("[INFO] Will use version 1.2.3.1 for parent-module as it has not been changed since that release.")));
assertThat(output, oneOf(containsString("[INFO] Will use version 10.0.1 for more-utils as it has not been changed since that release.")));
assertThat(output, oneOf(containsString("[INFO] Will use version 2.0.1 for core-utils as it has not been changed since that release.")));
assertThat(output, oneOf(containsString("[INFO] Will use version 3.2.1 for console-app as it has not been changed since that release.")));
assertThat(output, oneOf(containsString("[INFO] Will use version 1.0.1 for deep-dependencies-aggregator as it has not been changed since that release.")));
assertThat(output, oneOf(containsString("[WARNING] No changes have been detected in any modules so will re-release them all")));
assertThat(output, oneOf(containsString("[INFO] Will use version 1.2.3.2 for parent-module as it has not been changed since that release.")));
assertThat(output, oneOf(containsString("[INFO] Will use version 10.0.2 for more-utils as it has not been changed since that release.")));
assertThat(output, oneOf(containsString("[INFO] Will use version 2.0.2 for core-utils as it has not been changed since that release.")));
assertThat(output, oneOf(containsString("[INFO] Will use version 3.2.2 for console-app as it has not been changed since that release.")));
assertThat(output, oneOf(containsString("[INFO] Will use version 1.0.2 for deep-dependencies-aggregator as it has not been changed since that release.")));
}

@Test
Expand All @@ -86,11 +86,6 @@ public void ifThereHaveBeenNoChangesCanOptToReleaseNoModules() throws Exception
assertTagDoesNotExist("more-utils-10.0.2");
assertTagDoesNotExist("deep-dependencies-aggregator-1.0.2");

assertThat(output, oneOf(containsString("[INFO] Will use version 1.2.3.1 for parent-module as it has not been changed since that release.")));
assertThat(output, oneOf(containsString("[INFO] Will use version 10.0.1 for more-utils as it has not been changed since that release.")));
assertThat(output, oneOf(containsString("[INFO] Will use version 2.0.1 for core-utils as it has not been changed since that release.")));
assertThat(output, oneOf(containsString("[INFO] Will use version 3.2.1 for console-app as it has not been changed since that release.")));
assertThat(output, oneOf(containsString("[INFO] Will use version 1.0.1 for deep-dependencies-aggregator as it has not been changed since that release.")));
assertThat(output, oneOf(containsString("[WARNING] No changes have been detected in any modules so will not perform release")));
}

Expand Down
8 changes: 7 additions & 1 deletion src/test/java/e2e/SkippingUnchangedModulesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,19 @@ public void ifThereHaveBeenNoChangesThenReReleaseAllModules() throws Exception {
List<String> firstBuildOutput = testProject.mvnRelease("1");
assertThat(firstBuildOutput, noneOf(containsString("No changes have been detected in any modules so will re-release them all")));
List<String> secondBuildOutput = testProject.mvnRelease("2");
assertThat(secondBuildOutput, oneOf(containsString("No changes have been detected in any modules so will re-release them all")));

assertTagExists("console-app-3.2.2");
assertTagExists("parent-module-1.2.3.2");
assertTagExists("core-utils-2.0.2");
assertTagExists("more-utils-10.0.2");
assertTagExists("deep-dependencies-aggregator-1.0.2");

assertThat(secondBuildOutput, oneOf(containsString("[WARNING] No changes have been detected in any modules so will re-release them all")));
assertThat(secondBuildOutput, oneOf(containsString("[INFO] Will use version 1.2.3.2 for parent-module as it has not been changed since that release.")));
assertThat(secondBuildOutput, oneOf(containsString("[INFO] Will use version 10.0.2 for more-utils as it has not been changed since that release.")));
assertThat(secondBuildOutput, oneOf(containsString("[INFO] Will use version 2.0.2 for core-utils as it has not been changed since that release.")));
assertThat(secondBuildOutput, oneOf(containsString("[INFO] Will use version 3.2.2 for console-app as it has not been changed since that release.")));
assertThat(secondBuildOutput, oneOf(containsString("[INFO] Will use version 1.0.2 for deep-dependencies-aggregator as it has not been changed since that release.")));
}

@Test
Expand Down