Repository: mojohaus/versions
Pull request #1053 (2024-02-21 00:14:09)

Bump org.postgresql:postgresql from 42.4.3 to 42.7.2 in /versions-maven-plugin/src/it/it-property-updates-report-002-slow
Bumps [org.postgresql:postgresql](https://github.com/pgjdbc/pgjdbc) from 42.4.3 to 42.7.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/pgjdbc/pgjdbc/releases">org.postgresql:postgresql's releases</a>.</em></p>
<blockquote>
<h2>v42.7.1</h2>
<h2>Fixed regressions since 42.7.0</h2>
<ul>
<li>Revert &quot;Use canonical DateStyle name (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/2925">#2925</a>)&quot; <a href="https://github.com/vlsi"><code>@​vlsi</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3035">#3035</a>)</li>
<li>Revert &quot;feat: support SET statements combining with other queries with semicolon in PreparedStatement&quot; <a href="https://github.com/vlsi"><code>@​vlsi</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3010">#3010</a>)</li>
<li>chore: use java.release=8 when building pgjdbc from the generated source distribution <a href="https://github.com/vlsi"><code>@​vlsi</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3038">#3038</a>), the driver uses Java 8 methods only</li>
</ul>
<h2>Changes</h2>
<ul>
<li>Apply connectTimeout before SSLSocket.startHandshake to avoid infinite wait in case the connection is broken <a href="https://github.com/davecramer"><code>@​davecramer</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3040">#3040</a>)</li>
<li>perf: improve performance of PreparedStatement.setBlob, BlobInputStream, and BlobOutputStream with dynamic buffer sizing <a href="https://github.com/vlsi"><code>@​vlsi</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3044">#3044</a>)</li>
<li>fix: avoid timezone conversions when sending LocalDateTime to the database <a href="https://github.com/vlsi"><code>@​vlsi</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/2852">#2852</a>)</li>
<li>fix: support waffle-jna 2.x and 3.x by using reflective approach for ManagedSecBufferDesc <a href="https://github.com/chrullrich"><code>@​chrullrich</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/2720">#2720</a>)</li>
</ul>
<h2>🧰 Maintenance</h2>
<ul>
<li>chore: bump Gradle to 8.5 <a href="https://github.com/vlsi"><code>@​vlsi</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3045">#3045</a>)</li>
<li>chore: use Java 17 for building pgjdbc, and use --release 8 to target Java 8, add tests with Java 21 and 22 <a href="https://github.com/vlsi"><code>@​vlsi</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3026">#3026</a>)</li>
<li>fedora/rpm: move source build to java-17-openjdk-devel <a href="https://github.com/praiskup"><code>@​praiskup</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3036">#3036</a>)</li>
<li>Update site 42 7 0 <a href="https://github.com/davecramer"><code>@​davecramer</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3004">#3004</a>)</li>
<li>prepared for release 42.7.1 update changelogs <a href="https://github.com/davecramer"><code>@​davecramer</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3037">#3037</a>)</li>
</ul>
<h2>⬆️ Dependencies</h2>
<!-- raw HTML omitted -->
<ul>
<li>fix(deps): update dependency org.checkerframework:org.checkerframework.gradle.plugin to v0.6.36 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3060">#3060</a>)</li>
<li>chore(deps): update plugin biz.aqute.bnd.builder to v7 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3034">#3034</a>)</li>
<li>fix(deps): update dependency com.github.spotbugs:com.github.spotbugs.gradle.plugin to v6 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3056">#3056</a>)</li>
<li>fix(deps): update dependency com.github.spotbugs:com.github.spotbugs.gradle.plugin to v5.2.5 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3032">#3032</a>)</li>
<li>chore(deps): update codecov/codecov-action digest to b0466b4 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3059">#3059</a>)</li>
<li>fix(deps): update checkerframework to v3.41.0 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3058">#3058</a>)</li>
<li>fix(deps): update logback to v1.2.13 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3053">#3053</a>)</li>
<li>chore(deps): update codecov/codecov-action digest to 438fa9e <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3051">#3051</a>)</li>
<li>fix(deps): update dependency spotbugs to v4.8.2 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3052">#3052</a>)</li>
<li>chore: bump Gradle to 8.5 <a href="https://github.com/vlsi"><code>@​vlsi</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3045">#3045</a>)</li>
<li>fix(deps): update dependency org.ops4j.pax.url:pax-url-aether to v2.6.14 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3030">#3030</a>)</li>
<li>chore(deps): update plugin org.nosphere.gradle.github.actions to v1.4.0 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3031">#3031</a>)</li>
<li>chore(deps): update dependency ubuntu to v22 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3033">#3033</a>)</li>
<li>fix(deps): update checkerframework <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3027">#3027</a>)</li>
<li>fix(deps): update dependency spotbugs to v4.8.1 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3023">#3023</a>)</li>
<li>fix(deps): update dependency uk.org.webcompere:system-stubs-jupiter to v2.1.5 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3024">#3024</a>)</li>
<li>fix(deps): update jmh to v1.37 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3025">#3025</a>)</li>
<li>fix(deps): update dependency com.google.errorprone:error_prone_core to v2.23.0 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3022">#3022</a>)</li>
<li>fix(deps): update junit5 monorepo to v5.10.1 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3015">#3015</a>)</li>
<li>chore(deps): update plugin com.github.burrunan.s3-build-cache to v1.7 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3016">#3016</a>)</li>
<li>chore(deps): update dependency com.typesafe.play:sbt-plugin to v2.9.0 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3021">#3021</a>)</li>
<li>fix(deps): update dependency checkstyle to v10.12.5 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3020">#3020</a>)</li>
<li>chore(deps): update codecov/codecov-action digest to 920a494 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3019">#3019</a>)</li>
<li>chore(deps): update actions/github-script action to v7 <a href="https://github.com/renovate-bot"><code>@​renovate-bot</code></a> (<a href="https://redirect.github.com/pgjdbc/pgjdbc/issues/3018">#3018</a>)</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a href="https://github.com/pgjdbc/pgjdbc/commits">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=org.postgresql:postgresql&package-manager=maven&previous-version=42.4.3&new-version=42.7.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/mojohaus/versions/network/alerts).

</details>


Patch:
diff --git a/versions-maven-plugin/src/it/it-property-updates-report-002-slow/pom.xml b/versions-maven-plugin/src/it/it-property-updates-report-002-slow/pom.xml
index a9f954a1..6bbf96a5 100644
--- a/versions-maven-plugin/src/it/it-property-updates-report-002-slow/pom.xml
+++ b/versions-maven-plugin/src/it/it-property-updates-report-002-slow/pom.xml
@@ -18,7 +18,7 @@
     <httpclient.version>4.5.13</httpclient.version>
     <jackson.version>2.6.7.3</jackson.version>
     <mariadb-client.version>2.4.3</mariadb-client.version>
-    <postgresql-client.version>42.4.3</postgresql-client.version>
+    <postgresql-client.version>42.7.2</postgresql-client.version>
     <groovy.version>2.0.0</groovy.version>
   </properties>
 
diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java
index 93f56e27..6af235e9 100644
--- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java
+++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java
@@ -25,20 +25,24 @@ import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.Set;
 import java.util.SortedMap;
 import java.util.TimeZone;
 import java.util.TreeMap;
 import java.util.regex.Pattern;
 
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
 import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.model.Model;
-import org.apache.maven.model.Parent;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.Mojo;
@@ -334,6 +338,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo {
             Map<File, Model> reactorModels = PomHelper.getChildModels(project, getLog());
             final SortedMap<File, Model> reactor = new TreeMap<>(new ReactorDepthComparator(reactorModels));
             reactor.putAll(reactorModels);
+            final Map<Pair<String, String>, Set<Model>> children = computeChildren(reactorModels);
 
             // set of files to update
             final Set<File> files = new LinkedHashSet<>();
@@ -379,8 +384,8 @@ public class SetMojo extends AbstractVersionsUpdaterMojo {
                                 || oldVersionIdRegex.matcher(mVersion).matches())
                         && !newVersion.equals(mVersion)) {
                     applyChange(
-                            project,
                             reactor,
+                            children,
                             files,
                             mGroupId,
                             m.getArtifactId(),
@@ -407,6 +412,34 @@ public class SetMojo extends AbstractVersionsUpdaterMojo {
         }
     }
 
+    static Map<Pair<String, String>, Set<Model>> computeChildren(Map<File, Model> reactor) {
+        return reactor.values().stream()
+                .filter(v -> v.getParent() != null)
+                .reduce(
+                        new HashMap<>(),
+                        (map, child) -> {
+                            map.compute(
+                                    new ImmutablePair<>(
+                                            child.getParent().getGroupId(),
+                                            child.getParent().getArtifactId()),
+                                    (pair, set) -> Optional.ofNullable(set)
+                                            .map(children -> {
+                                                children.add(child);
+                                                return children;
+                                            })
+                                            .orElse(new HashSet<Model>() {
+                                                {
+                                                    add(child);
+                                                }
+                                            }));
+                            return map;
+                        },
+                        (m1, m2) -> {
+                            m1.putAll(m2);
+                            return m1;
+                        });
+    }
+
     /**
      * Returns the incremented version, with the nextSnapshotIndexToIncrement indicating the 1-based index,
      * from the left, or the most major version component, of the version string.
@@ -436,28 +469,21 @@ public class SetMojo extends AbstractVersionsUpdaterMojo {
         return StringUtils.join(numbers.toArray(new String[0]), ".") + "-SNAPSHOT";
     }
 
-    private static String fixNullOrEmpty(String value, String defaultValue) {
-        return StringUtils.isBlank(value) ? defaultValue : value;
-    }
-
     private void applyChange(
-            MavenProject project,
             SortedMap<File, Model> reactor,
+            Map<Pair<String, String>, Set<Model>> children,
             Set<File> files,
             String groupId,
             String artifactId,
             String oldVersion) {
 
         getLog().debug("Applying change " + groupId + ":" + artifactId + ":" + oldVersion + " -> " + newVersion);
-        // this is a triggering change
         addChange(groupId, artifactId, oldVersion, newVersion);
-        // now fake out the triggering change
 
-        Map.Entry<File, Model> current = PomHelper.getModelEntry(reactor, groupId, artifactId);
-        if (current != null) {
-            current.getValue().setVersion(newVersion);
-            files.add(current.getValue().getPomFile());
-        }
+        Optional.ofNullable(PomHelper.getModelEntry(reactor, groupId, artifactId))
+                .map(Map.Entry::getValue)
+                .map(Model::getPomFile)
+                .ifPresent(files::add);
 
         for (Map.Entry<File, Model> sourceEntry : reactor.entrySet()) {
             final File sourcePath = sourceEntry.getKey();
@@ -488,50 +514,27 @@ public class SetMojo extends AbstractVersionsUpdaterMojo {
 
             getLog().debug("Looking for modules which use "
                     + ArtifactUtils.versionlessKey(sourceGroupId, sourceArtifactId) + " as their parent");
-
-            for (Map.Entry<File, Model> stringModelEntry : processAllModules
-                    ? reactor.entrySet()
-                    : PomHelper.getChildModels(reactor, sourceGroupId, sourceArtifactId)
-                            .entrySet()) {
-                final Model targetModel = stringModelEntry.getValue();
-                final Parent parent = targetModel.getParent();
-                getLog().debug("Module: " + stringModelEntry.getKey());
-                if (parent != null && sourceVersion.equals(parent.getVersion())) {
-                    getLog().debug("    parent already is "
-                            + ArtifactUtils.versionlessKey(sourceGroupId, sourceArtifactId) + ":" + sourceVersion);
-                } else {
-                    getLog().debug("    parent is " + ArtifactUtils.versionlessKey(sourceGroupId, sourceArtifactId)
-                            + ":" + (parent == null ? "" : parent.getVersion()));
-                    getLog().debug("    will become " + ArtifactUtils.versionlessKey(sourceGroupId, sourceArtifactId)
-                            + ":" + sourceVersion);
-                }
-                final boolean targetExplicit = PomHelper.isExplicitVersion(targetModel);
-                if ((updateMatchingVersions || !targetExplicit) //
-                        && (parent != null
-                                && StringUtils.equals(parent.getVersion(), PomHelper.getVersion(targetModel)))) {
-                    getLog().debug("    module is "
-                            + ArtifactUtils.versionlessKey(
-                                    PomHelper.getGroupId(targetModel), PomHelper.getArtifactId(targetModel))
-                            + ":"
-                            + PomHelper.getVersion(targetModel));
-                    getLog().debug("    will become "
-                            + ArtifactUtils.versionlessKey(
-                                    PomHelper.getGroupId(targetModel), PomHelper.getArtifactId(targetModel))
-                            + ":" + sourceVersion);
-                    addChange(
-                            PomHelper.getGroupId(targetModel),
-                            PomHelper.getArtifactId(targetModel),
-                            PomHelper.getVersion(targetModel),
-                            sourceVersion);
-                    targetModel.setVersion(sourceVersion);
-                } else {
-                    getLog().debug("    module is "
-                            + ArtifactUtils.versionlessKey(
-                                    PomHelper.getGroupId(targetModel), PomHelper.getArtifactId(targetModel))
-                            + ":"
-                            + PomHelper.getVersion(targetModel));
-                }
-            }
+            Optional.ofNullable(children.get(new ImmutablePair<>(sourceGroupId, sourceArtifactId)))
+                    .ifPresent(set -> set.forEach(model -> {
+                        final boolean hasExplicitVersion = PomHelper.isExplicitVersion(model);
+                        if ((updateMatchingVersions || !hasExplicitVersion)
+                                && (StringUtils.equals(sourceVersion, PomHelper.getVersion(model)))) {
+                            getLog().debug("    module is "
+                                    + ArtifactUtils.versionlessKey(
+                                            PomHelper.getGroupId(model), PomHelper.getArtifactId(model))
+                                    + ":"
+                                    + PomHelper.getVersion(model));
+                            getLog().debug("    will become "
+                                    + ArtifactUtils.versionlessKey(
+                                            PomHelper.getGroupId(model), PomHelper.getArtifactId(model))
+                                    + ":" + newVersion);
+                            addChange(
+                                    PomHelper.getGroupId(model),
+                                    PomHelper.getArtifactId(model),
+                                    PomHelper.getVersion(model),
+                                    newVersion);
+                        }
+                    }));
         }
     }
 


Test patch:
diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java
index 4ffcdf08..9bebfd58 100644
--- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java
+++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java
@@ -5,10 +5,16 @@ import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
 import java.util.function.Consumer;
 import java.util.stream.Stream;
 
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
 import org.apache.maven.model.Model;
+import org.apache.maven.model.Parent;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
@@ -23,8 +29,12 @@ import org.junit.Test;
 import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.hasSize;
 import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.matchesPattern;
+import static org.hamcrest.Matchers.matchesRegex;
 import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.nullValue;
 
 public class SetMojoTest extends AbstractMojoTestCase {
     @Rule
@@ -212,4 +222,67 @@ public class SetMojoTest extends AbstractMojoTestCase {
                 String.join("", Files.readAllLines(tempDir.resolve("child/pom.xml"))),
                 containsString("<version>testing</version>"));
     }
+
+    @Test
+    public void testIssue1042() throws Exception {
+        TestUtils.copyDir(Paths.get("src/test/resources/org/codehaus/mojo/set/issue-1042"), tempDir);
+        SetMojo mojo = (SetMojo) mojoRule.lookupConfiguredMojo(tempDir.toFile(), "set");
+        mojo.execute();
+        assertThat(
+                String.join("", Files.readAllLines(tempDir.resolve("pom.xml"))),
+                matchesPattern(
+                        ".*\\Q<artifactId>child-reactor</artifactId>\\E\\s*" + "\\Q<version>1.0</version>\\E.*"));
+        assertThat(
+                String.join("", Files.readAllLines(tempDir.resolve("child-webapp/pom.xml"))),
+                matchesRegex(".*\\Q<artifactId>child-webapp</artifactId>\\E\\s*" + "\\Q<version>1.0</version>\\E.*"));
+    }
+
+    @Test
+    public void testComputeChildren() {
+        Map<Pair<String, String>, Set<Model>> children = SetMojo.computeChildren(new HashMap<File, Model>() {
+            {
+                put(new File("parent"), new Model() {
+                    {
+                        setArtifactId("parent");
+                        setParent(new Parent() {
+                            {
+                                setGroupId("default");
+                                setArtifactId("superParent");
+                            }
+                        });
+                    }
+                });
+                put(new File("child2"), new Model() {
+                    {
+                        setArtifactId("child2");
+                        setParent(new Parent() {
+                            {
+                                setGroupId("default");
+                                setArtifactId("superParent");
+                            }
+                        });
+                    }
+                });
+                put(new File("superParent"), new Model() {
+                    {
+                        setArtifactId("superParent");
+                    }
+                });
+                put(new File("child"), new Model() {
+                    {
+                        setArtifactId("child");
+                        setParent(new Parent() {
+                            {
+                                setGroupId("default");
+                                setArtifactId("parent");
+                            }
+                        });
+                    }
+                });
+            }
+        });
+        assertThat(children.get(new ImmutablePair<>("default", "superParent")), hasSize(2));
+        assertThat(children.get(new ImmutablePair<>("default", "parent")), hasSize(1));
+        assertThat(children.get(new ImmutablePair<>("default", "child")), is(nullValue()));
+    }
 }
diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-1042/child-webapp/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-1042/child-webapp/pom.xml
new file mode 100644
index 00000000..96f8596e
--- /dev/null
+++ b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-1042/child-webapp/pom.xml
@@ -0,0 +1,15 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>default</groupId>
+        <artifactId>package-parent</artifactId>
+        <version>1.0</version>
+        <relativePath>../main-reactor/package-parent/pom.xml</relativePath>
+    </parent>
+
+    <artifactId>child-webapp</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
+</project>
diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-1042/main-reactor/package-parent/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-1042/main-reactor/package-parent/pom.xml
new file mode 100644
index 00000000..7729033d
--- /dev/null
+++ b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-1042/main-reactor/package-parent/pom.xml
@@ -0,0 +1,15 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>default</groupId>
+        <artifactId>pom-parent</artifactId>
+        <version>1.0</version>
+        <relativePath>../pom-parent/pom.xml</relativePath>
+    </parent>
+
+    <artifactId>package-parent</artifactId>
+    <version>1.0</version>
+    <packaging>pom</packaging>
+</project>
diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-1042/main-reactor/pom-parent/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-1042/main-reactor/pom-parent/pom.xml
new file mode 100644
index 00000000..4c2ab887
--- /dev/null
+++ b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-1042/main-reactor/pom-parent/pom.xml
@@ -0,0 +1,8 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>default</groupId>
+    <artifactId>pom-parent</artifactId>
+    <version>1.0</version>
+    <packaging>pom</packaging>
+</project>
diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-1042/main-reactor/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-1042/main-reactor/pom.xml
new file mode 100644
index 00000000..9229da66
--- /dev/null
+++ b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-1042/main-reactor/pom.xml
@@ -0,0 +1,13 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>default</groupId>
+    <artifactId>main-reactor</artifactId>
+    <version>1.0</version>
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>pom-parent</module>
+        <module>package-parent</module>
+    </modules>
+</project>
diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-1042/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-1042/pom.xml
new file mode 100644
index 00000000..21efc2e5
--- /dev/null
+++ b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-1042/pom.xml
@@ -0,0 +1,35 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>default</groupId>
+        <artifactId>pom-parent</artifactId>
+        <version>1.0</version>
+        <relativePath>main-reactor/pom-parent/pom.xml</relativePath>
+    </parent>
+
+    <artifactId>child-reactor</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>child-webapp</module>
+    </modules>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>versions-maven-plugin</artifactId>
+                <goals>
+                    <goal>set</goal>
+                </goals>
+                <configuration>
+                    <newVersion>1.0</newVersion>
+                    <generateBackupPoms>false</generateBackupPoms>
+                    <processAllModules>true</processAllModules>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>