diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/builder/ReactorBuildStats.java b/daemon/src/main/java/org/mvndaemon/mvnd/builder/ReactorBuildStats.java index 53bab4f17..4c8e9d08d 100644 --- a/daemon/src/main/java/org/mvndaemon/mvnd/builder/ReactorBuildStats.java +++ b/daemon/src/main/java/org/mvndaemon/mvnd/builder/ReactorBuildStats.java @@ -56,14 +56,14 @@ private ReactorBuildStats(Map serviceTimes, this.bottleneckTimes = ImmutableMap.copyOf(bottleneckTimes); } - private static String projectGA(MavenProject project) { - return project.getGroupId() + ":" + project.getArtifactId(); + private static String projectGAV(MavenProject project) { + return project.getGroupId() + ":" + project.getArtifactId() + ":" + project.getVersion(); } public static ReactorBuildStats create(Collection projects) { ImmutableMap.Builder serviceTimes = ImmutableMap.builder(); ImmutableMap.Builder bottleneckTimes = ImmutableMap.builder(); - projects.stream().map(ReactorBuildStats::projectGA).forEach(key -> { + projects.stream().map(ReactorBuildStats::projectGAV).forEach(key -> { serviceTimes.put(key, new AtomicLong()); bottleneckTimes.put(key, new AtomicLong()); }); @@ -79,9 +79,9 @@ public void recordStop() { } public void recordServiceTime(MavenProject project, long durationNanos) { - AtomicLong serviceTime = serviceTimes.get(projectGA(project)); + AtomicLong serviceTime = serviceTimes.get(projectGAV(project)); if (serviceTime == null) { - throw new IllegalStateException("Unknown project " + projectGA(project) + ", found " + serviceTimes.keySet()); + throw new IllegalStateException("Unknown project " + projectGAV(project) + ", found " + serviceTimes.keySet()); } serviceTime.addAndGet(durationNanos); } @@ -90,7 +90,7 @@ public void recordBottlenecks(Set projects, int degreeOfConcurrenc long durationNanos) { // only projects that result in single-threaded builds if (projects.size() == 1) { - projects.forEach(p -> bottleneckTimes.get(projectGA(p)).addAndGet(durationNanos)); + projects.forEach(p -> bottleneckTimes.get(projectGAV(p)).addAndGet(durationNanos)); } } @@ -108,7 +108,7 @@ public long walltimeTime(TimeUnit unit) { } public String renderCriticalPath(DependencyGraph graph) { - return renderCriticalPath(graph, ReactorBuildStats::projectGA); + return renderCriticalPath(graph, ReactorBuildStats::projectGAV); } public String renderCriticalPath(DependencyGraph graph, Function toKey) { diff --git a/integration-tests/src/test/java/org/mvndaemon/mvnd/it/DupGATest.java b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/DupGATest.java new file mode 100644 index 000000000..48f629eff --- /dev/null +++ b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/DupGATest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mvndaemon.mvnd.it; + +import java.io.IOException; +import javax.inject.Inject; +import org.junit.jupiter.api.Test; +import org.mvndaemon.mvnd.assertj.TestClientOutput; +import org.mvndaemon.mvnd.client.Client; +import org.mvndaemon.mvnd.client.DaemonParameters; +import org.mvndaemon.mvnd.junit.MvndTest; + +@MvndTest(projectDir = "src/test/projects/dup-ga") +public class DupGATest { + + @Inject + Client client; + + @Inject + DaemonParameters parameters; + + @Test + void cleanInstall() throws IOException, InterruptedException { + final TestClientOutput output = new TestClientOutput(); + client.execute(output, "clean", "install", "-e").assertSuccess(); + } +} diff --git a/integration-tests/src/test/projects/dup-ga/.mvn/maven.config b/integration-tests/src/test/projects/dup-ga/.mvn/maven.config new file mode 100644 index 000000000..4230c2417 --- /dev/null +++ b/integration-tests/src/test/projects/dup-ga/.mvn/maven.config @@ -0,0 +1,3 @@ +-Dmaven.wagon.httpconnectionManager.ttlSeconds=120 +-Dmaven.wagon.http.retryHandler.requestSentEnabled=true +-Dmaven.wagon.http.retryHandler.count=10 diff --git a/integration-tests/src/test/projects/dup-ga/hi1/pom.xml b/integration-tests/src/test/projects/dup-ga/hi1/pom.xml new file mode 100644 index 000000000..5f95e99fa --- /dev/null +++ b/integration-tests/src/test/projects/dup-ga/hi1/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + + org.mvndaemon.mvnd.test.dup-ga + dup-ga + 0.0.1-SNAPSHOT + ../pom.xml + + + dup-ga-hi + 1.0-SNAPSHOT + + \ No newline at end of file diff --git a/integration-tests/src/test/projects/dup-ga/hi2/pom.xml b/integration-tests/src/test/projects/dup-ga/hi2/pom.xml new file mode 100644 index 000000000..98f89748c --- /dev/null +++ b/integration-tests/src/test/projects/dup-ga/hi2/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + + org.mvndaemon.mvnd.test.dup-ga + dup-ga + 0.0.1-SNAPSHOT + ../pom.xml + + + dup-ga-hi + 2.0-SNAPSHOT + + \ No newline at end of file diff --git a/integration-tests/src/test/projects/dup-ga/pom.xml b/integration-tests/src/test/projects/dup-ga/pom.xml new file mode 100644 index 000000000..f2583c3fa --- /dev/null +++ b/integration-tests/src/test/projects/dup-ga/pom.xml @@ -0,0 +1,76 @@ + + + + 4.0.0 + org.mvndaemon.mvnd.test.dup-ga + dup-ga + 0.0.1-SNAPSHOT + pom + + + UTF-8 + 1.8 + 1.8 + + 2.5 + 3.8.0 + 2.4 + 2.6 + 2.22.2 + + + + hi1 + hi2 + + + + + + + org.apache.maven.plugins + maven-clean-plugin + ${maven-clean-plugin.version} + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + + org.apache.maven.plugins + maven-install-plugin + ${maven-install-plugin.version} + + + org.apache.maven.plugins + maven-resources-plugin + ${maven-resources-plugin.version} + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + \ No newline at end of file