mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-28 00:22:03 +00:00
Fix error when the reactor contains duplicate groupId:artifactId, fixes #333
This commit is contained in:
@@ -56,14 +56,14 @@ class ReactorBuildStats {
|
|||||||
this.bottleneckTimes = ImmutableMap.copyOf(bottleneckTimes);
|
this.bottleneckTimes = ImmutableMap.copyOf(bottleneckTimes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String projectGA(MavenProject project) {
|
private static String projectGAV(MavenProject project) {
|
||||||
return project.getGroupId() + ":" + project.getArtifactId();
|
return project.getGroupId() + ":" + project.getArtifactId() + ":" + project.getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ReactorBuildStats create(Collection<MavenProject> projects) {
|
public static ReactorBuildStats create(Collection<MavenProject> projects) {
|
||||||
ImmutableMap.Builder<String, AtomicLong> serviceTimes = ImmutableMap.builder();
|
ImmutableMap.Builder<String, AtomicLong> serviceTimes = ImmutableMap.builder();
|
||||||
ImmutableMap.Builder<String, AtomicLong> bottleneckTimes = ImmutableMap.builder();
|
ImmutableMap.Builder<String, AtomicLong> bottleneckTimes = ImmutableMap.builder();
|
||||||
projects.stream().map(ReactorBuildStats::projectGA).forEach(key -> {
|
projects.stream().map(ReactorBuildStats::projectGAV).forEach(key -> {
|
||||||
serviceTimes.put(key, new AtomicLong());
|
serviceTimes.put(key, new AtomicLong());
|
||||||
bottleneckTimes.put(key, new AtomicLong());
|
bottleneckTimes.put(key, new AtomicLong());
|
||||||
});
|
});
|
||||||
@@ -79,9 +79,9 @@ class ReactorBuildStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void recordServiceTime(MavenProject project, long durationNanos) {
|
public void recordServiceTime(MavenProject project, long durationNanos) {
|
||||||
AtomicLong serviceTime = serviceTimes.get(projectGA(project));
|
AtomicLong serviceTime = serviceTimes.get(projectGAV(project));
|
||||||
if (serviceTime == null) {
|
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);
|
serviceTime.addAndGet(durationNanos);
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ class ReactorBuildStats {
|
|||||||
long durationNanos) {
|
long durationNanos) {
|
||||||
// only projects that result in single-threaded builds
|
// only projects that result in single-threaded builds
|
||||||
if (projects.size() == 1) {
|
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 @@ class ReactorBuildStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String renderCriticalPath(DependencyGraph<MavenProject> graph) {
|
public String renderCriticalPath(DependencyGraph<MavenProject> graph) {
|
||||||
return renderCriticalPath(graph, ReactorBuildStats::projectGA);
|
return renderCriticalPath(graph, ReactorBuildStats::projectGAV);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <K> String renderCriticalPath(DependencyGraph<K> graph, Function<K, String> toKey) {
|
public <K> String renderCriticalPath(DependencyGraph<K> graph, Function<K, String> toKey) {
|
||||||
|
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,3 @@
|
|||||||
|
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120
|
||||||
|
-Dmaven.wagon.http.retryHandler.requestSentEnabled=true
|
||||||
|
-Dmaven.wagon.http.retryHandler.count=10
|
31
integration-tests/src/test/projects/dup-ga/hi1/pom.xml
Normal file
31
integration-tests/src/test/projects/dup-ga/hi1/pom.xml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<!--
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
-->
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.mvndaemon.mvnd.test.dup-ga</groupId>
|
||||||
|
<artifactId>dup-ga</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>dup-ga-hi</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
</project>
|
31
integration-tests/src/test/projects/dup-ga/hi2/pom.xml
Normal file
31
integration-tests/src/test/projects/dup-ga/hi2/pom.xml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<!--
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
-->
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.mvndaemon.mvnd.test.dup-ga</groupId>
|
||||||
|
<artifactId>dup-ga</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>dup-ga-hi</artifactId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
</project>
|
76
integration-tests/src/test/projects/dup-ga/pom.xml
Normal file
76
integration-tests/src/test/projects/dup-ga/pom.xml
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
<!--
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
-->
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.mvndaemon.mvnd.test.dup-ga</groupId>
|
||||||
|
<artifactId>dup-ga</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
|
||||||
|
<maven-clean-plugin.version>2.5</maven-clean-plugin.version>
|
||||||
|
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
|
||||||
|
<maven-install-plugin.version>2.4</maven-install-plugin.version>
|
||||||
|
<maven-resources-plugin.version>2.6</maven-resources-plugin.version>
|
||||||
|
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>hi1</module>
|
||||||
|
<module>hi2</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
|
<version>${maven-clean-plugin.version}</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-install-plugin</artifactId>
|
||||||
|
<version>${maven-install-plugin.version}</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>${maven-resources-plugin.version}</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>${maven-surefire-plugin.version}</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
Reference in New Issue
Block a user