Jörg Hohwiller created MNG-8418: ----------------------------------- Summary: regression: maven 4: Duplicate key default Key: MNG-8418 URL: https://issues.apache.org/jira/browse/MNG-8418 Project: Maven Issue Type: Bug Affects Versions: 4.0.0-rc-1 Environment: Apache Maven 4.0.0-rc-1 (d81b1b6a2870dc954d6d642500ad38e8e4cb3dde) Maven home: D:\projects\myproject\software\mvn Java version: 17.0.13, vendor: Eclipse Adoptium, runtime: D:\projects\myproject\software\java Default locale: de_DE, platform encoding: UTF-8 OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows" Reporter: Jörg Hohwiller
I am testing migration of a complex project (600+ modules) to maven 4.0. While I am fully aware that maven 4.0.0-rc1 is not supposed to be production ready, I already want to do further testing to report blockers from real-life projects that could prevent a smooth upgrade from maven 3 (3.9.9) to maven 4 (once 4.0.0 official release is published). The build (invocation was {{{}mvn install -DskipTests -X{}}}) is working with maven 3 (tested with 3.8.6, 3.9.6 and 3.9.9) but it failes with maven 4 (also with latest 4.0.0-rc-1): {code:java} [ERROR] Failed to execute goal on project myproject.foundation.client: Could not collect dependencies for project com.customer:myproject.foundation.client:jar:4.25.2.0-SNAPSHOT [ERROR] java.lang.IllegalStateException: Duplicate key default (attempted merging values org.apache.maven.api.model.Activation@1556c428 and org.apache.maven.api.model.Activation@62ed65df) [ERROR] Caused by: Duplicate key default (attempted merging values org.apache.maven.api.model.Activation@1556c428 and org.apache.maven.api.model.Activation@62ed65df) [ERROR] java.lang.IllegalStateException: Duplicate key default (attempted merging values org.apache.maven.api.model.Activation@1556c428 and org.apache.maven.api.model.Activation@62ed65df) [ERROR] Caused by: Duplicate key default (attempted merging values org.apache.maven.api.model.Activation@1556c428 and org.apache.maven.api.model.Activation@62ed65df) [ERROR] : Failed to collect dependencies at com.customer.mylibrary:mylibrary-clientcomponents:jar:3.39.0.0 -> com.miglayout:miglayout:jar:3.7.2 [ERROR] -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project myproject.foundation.client: Could not collect dependencies for project com.customer:myproject.foundation.client:jar:4.25.2.0-SNAPSHOT java.lang.IllegalStateException: Duplicate key default (attempted merging values org.apache.maven.api.model.Activation@1556c428 and org.apache.maven.api.model.Activation@62ed65df) Caused by: Duplicate key default (attempted merging values org.apache.maven.api.model.Activation@1556c428 and org.apache.maven.api.model.Activation@62ed65df) java.lang.IllegalStateException: Duplicate key default (attempted merging values org.apache.maven.api.model.Activation@1556c428 and org.apache.maven.api.model.Activation@62ed65df) Caused by: Duplicate key default (attempted merging values org.apache.maven.api.model.Activation@1556c428 and org.apache.maven.api.model.Activation@62ed65df) at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:279) at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectArtifacts(LifecycleDependencyResolver.java:208) at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:128) at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:368) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:307) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:214) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:179) at org.apache.maven.lifecycle.internal.MojoExecutor$1.run(MojoExecutor.java:168) at org.apache.maven.buildcache.BuildCacheMojosExecutionStrategy.execute(BuildCacheMojosExecutionStrategy.java:145) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:165) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:107) at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder.lambda$createBuildCallable$1(MultiThreadedBuilder.java:191) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.lang.Thread.run(Thread.java:840) Caused by: org.apache.maven.project.DependencyResolutionException: Could not collect dependencies for project com.customer:myproject.foundation.client:jar:4.25.2.0-SNAPSHOT java.lang.IllegalStateException: Duplicate key default (attempted merging values org.apache.maven.api.model.Activation@1556c428 and org.apache.maven.api.model.Activation@62ed65df) Caused by: Duplicate key default (attempted merging values org.apache.maven.api.model.Activation@1556c428 and org.apache.maven.api.model.Activation@62ed65df) java.lang.IllegalStateException: Duplicate key default (attempted merging values org.apache.maven.api.model.Activation@1556c428 and org.apache.maven.api.model.Activation@62ed65df) Caused by: Duplicate key default (attempted merging values org.apache.maven.api.model.Activation@1556c428 and org.apache.maven.api.model.Activation@62ed65df) at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:163) at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:260) at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectArtifacts(LifecycleDependencyResolver.java:208) at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:128) at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:368) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:307) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:214) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:179) at org.apache.maven.lifecycle.internal.MojoExecutor$1.run(MojoExecutor.java:168) at org.apache.maven.buildcache.BuildCacheMojosExecutionStrategy.execute(BuildCacheMojosExecutionStrategy.java:145) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:165) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:107) at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder.lambda$createBuildCallable$1(MultiThreadedBuilder.java:191) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.lang.Thread.run(Thread.java:840) Caused by: org.eclipse.aether.collection.DependencyCollectionException: Failed to collect dependencies at com.customer.mylibrary:mylibrary-clientcomponents:jar:3.39.0.0 -> com.miglayout:miglayout:jar:3.7.2 at org.eclipse.aether.internal.impl.collect.DependencyCollectorDelegate.collectDependencies(DependencyCollectorDelegate.java:260) at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:79) at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies(DefaultRepositorySystem.java:241) at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:156) at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:260) at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectArtifacts(LifecycleDependencyResolver.java:208) at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:128) at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:368) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:307) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:214) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:179) at org.apache.maven.lifecycle.internal.MojoExecutor$1.run(MojoExecutor.java:168) at org.apache.maven.buildcache.BuildCacheMojosExecutionStrategy.execute(BuildCacheMojosExecutionStrategy.java:145) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:165) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:107) at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder.lambda$createBuildCallable$1(MultiThreadedBuilder.java:191) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.lang.Thread.run(Thread.java:840) Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Duplicate key default (attempted merging values org.apache.maven.api.model.Activation@1556c428 and org.apache.maven.api.model.Activation@62ed65df) at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:191) at org.eclipse.aether.internal.impl.collect.bf.BfDependencyCollector.processDependency(BfDependencyCollector.java:237) at org.eclipse.aether.internal.impl.collect.bf.BfDependencyCollector.doCollectDependencies(BfDependencyCollector.java:202) at org.eclipse.aether.internal.impl.collect.DependencyCollectorDelegate.collectDependencies(DependencyCollectorDelegate.java:222) at org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:79) at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies(DefaultRepositorySystem.java:241) at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:156) at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:260) at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectArtifacts(LifecycleDependencyResolver.java:208) at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:128) at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:368) at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:307) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:214) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:179) at org.apache.maven.lifecycle.internal.MojoExecutor$1.run(MojoExecutor.java:168) at org.apache.maven.buildcache.BuildCacheMojosExecutionStrategy.execute(BuildCacheMojosExecutionStrategy.java:145) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:165) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:107) at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder.lambda$createBuildCallable$1(MultiThreadedBuilder.java:191) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.lang.Thread.run(Thread.java:840) Caused by: java.lang.IllegalStateException: Duplicate key default (attempted merging values org.apache.maven.api.model.Activation@1556c428 and org.apache.maven.api.model.Activation@62ed65df) at java.util.stream.Collectors.duplicateKeyException(Collectors.java:135) at java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:182) at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169) at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) at java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:720) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) at org.apache.maven.internal.impl.model.DefaultModelBuilder.getProfileActivations(DefaultModelBuilder.java:1878) at org.apache.maven.internal.impl.model.DefaultModelBuilder$ModelBuilderSessionState.activateFileModel(DefaultModelBuilder.java:1135) at org.apache.maven.internal.impl.model.DefaultModelBuilder$ModelBuilderSessionState.readEffectiveModel(DefaultModelBuilder.java:1154) at org.apache.maven.internal.impl.model.DefaultModelBuilder$ModelBuilderSessionState.buildEffectiveModel(DefaultModelBuilder.java:807) at org.apache.maven.internal.impl.model.DefaultModelBuilder$ModelBuilderSessionImpl.build(DefaultModelBuilder.java:231) at org.apache.maven.internal.impl.resolver.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:207) at org.apache.maven.internal.impl.resolver.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:103) at org.eclipse.aether.internal.impl.collect.DependencyCollectorDelegate.resolveCachedArtifactDescriptor(DependencyCollectorDelegate.java:484) at org.eclipse.aether.internal.impl.collect.bf.BfDependencyCollector.resolveDescriptorForVersion(BfDependencyCollector.java:463) at org.eclipse.aether.internal.impl.collect.bf.BfDependencyCollector.lambda$resolveArtifactDescriptorAsync$1(BfDependencyCollector.java:437) at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) at org.eclipse.aether.internal.impl.collect.bf.BfDependencyCollector.lambda$resolveArtifactDescriptorAsync$4(BfDependencyCollector.java:436) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.lang.Thread.run(Thread.java:840) [ERROR] [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn [args] -r [DEBUG] Shutting down adapter factory; available factories [file-lock, rwlock-local, semaphore-local, noop]; available name mappers [discriminating, file-gav, file-hgav, file-static, gav, static] [DEBUG] Shutting down 'file-lock' factory [DEBUG] Shutting down 'rwlock-local' factory [DEBUG] Shutting down 'semaphore-local' factory [DEBUG] Shutting down 'noop' factory {code} I already checked the POM of {{{}mylibrary-clientcomponents:jar:3.39.0.0{}}}. There are 4 parent POMs involved from where the dependency to {{com.miglayout:miglayout:jar:3.7.2}} is defined but it is not duplicated anywhere. Since the error indicates activations that IMHO only exist in profiles I also checked all profiles with activations. All profiles share a unique ID. The activations in the mylibrary POMs are always: {code:java} <activation> <activeByDefault>false</activeByDefault> </activation> {code} In the {{myproject.foundation.client:jar:4.25.2.0-SNAPSHOT}} POM there is also a profile with a different ID that has this activation: {code:java} <profile> <id>macos</id> <activation> <os> <family>mac</family> </os> </activation> ... {code} First thing that comes to my mind would be to implement a helpful implementation of {{toString()}} for {{{}org.apache.maven.api.model.Activation{}}}. NOTE: This issue is not related to concurrency/threading (no {{-T}} option). The bug comes from here: [https://github.com/apache/maven/blob/d81b1b6a2870dc954d6d642500ad38e8e4cb3dde/impl/maven-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelBuilder.java#L1876-L1878] Since the code already changed on master for rc2 you can immediately close this issue, but I could not find a MNG bug issue for "Duplicate key default". -- This message was sent by Atlassian Jira (v8.20.10#820010)