From 20a6207c2cac823125100644035b3baa933b6148 Mon Sep 17 00:00:00 2001 From: Mario Melcher Date: Thu, 1 Jul 2021 15:58:04 +0200 Subject: [PATCH 1/4] Latest tagged version from current branch is used for unchanged modules danielflower/multi-module-maven-release-plugin/#118 --- .../mavenplugins/release/AnnotatedTag.java | 41 +++++++++-- .../release/AnnotatedTagFinder.java | 72 +++++++++++++------ .../mavenplugins/release/DiffDetector.java | 3 +- .../mavenplugins/release/RefWithCommitId.java | 48 +++++++++++++ .../release/AnnotatedTagFinderTest.java | 34 ++++++--- .../release/DiffDetectorTest.java | 66 +++++++++++++---- .../mavenplugins/release/ReactorTest.java | 1 + src/test/java/scaffolding/TestProject.java | 10 +++ 8 files changed, 230 insertions(+), 45 deletions(-) create mode 100644 src/main/java/com/github/danielflower/mavenplugins/release/RefWithCommitId.java diff --git a/src/main/java/com/github/danielflower/mavenplugins/release/AnnotatedTag.java b/src/main/java/com/github/danielflower/mavenplugins/release/AnnotatedTag.java index 4a54d350..89384185 100644 --- a/src/main/java/com/github/danielflower/mavenplugins/release/AnnotatedTag.java +++ b/src/main/java/com/github/danielflower/mavenplugins/release/AnnotatedTag.java @@ -6,6 +6,7 @@ import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevTag; import org.eclipse.jgit.revwalk.RevWalk; import org.json.simple.JSONObject; @@ -16,28 +17,58 @@ public class AnnotatedTag { public static final String VERSION = "version"; public static final String BUILD_NUMBER = "buildNumber"; + public static final String TAG_PREFIX = "refs/tags/"; private final String name; private final JSONObject message; private Ref ref; + private RevCommit tagCommit; - private AnnotatedTag(Ref ref, String name, JSONObject message) { + private AnnotatedTag(Ref ref, RevCommit tagCommit, String name, JSONObject message) { Guard.notBlank("tag name", name); Guard.notNull("tag message", message); this.ref = ref; this.name = name; this.message = message; + this.tagCommit = tagCommit; + } + + public ObjectId getObjectId() { + return tagCommit.getId(); } public static AnnotatedTag create(String name, String version, long buildNumber) { JSONObject message = new JSONObject(); message.put(VERSION, version); message.put(BUILD_NUMBER, String.valueOf(buildNumber)); - return new AnnotatedTag(null, name, message); + return new AnnotatedTag(null, null, name, message); } public static AnnotatedTag fromRef(Repository repository, Ref gitTag) throws IOException, IncorrectObjectTypeException { Guard.notNull("gitTag", gitTag); + RevWalk walk = new RevWalk(repository); + JSONObject message; + RevCommit tagCommit; + try { + ObjectId tagId = gitTag.getObjectId(); + RevTag tag = walk.parseTag(tagId); + tagCommit = walk.parseCommit(tag); + message = (JSONObject) JSONValue.parse(tag.getFullMessage()); + } finally { + walk.dispose(); + } + if (message == null) { + message = new JSONObject(); + message.put(VERSION, "0"); + message.put(BUILD_NUMBER, "0"); + } + return new AnnotatedTag(gitTag, tagCommit, stripRefPrefix(gitTag.getName()), message); + } + + + public static AnnotatedTag fromRefCommit(Repository repository, Ref gitTag, RevCommit commit) throws IOException, IncorrectObjectTypeException { + Guard.notNull("gitTag", gitTag); + RevWalk walk = new RevWalk(repository); JSONObject message; try { @@ -52,11 +83,12 @@ public static AnnotatedTag fromRef(Repository repository, Ref gitTag) throws IOE message.put(VERSION, "0"); message.put(BUILD_NUMBER, "0"); } - return new AnnotatedTag(gitTag, stripRefPrefix(gitTag.getName()), message); + return new AnnotatedTag(gitTag, commit, stripRefPrefix(gitTag.getName()), message); } static String stripRefPrefix(String refName) { - return refName.substring("refs/tags/".length()); + assert refName.startsWith(TAG_PREFIX); + return refName.substring(TAG_PREFIX.length()); } public String name() { @@ -74,6 +106,7 @@ public long buildNumber() { public Ref saveAtHEAD(Git git) throws GitAPIException { String json = message.toJSONString(); ref = git.tag().setName(name()).setAnnotated(true).setMessage(json).call(); + tagCommit = git.log().setMaxCount(1).call().iterator().next(); return ref; } diff --git a/src/main/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinder.java b/src/main/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinder.java index 770e19c9..8320f259 100644 --- a/src/main/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinder.java +++ b/src/main/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinder.java @@ -1,15 +1,20 @@ package com.github.danielflower.mavenplugins.release; +import static java.util.stream.Collectors.groupingBy; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + import org.apache.maven.plugin.MojoExecutionException; import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.api.LogCommand; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.errors.IncorrectObjectTypeException; +import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Ref; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import org.eclipse.jgit.revwalk.RevCommit; class AnnotatedTagFinder { private VersionNamer versionNamer; @@ -20,28 +25,55 @@ class AnnotatedTagFinder { List tagsForVersion(Git git, String module, String versionWithoutBuildNumber) throws MojoExecutionException { ArrayList results = new ArrayList(); - List tags; try { - tags = git.tagList().call(); - } catch (GitAPIException e) { - throw new MojoExecutionException("Error while getting a list of tags in the local repo", e); - } - Collections.reverse(tags); - String tagWithoutBuildNumber = module + "-" + versionWithoutBuildNumber; - for (Ref tag : tags) { - if (isPotentiallySameVersionIgnoringBuildNumber(tagWithoutBuildNumber, tag.getName())) { - try { - results.add(AnnotatedTag.fromRef(git.getRepository(), tag)); - } catch (IncorrectObjectTypeException ignored) { - // not actually a tag, so skip it. - } catch (IOException e) { - throw new MojoExecutionException("Error while looking up tag " + tag, e); + ArrayList tagCommits = getAnnotatedTags(git, module, versionWithoutBuildNumber); + Map> commitTags = tagCommits.stream().collect(groupingBy( + RefWithCommitId::getCommitObjectId)); + Iterable commits = git.log().call(); + for (RevCommit commit : commits) { + if (commitTags.containsKey(commit.getId())) { + for (RefWithCommitId tag : commitTags.get(commit.getId())) { + try { + results.add(AnnotatedTag.fromRefCommit(git.getRepository(), tag.getRef(), commit)); + } catch (IncorrectObjectTypeException ignored) { + // not actually a tag, so skip it. + } catch (IOException e) { + throw new MojoExecutionException("Error while looking up tag " + tag, e); + } + } + // break; } } + } catch (GitAPIException | IOException e) { + throw new MojoExecutionException("Error while getting a list of annotated tags in the local repo", e); } return results; } + private ArrayList getAnnotatedTags(Git git, String module, String versionWithoutBuildNumber) + throws GitAPIException, IOException + { + String tagWithoutBuildNumber = module + "-" + versionWithoutBuildNumber; + ArrayList allTags = new ArrayList(); + List tags = git.tagList().call(); + + for (Ref ref : tags) { + if(!isPotentiallySameVersionIgnoringBuildNumber(tagWithoutBuildNumber, ref.getName())) continue; + + LogCommand log = git.log(); + + Ref peeledRef = git.getRepository().getRefDatabase().peel(ref); + if(peeledRef.getPeeledObjectId() != null) { + log.add(peeledRef.getPeeledObjectId()); + } else { + log.add(ref.getObjectId()); + } + RevCommit commit = log.call().iterator().next(); + allTags.add(new RefWithCommitId(ref, commit.getId())); + } + return allTags; + } + boolean isPotentiallySameVersionIgnoringBuildNumber(String versionWithoutBuildNumber, String refName) { return buildNumberOf(versionWithoutBuildNumber, refName) != null; } diff --git a/src/main/java/com/github/danielflower/mavenplugins/release/DiffDetector.java b/src/main/java/com/github/danielflower/mavenplugins/release/DiffDetector.java index ec87fb91..b9e81d7d 100644 --- a/src/main/java/com/github/danielflower/mavenplugins/release/DiffDetector.java +++ b/src/main/java/com/github/danielflower/mavenplugins/release/DiffDetector.java @@ -2,7 +2,8 @@ import java.io.IOException; import java.util.Collection; +import java.util.List; public interface DiffDetector { - boolean hasChangedSince(String modulePath, java.util.List childModules, Collection tags) throws IOException; + boolean hasChangedSince(String modulePath, List childModules, Collection tags) throws IOException; } diff --git a/src/main/java/com/github/danielflower/mavenplugins/release/RefWithCommitId.java b/src/main/java/com/github/danielflower/mavenplugins/release/RefWithCommitId.java new file mode 100644 index 00000000..1f679d9a --- /dev/null +++ b/src/main/java/com/github/danielflower/mavenplugins/release/RefWithCommitId.java @@ -0,0 +1,48 @@ +package com.github.danielflower.mavenplugins.release; + +import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.lib.Ref; + +public final class RefWithCommitId +{ + private final Ref ref; + private final ObjectId commitId; + + public RefWithCommitId(Ref ref, ObjectId commitId) { + Guard.notNull("ref", ref); + Guard.notNull("commitId", commitId); + this.ref = ref; + this.commitId = commitId; + } + + public Ref getRef() { + return ref; + } + + + + public ObjectId getCommitObjectId() { + return commitId; + } + + @Override + public String toString() { + return "RefWithCommitId{" + + "ref='" + ref.toString() + '\'' + + ", commitId=" + commitId.toString() + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RefWithCommitId that = (RefWithCommitId) o; + return ref.equals(that.ref); + } + + @Override + public int hashCode() { + return ref.hashCode(); + } +} diff --git a/src/test/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinderTest.java b/src/test/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinderTest.java index ff93802a..90d9d046 100644 --- a/src/test/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinderTest.java +++ b/src/test/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinderTest.java @@ -22,17 +22,21 @@ public class AnnotatedTagFinderTest { public void findsTheLatestCommitWhereThereHaveBeenNoBranches() throws Exception { TestProject project = TestProject.independentVersionsProject(); - AnnotatedTag tag1 = saveFileInModule(project, "console-app", "1.2", 3); - AnnotatedTag tag2 = saveFileInModule(project, "core-utils", "2", 0); - AnnotatedTag tag3 = saveFileInModule(project, "console-app", "1.2", 4); + AnnotatedTag tag1 = saveFileInModuleAndTag(project, "console-app", "1.2", 3); + AnnotatedTag tag2 = saveFileInModuleAndTag(project, "core-utils", "2", 0); + AnnotatedTag tag3 = saveFileInModuleAndTag(project, "console-app", "1.2", 4); assertThat(annotatedTagFinder.tagsForVersion(project.local, "console-app", "1.3"), hasSize(0)); assertThat(annotatedTagFinder.tagsForVersion(project.local, "console-app", "1.2"), containsInAnyOrder(tag1, tag3)); assertThat(annotatedTagFinder.tagsForVersion(project.local, "core-utils", "2"), contains(tag2)); } - static AnnotatedTag saveFileInModule(TestProject project, String moduleName, String version, long buildNumber) throws IOException, GitAPIException { + static AnnotatedTag saveFileInModuleAndTag(TestProject project, String moduleName, String version, long buildNumber) throws IOException, GitAPIException { project.commitRandomFile(moduleName); + return tagCurrentCommit(project, moduleName, version, buildNumber); + } + + static AnnotatedTag tagCurrentCommit(TestProject project, String moduleName, String version, long buildNumber) throws GitAPIException { String nameForTag = moduleName.equals(".") ? "root" : moduleName; return tagLocalRepo(project, nameForTag + "-" + version + versionNamer.getDelimiter() + buildNumber, version, buildNumber); } @@ -54,14 +58,28 @@ public void canRecogniseTagsThatArePotentiallyOfTheSameVersion() { @Test public void returnsMultipleTagsOnASingleCommit() throws IOException, GitAPIException, MojoExecutionException { TestProject project = TestProject.independentVersionsProject(); - saveFileInModule(project, "console-app", "1.2", 1); - AnnotatedTag tag1 = tagLocalRepo(project, "console-app-1.1.1.1", "1.1.1", 1); - AnnotatedTag tag3 = tagLocalRepo(project, "console-app-1.1.1.3", "1.1.1", 3); - AnnotatedTag tag2 = tagLocalRepo(project, "console-app-1.1.1.2", "1.1.1", 2); + saveFileInModuleAndTag(project, "console-app", "1.2", 1); + AnnotatedTag tag1 = tagCurrentCommit(project, "console-app", "1.1.1", 1); + AnnotatedTag tag3 = tagCurrentCommit(project, "console-app", "1.1.1", 3); + AnnotatedTag tag2 = tagCurrentCommit(project, "console-app", "1.1.1", 2); List annotatedTags = annotatedTagFinder.tagsForVersion(project.local, "console-app", "1.1.1"); assertThat(annotatedTags, containsInAnyOrder(tag1, tag2, tag3)); } + @Test + public void returnsOnlyTagsOfCurrentBranch() throws IOException, GitAPIException, MojoExecutionException { + TestProject project = TestProject.singleModuleProject(); + AnnotatedTag tag1 = saveFileInModuleAndTag(project, ".", "1.0", 0); + project.createBranch("feature"); + project.commitRandomFile("."); + AnnotatedTag tag2 = saveFileInModuleAndTag(project, ".", "1.0", 1); + project.checkoutBranch("feature"); + + List annotatedTags = annotatedTagFinder.tagsForVersion(project.local, "root", "1.0"); + + assertThat(annotatedTags, both(contains(tag1)).and(not(contains(tag2)))); + } + @Test public void versionNamerCaresNotForOrderOfTags() throws ValidationException { VersionNamer versionNamer = new VersionNamer(); diff --git a/src/test/java/com/github/danielflower/mavenplugins/release/DiffDetectorTest.java b/src/test/java/com/github/danielflower/mavenplugins/release/DiffDetectorTest.java index d465d357..b346cfd9 100644 --- a/src/test/java/com/github/danielflower/mavenplugins/release/DiffDetectorTest.java +++ b/src/test/java/com/github/danielflower/mavenplugins/release/DiffDetectorTest.java @@ -7,10 +7,12 @@ import java.io.IOException; import java.util.ArrayList; -import static com.github.danielflower.mavenplugins.release.AnnotatedTagFinderTest.saveFileInModule; +import static com.github.danielflower.mavenplugins.release.AnnotatedTagFinderTest.saveFileInModuleAndTag; +import static com.github.danielflower.mavenplugins.release.AnnotatedTagFinderTest.tagCurrentCommit; import static java.util.Arrays.asList; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; public class DiffDetectorTest { @@ -18,9 +20,9 @@ public class DiffDetectorTest { public void canDetectIfFilesHaveBeenChangedForAModuleSinceSomeSpecificTag() throws Exception { TestProject project = TestProject.independentVersionsProject(); - AnnotatedTag tag1 = saveFileInModule(project, "console-app", "1.2", 3); - AnnotatedTag tag2 = saveFileInModule(project, "core-utils", "2", 0); - AnnotatedTag tag3 = saveFileInModule(project, "console-app", "1.2", 4); + AnnotatedTag tag1 = saveFileInModuleAndTag(project, "console-app", "1.2", 3); + AnnotatedTag tag2 = saveFileInModuleAndTag(project, "core-utils", "2", 0); + AnnotatedTag tag3 = saveFileInModuleAndTag(project, "console-app", "1.2", 4); DiffDetector detector = new TreeWalkingDiffDetector(project.local.getRepository()); @@ -32,22 +34,23 @@ public void canDetectIfFilesHaveBeenChangedForAModuleSinceSomeSpecificTag() thro @Test public void canDetectThingsInTheRoot() throws IOException, GitAPIException { TestProject simple = TestProject.singleModuleProject(); - AnnotatedTag tag1 = saveFileInModule(simple, ".", "1.0", 1); + AnnotatedTag tag1 = saveFileInModuleAndTag(simple, ".", "1.0", 1); simple.commitRandomFile("."); DiffDetector detector = new TreeWalkingDiffDetector(simple.local.getRepository()); assertThat(detector.hasChangedSince(".", noChildModules(), asList(tag1)), is(true)); - AnnotatedTag tag2 = saveFileInModule(simple, ".", "1.0", 2); - assertThat(detector.hasChangedSince(".", noChildModules(), asList(tag2)), is(false)); + AnnotatedTag tag2 = saveFileInModuleAndTag(simple, ".", "1.0", 2); + assertThat(detector.hasChangedSince(".", noChildModules(), asList(tag1, tag2)), is(false)); + assertThat(detector.hasChangedSince(".", noChildModules(), asList(tag2, tag1)), is(false)); } @Test public void canDetectChangesAfterTheLastTag() throws IOException, GitAPIException { TestProject project = TestProject.independentVersionsProject(); - saveFileInModule(project, "console-app", "1.2", 3); - saveFileInModule(project, "core-utils", "2", 0); - AnnotatedTag tag3 = saveFileInModule(project, "console-app", "1.2", 4); + saveFileInModuleAndTag(project, "console-app", "1.2", 3); + saveFileInModuleAndTag(project, "core-utils", "2", 0); + AnnotatedTag tag3 = saveFileInModuleAndTag(project, "console-app", "1.2", 4); project.commitRandomFile("console-app"); DiffDetector detector = new TreeWalkingDiffDetector(project.local.getRepository()); @@ -58,7 +61,7 @@ public void canDetectChangesAfterTheLastTag() throws IOException, GitAPIExceptio public void canIgnoreChangesInModuleFolders() throws IOException, GitAPIException { TestProject project = TestProject.nestedProject(); - AnnotatedTag tag1 = saveFileInModule(project, "server-modules", "1.0.2.4", 0); + AnnotatedTag tag1 = saveFileInModuleAndTag(project, "server-modules", "1.0.2.4", 0); project.commitRandomFile("server-modules/server-module-a"); DiffDetector detector = new TreeWalkingDiffDetector(project.local.getRepository()); @@ -70,7 +73,7 @@ public void canIgnoreChangesInModuleFolders() throws IOException, GitAPIExceptio public void canDetectLocalChangesWithModuleFolders() throws IOException, GitAPIException { TestProject project = TestProject.nestedProject(); - AnnotatedTag tag1 = saveFileInModule(project, "server-modules", "1.0.2.4", 0); + AnnotatedTag tag1 = saveFileInModuleAndTag(project, "server-modules", "1.0.2.4", 0); project.commitRandomFile("server-modules"); DiffDetector detector = new TreeWalkingDiffDetector(project.local.getRepository()); @@ -78,6 +81,45 @@ public void canDetectLocalChangesWithModuleFolders() throws IOException, GitAPIE asList(tag1)), is(true)); } + @Test + public void canDetectLatestTagOnBranch() throws Exception { + TestProject project = TestProject.singleModuleProject(); + AnnotatedTag tag1 = saveFileInModuleAndTag(project, ".", "1.0", 0); + project.createBranch("feature"); + project.commitRandomFile("."); + AnnotatedTag tag2 = saveFileInModuleAndTag(project, ".", "1.0", 1); + project.checkoutBranch("feature"); + + DiffDetector detector = new TreeWalkingDiffDetector(project.local.getRepository()); + assertThat(detector.hasChangedSince(".", noChildModules(), + asList(tag1, tag2)), is(false)); + } + + @Test + public void canDetectLatestBuild() throws Exception { + TestProject project = TestProject.singleModuleProject(); + AnnotatedTag tag1 = saveFileInModuleAndTag(project, ".", "1.0", 0); + AnnotatedTag tag2 = tagCurrentCommit(project, ".", "1.0", 1); + + DiffDetector detector = new TreeWalkingDiffDetector(project.local.getRepository()); + assertThat(detector.hasChangedSince(".", noChildModules(), + asList(tag1, tag2)), is(false)); + assertThat(detector.hasChangedSince(".", noChildModules(), + asList(tag2, tag1)), is(false)); + } + + @Test + public void canDetectLatestBuildNoMatterIfCreatedWrongWayRound() throws Exception { + TestProject project = TestProject.singleModuleProject(); + AnnotatedTag tag2 = saveFileInModuleAndTag(project, ".", "1.0", 1); + AnnotatedTag tag1 = tagCurrentCommit(project, ".", "1.0", 0); + + DiffDetector detector = new TreeWalkingDiffDetector(project.local.getRepository()); + assertThat(detector.hasChangedSince(".", noChildModules(), + asList(tag2, tag1)), is(false)); + assertThat(detector.hasChangedSince(".", noChildModules(), + asList(tag1, tag2)), is(false)); + } private static java.util.List noChildModules() { return new ArrayList(); diff --git a/src/test/java/com/github/danielflower/mavenplugins/release/ReactorTest.java b/src/test/java/com/github/danielflower/mavenplugins/release/ReactorTest.java index 0ba29111..62243816 100644 --- a/src/test/java/com/github/danielflower/mavenplugins/release/ReactorTest.java +++ b/src/test/java/com/github/danielflower/mavenplugins/release/ReactorTest.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.util.Collection; import java.util.List; +import java.util.Optional; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.*; diff --git a/src/test/java/scaffolding/TestProject.java b/src/test/java/scaffolding/TestProject.java index 21f6524e..7f08f601 100644 --- a/src/test/java/scaffolding/TestProject.java +++ b/src/test/java/scaffolding/TestProject.java @@ -75,6 +75,16 @@ public TestProject commitRandomFile(String module) throws IOException, GitAPIExc return this; } + public TestProject checkoutBranch(String branch) throws GitAPIException { + local.checkout().setName(branch).call(); + return this; + } + + public TestProject createBranch(String branch) throws GitAPIException { + local.branchCreate().setName(branch).call(); + return this; + } + public void pushIt() throws GitAPIException { local.push().call(); } From 52705e249b34b4ae2ea5cfac95ef22da45f015bd Mon Sep 17 00:00:00 2001 From: Mario Melcher Date: Thu, 1 Jul 2021 16:07:41 +0200 Subject: [PATCH 2/4] improve the performance a little danielflower/multi-module-maven-release-plugin/#118 --- .../mavenplugins/release/AnnotatedTagFinder.java | 3 ++- .../mavenplugins/release/AnnotatedTagFinderTest.java | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinder.java b/src/main/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinder.java index 8320f259..3000e9cf 100644 --- a/src/main/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinder.java +++ b/src/main/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinder.java @@ -41,7 +41,8 @@ List tagsForVersion(Git git, String module, String versionWithoutB throw new MojoExecutionException("Error while looking up tag " + tag, e); } } - // break; + // we want the version of the latest commit so we stop here + break; } } } catch (GitAPIException | IOException e) { diff --git a/src/test/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinderTest.java b/src/test/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinderTest.java index 90d9d046..72a13781 100644 --- a/src/test/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinderTest.java +++ b/src/test/java/com/github/danielflower/mavenplugins/release/AnnotatedTagFinderTest.java @@ -22,13 +22,13 @@ public class AnnotatedTagFinderTest { public void findsTheLatestCommitWhereThereHaveBeenNoBranches() throws Exception { TestProject project = TestProject.independentVersionsProject(); - AnnotatedTag tag1 = saveFileInModuleAndTag(project, "console-app", "1.2", 3); - AnnotatedTag tag2 = saveFileInModuleAndTag(project, "core-utils", "2", 0); - AnnotatedTag tag3 = saveFileInModuleAndTag(project, "console-app", "1.2", 4); + saveFileInModuleAndTag(project, "console-app", "1.2", 3); + AnnotatedTag tag1 = saveFileInModuleAndTag(project, "core-utils", "2", 0); + AnnotatedTag tag2 = saveFileInModuleAndTag(project, "console-app", "1.2", 4); assertThat(annotatedTagFinder.tagsForVersion(project.local, "console-app", "1.3"), hasSize(0)); - assertThat(annotatedTagFinder.tagsForVersion(project.local, "console-app", "1.2"), containsInAnyOrder(tag1, tag3)); - assertThat(annotatedTagFinder.tagsForVersion(project.local, "core-utils", "2"), contains(tag2)); + assertThat(annotatedTagFinder.tagsForVersion(project.local, "console-app", "1.2"), contains(tag2)); + assertThat(annotatedTagFinder.tagsForVersion(project.local, "core-utils", "2"), contains(tag1)); } static AnnotatedTag saveFileInModuleAndTag(TestProject project, String moduleName, String version, long buildNumber) throws IOException, GitAPIException { From 0eaa2fef650f866982f2019954c5d0e084da1a09 Mon Sep 17 00:00:00 2001 From: Mario Melcher Date: Thu, 1 Jul 2021 16:37:43 +0200 Subject: [PATCH 3/4] set maven.compiler.source and target to 1.8 for all test-projects --- test-projects/deep-dependencies/parent-module/pom.xml | 4 +++- test-projects/deep-dependencies/pom.xml | 4 ++++ .../parent-module/pom.xml | 4 +++- .../pom.xml | 4 ++++ .../root-bom/pom.xml | 2 ++ test-projects/dependencymanagement/parent-module/pom.xml | 2 ++ test-projects/dependencymanagement/pom.xml | 5 +++++ test-projects/dependencymanagement/root-bom/pom.xml | 2 ++ test-projects/different-delimiter/pom.xml | 2 ++ test-projects/independent-versions/pom.xml | 2 ++ test-projects/inherited-versions-from-parent/pom.xml | 2 ++ test-projects/local-plugin/pom.xml | 2 ++ test-projects/module-with-profiles/pom.xml | 2 ++ test-projects/module-with-scm-tag/pom.xml | 2 ++ test-projects/module-with-test-failure/pom.xml | 2 ++ test-projects/nested-project/parent-module/pom.xml | 2 ++ test-projects/nested-project/pom.xml | 5 +++++ test-projects/nested-project/server-modules/pom.xml | 5 +++++ test-projects/parent-as-sibling/parent-module/pom.xml | 2 ++ test-projects/parent-as-sibling/pom.xml | 5 +++++ test-projects/single-module/pom.xml | 2 ++ .../snapshot-dependencies-with-version-properties/pom.xml | 2 ++ 22 files changed, 62 insertions(+), 2 deletions(-) diff --git a/test-projects/deep-dependencies/parent-module/pom.xml b/test-projects/deep-dependencies/parent-module/pom.xml index f64f02ad..b4ef2fbe 100644 --- a/test-projects/deep-dependencies/parent-module/pom.xml +++ b/test-projects/deep-dependencies/parent-module/pom.xml @@ -9,8 +9,10 @@ parent-module 1.2.3-SNAPSHOT pom - + 1.8 + 1.8 + UTF-8 1.8 1.8 diff --git a/test-projects/deep-dependencies/pom.xml b/test-projects/deep-dependencies/pom.xml index 96d69b52..bf56eedb 100644 --- a/test-projects/deep-dependencies/pom.xml +++ b/test-projects/deep-dependencies/pom.xml @@ -8,6 +8,10 @@ com.github.danielflower.mavenplugins.testprojects.deepdependencies deep-dependencies-aggregator 1.0-SNAPSHOT + + 1.8 + 1.8 + the-core-utilities console-app diff --git a/test-projects/dependencymanagement-using-parent-module-version-property/parent-module/pom.xml b/test-projects/dependencymanagement-using-parent-module-version-property/parent-module/pom.xml index 02391b5a..2b2f4023 100644 --- a/test-projects/dependencymanagement-using-parent-module-version-property/parent-module/pom.xml +++ b/test-projects/dependencymanagement-using-parent-module-version-property/parent-module/pom.xml @@ -9,8 +9,10 @@ parent-module ${parent-module.version} pom - + 1.8 + 1.8 + UTF-8 1.2.3-SNAPSHOT 1.8 diff --git a/test-projects/dependencymanagement-using-parent-module-version-property/pom.xml b/test-projects/dependencymanagement-using-parent-module-version-property/pom.xml index 4bcfad75..13ea564e 100644 --- a/test-projects/dependencymanagement-using-parent-module-version-property/pom.xml +++ b/test-projects/dependencymanagement-using-parent-module-version-property/pom.xml @@ -9,6 +9,10 @@ dependencymanagement-aggregator 1.0-SNAPSHOT pom + + 1.8 + 1.8 + diff --git a/test-projects/dependencymanagement-using-parent-module-version-property/root-bom/pom.xml b/test-projects/dependencymanagement-using-parent-module-version-property/root-bom/pom.xml index 65cb8531..850f7afc 100644 --- a/test-projects/dependencymanagement-using-parent-module-version-property/root-bom/pom.xml +++ b/test-projects/dependencymanagement-using-parent-module-version-property/root-bom/pom.xml @@ -11,6 +11,8 @@ pom + 1.8 + 1.8 4.0 diff --git a/test-projects/dependencymanagement/parent-module/pom.xml b/test-projects/dependencymanagement/parent-module/pom.xml index 75f31629..d16255e2 100644 --- a/test-projects/dependencymanagement/parent-module/pom.xml +++ b/test-projects/dependencymanagement/parent-module/pom.xml @@ -11,6 +11,8 @@ pom + 1.8 + 1.8 UTF-8 1.8 1.8 diff --git a/test-projects/dependencymanagement/pom.xml b/test-projects/dependencymanagement/pom.xml index 197d2f88..9325bd1b 100644 --- a/test-projects/dependencymanagement/pom.xml +++ b/test-projects/dependencymanagement/pom.xml @@ -10,6 +10,11 @@ 1.0-SNAPSHOT pom + + 1.8 + 1.8 + + diff --git a/test-projects/dependencymanagement/root-bom/pom.xml b/test-projects/dependencymanagement/root-bom/pom.xml index 258f267c..788a0199 100644 --- a/test-projects/dependencymanagement/root-bom/pom.xml +++ b/test-projects/dependencymanagement/root-bom/pom.xml @@ -12,6 +12,8 @@ pom + 1.8 + 1.8 4.0 diff --git a/test-projects/different-delimiter/pom.xml b/test-projects/different-delimiter/pom.xml index 9c1992dd..a4ec7b48 100644 --- a/test-projects/different-delimiter/pom.xml +++ b/test-projects/different-delimiter/pom.xml @@ -11,6 +11,8 @@ jar + 1.8 + 1.8 UTF-8 1.8 1.8 diff --git a/test-projects/independent-versions/pom.xml b/test-projects/independent-versions/pom.xml index 8c94ff76..ec9daab5 100644 --- a/test-projects/independent-versions/pom.xml +++ b/test-projects/independent-versions/pom.xml @@ -15,6 +15,8 @@ pom + 1.8 + 1.8 UTF-8 1.8 1.8 diff --git a/test-projects/inherited-versions-from-parent/pom.xml b/test-projects/inherited-versions-from-parent/pom.xml index 7728c8d9..5f94e4d1 100644 --- a/test-projects/inherited-versions-from-parent/pom.xml +++ b/test-projects/inherited-versions-from-parent/pom.xml @@ -15,6 +15,8 @@ pom + 1.8 + 1.8 UTF-8 1.8 1.8 diff --git a/test-projects/local-plugin/pom.xml b/test-projects/local-plugin/pom.xml index 5135e2c8..837a1957 100644 --- a/test-projects/local-plugin/pom.xml +++ b/test-projects/local-plugin/pom.xml @@ -10,6 +10,8 @@ ${my.version} + 1.8 + 1.8 1.0-SNAPSHOT 1.8 1.8 diff --git a/test-projects/module-with-profiles/pom.xml b/test-projects/module-with-profiles/pom.xml index 3c5b009d..9096f503 100644 --- a/test-projects/module-with-profiles/pom.xml +++ b/test-projects/module-with-profiles/pom.xml @@ -11,6 +11,8 @@ jar + 1.8 + 1.8 UTF-8 1.8 1.8 diff --git a/test-projects/module-with-scm-tag/pom.xml b/test-projects/module-with-scm-tag/pom.xml index bb6bfe91..88887ed4 100644 --- a/test-projects/module-with-scm-tag/pom.xml +++ b/test-projects/module-with-scm-tag/pom.xml @@ -11,6 +11,8 @@ pom + 1.8 + 1.8 UTF-8 1.8 1.8 diff --git a/test-projects/module-with-test-failure/pom.xml b/test-projects/module-with-test-failure/pom.xml index bd9d1f7b..90a4af9d 100644 --- a/test-projects/module-with-test-failure/pom.xml +++ b/test-projects/module-with-test-failure/pom.xml @@ -11,6 +11,8 @@ jar + 1.8 + 1.8 UTF-8 1.8 1.8 diff --git a/test-projects/nested-project/parent-module/pom.xml b/test-projects/nested-project/parent-module/pom.xml index 36d00bed..7f4147cc 100644 --- a/test-projects/nested-project/parent-module/pom.xml +++ b/test-projects/nested-project/parent-module/pom.xml @@ -11,6 +11,8 @@ pom + 1.8 + 1.8 UTF-8 1.8 1.8 diff --git a/test-projects/nested-project/pom.xml b/test-projects/nested-project/pom.xml index 75dd9a57..99bb9788 100644 --- a/test-projects/nested-project/pom.xml +++ b/test-projects/nested-project/pom.xml @@ -16,6 +16,11 @@ pom + + 1.8 + 1.8 + + diff --git a/test-projects/nested-project/server-modules/pom.xml b/test-projects/nested-project/server-modules/pom.xml index 708d159a..8b2457d4 100644 --- a/test-projects/nested-project/server-modules/pom.xml +++ b/test-projects/nested-project/server-modules/pom.xml @@ -15,6 +15,11 @@ pom + + 1.8 + 1.8 + + diff --git a/test-projects/parent-as-sibling/parent-module/pom.xml b/test-projects/parent-as-sibling/parent-module/pom.xml index 44744f0c..6e3c770e 100644 --- a/test-projects/parent-as-sibling/parent-module/pom.xml +++ b/test-projects/parent-as-sibling/parent-module/pom.xml @@ -11,6 +11,8 @@ pom + 1.8 + 1.8 UTF-8 1.8 1.8 diff --git a/test-projects/parent-as-sibling/pom.xml b/test-projects/parent-as-sibling/pom.xml index 13ba470c..d322e676 100644 --- a/test-projects/parent-as-sibling/pom.xml +++ b/test-projects/parent-as-sibling/pom.xml @@ -15,6 +15,11 @@ pom + + 1.8 + 1.8 + + diff --git a/test-projects/single-module/pom.xml b/test-projects/single-module/pom.xml index c906bc9a..ff9feb46 100644 --- a/test-projects/single-module/pom.xml +++ b/test-projects/single-module/pom.xml @@ -11,6 +11,8 @@ jar + 1.8 + 1.8 UTF-8 1.8 1.8 diff --git a/test-projects/snapshot-dependencies-with-version-properties/pom.xml b/test-projects/snapshot-dependencies-with-version-properties/pom.xml index 5b37646e..02253cbe 100644 --- a/test-projects/snapshot-dependencies-with-version-properties/pom.xml +++ b/test-projects/snapshot-dependencies-with-version-properties/pom.xml @@ -12,6 +12,8 @@ Project with snapshot dependencies + 1.8 + 1.8 UTF-8 1.8 1.8 From a12837af8323e1f4ffde48e20e13f3fc6fb96cc9 Mon Sep 17 00:00:00 2001 From: Mario Melcher Date: Thu, 1 Jul 2021 16:40:53 +0200 Subject: [PATCH 4/4] bump version to 3.6 because of breaking change --- pom.xml | 2 +- src/site/markdown/changelog.md | 4 ++++ src/test/java/scaffolding/TestProject.java | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index ec10fa98..36f2e4dd 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.danielflower.mavenplugins multi-module-maven-release-plugin - 3.5-SNAPSHOT + 3.6-SNAPSHOT The Multi Module Maven Release Plugin A maven release plugin built for multi-maven-module git repositories allowing continuous deployment diff --git a/src/site/markdown/changelog.md b/src/site/markdown/changelog.md index 408c267a..2cb828ec 100644 --- a/src/site/markdown/changelog.md +++ b/src/site/markdown/changelog.md @@ -1,6 +1,10 @@ Changelog --------- +### 3.6.0 + +* Latest tagged version from current branch is used for unchanged modules [issue #118 for details](https://github.com/danielflower/multi-module-maven-release-plugin/issues/118) + ### 3.2.0 * Added support for processing version properties e.g. `${foo.version}` diff --git a/src/test/java/scaffolding/TestProject.java b/src/test/java/scaffolding/TestProject.java index 7f08f601..60c9556a 100644 --- a/src/test/java/scaffolding/TestProject.java +++ b/src/test/java/scaffolding/TestProject.java @@ -19,7 +19,7 @@ public class TestProject { private static final MvnRunner defaultRunner = new MvnRunner(null); - private static final String PLUGIN_VERSION_FOR_TESTS = "3.5-SNAPSHOT"; + private static final String PLUGIN_VERSION_FOR_TESTS = "3.6-SNAPSHOT"; public final File originDir; public final Git origin;