Details

Description

While preparing our projects to be migrated from Maven 2 (currently using 2.2.1) to Maven 3 (3.0-alpha-5) I faced a problem concerning transitive dependencies. I had the following setup:

3 projects:

a parent project (PARENT)

Project A (parent = PARENT with lots of 3rd party libs as dependencies)

Project B (parent = PARENT and declares Project A to be a dependency)

I tried to build Project B using Maven 3 but the build failed, because Project A's transitive dependencies were not resolved. When trying to build the same project using Maven 2 it successfully picked up the transitive dependencies. After a bit of searching I activated the error stacktraces and saw the following exception when running the project's build with Maven 3:

[DEBUG] Unable to find resource 'PARENT:pom:0.4-SNAPSHOT' in repository internal-snapshots (https://foo.bar/maven/internal-snapshots)
org.apache.maven.wagon.ResourceDoesNotExistException: Failure to resolve PARENT/0.1-SNAPSHOT/PARENT-0.4-SNAPSHOT.pom from https://foo.bar/maven/internal-snapshots was cached in the local repository. Resolution will not be reattempted until the update interval of internal-snapshots has elapsed or updates are forced.
at org.apache.maven.repository.legacy.DefaultWagonManager.getArtifact(DefaultWagonManager.java:114)
at org.apache.maven.repository.legacy.DefaultWagonManager.getArtifact(DefaultWagonManager.java:131)
at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:215)
at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:461)
at org.apache.maven.repository.legacy.LegacyRepositorySystem.resolve(LegacyRepositorySystem.java:325)
at org.apache.maven.project.RepositoryModelResolver.resolveModel(RepositoryModelResolver.java:171)
at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally(DefaultModelBuilder.java:567)
at org.apache.maven.model.building.DefaultModelBuilder.readParent(DefaultModelBuilder.java:434)
at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:179)
at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:117)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:112)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:232)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:191)
at org.apache.maven.project.artifact.MavenMetadataSource.retrieveRelocatedProject(MavenMetadataSource.java:571)
at org.apache.maven.project.artifact.MavenMetadataSource.retrieve(MavenMetadataSource.java:184)
at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.recurse(DefaultLegacyArtifactCollector.java:533)
at org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector.collect(DefaultLegacyArtifactCollector.java:150)
at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:541)
at org.apache.maven.repository.legacy.LegacyRepositorySystem.resolve(LegacyRepositorySystem.java:325)
at org.apache.maven.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:152)
at org.apache.maven.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:66)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.resolveProjectDependencies(DefaultLifecycleExecutor.java:378)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:245)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:102)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:423)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:158)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:123)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)[WARNING] Invalid artifact metadata for projectA:jar:0.4.0: 1 problem was encountered while building the effective model for projectA:0.4.0[FATAL] Non-resolvable parent POM PARENT:0.1-SNAPSHOT for projectA:0.4.0: Failed to resolve POM for PARENT:0.1-SNAPSHOT due to Missing:
...

The error message was of course correct, since the PARENT project wasn't properly installed in my local repo, and I will now attempt to fix that, but Maven 3 should not have swallowed this stacktrace, because it was totally unclear why transitive dependencies were not resolved (while Project A itself ended up on the classpath of Project B)

This is the warning telling you about the problem and this warning is always present in the log, even without debug enabled. So the problem is not silently ignored. The improved message will now clearly say that this effects transitive dependencies and that debug logging can be used to see all the details.

The stack trace is deliberately not shown unless debug is enabled as there are still a bunch of broken POMs out in the wild that users depend on and throwing the stack trace at them when they have no chance to fix or disable it is annoying.

Benjamin Bentmann
added a comment - 01/Dec/09 09:51 Improved log output in r885804 .
[WARNING] Invalid artifact metadata for projectA:jar:0.4.0
This is the warning telling you about the problem and this warning is always present in the log, even without debug enabled. So the problem is not silently ignored. The improved message will now clearly say that this effects transitive dependencies and that debug logging can be used to see all the details.
The stack trace is deliberately not shown unless debug is enabled as there are still a bunch of broken POMs out in the wild that users depend on and throwing the stack trace at them when they have no chance to fix or disable it is annoying.