Reputation: 14449
I have multi module maven project.When I try to build site, e.g. execute maven site
on parent project it fails to resolve dependency to one of modules.
But if I just compile (mvn clean compile
on parent project) it or run tests (mvn clean test
on parent project) there are no dependency problems.
What could cause such behaviour?
UPD
Maven version
Apache Maven 3.0.2 (r1056850; 2011-01-09 02:58:10+0200)
Java version: 1.6.0_26, vendor: Sun Microsystems Inc.
Java home: c:\Program Files\Java\jdk1.6.0_26\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
maven-site-plugin version
[DEBUG] Included: org.apache.maven.plugins:maven-site-plugin:jar:2.0.1
Error message
[ERROR] Failed to execute goal on project myproj-client: Could not resolve dependencies for project mycompany.myproj:myproj-client:jar:0.0.1-SNAPSHOT: Could not find artifact mycompany.myproj:myproj-common:jar:0.0.1-SNAPSHOT -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project myproj-client: Could not resolve dependencies for project mycompany.myproj:myproj-client:jar:0.0.1-SNAPSHOT: Could not find artifact mycompany.myproj:myproj-common:jar:0.0.1-SNAPSHOT
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:190)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:104)
at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:258)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:201)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
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)
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project mycompany.myproj:myproj-client:jar:0.0.1-SNAPSHOT: Could not find artifact mycompany.myproj:myproj-common:jar:0.0.1-SNAPSHOT
at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:156)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:165)
... 22 more
Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Could not find artifact mycompany.myproj:myproj-common:jar:0.0.1-SNAPSHOT
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:526)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveArtifacts(DefaultRepositorySystem.java:304)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:334)
at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:150)
... 23 more
Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could not find artifact mycompany.myproj:myproj-common:jar:0.0.1-SNAPSHOT
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:517)
... 26 more
[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 <goals> -rf :myproj-client
Upvotes: 16
Views: 86291
Reputation: 45
i was facing the same but for struts and paypal_base dependecies, i fixed by doing following.
I have installed that jar files via following mvn command
mvn install:install-file -Dfile=C:\Dependencies\paypal_base.jar \ -DgroupId=paypal -DartifactId=paypal_base -Dversion=0.1 \ -Dpackaging=jar
and
mvn install:install-file -Dfile=C:\Dependencies\struts.jar \
-DgroupId=struts -DartifactId=struts -Dversion=0.1 \
-Dpackaging=jar
(-DFile is the location of jar file in you system)
you must check the jar, and use above instruction is jar not exist. may be this will helpful.
Upvotes: 5
Reputation: 139
I have the same problem. I didn't dig into Maven's source code too much. But here is my observation.
Supposed that you never mvn install
myproj-common in your local repository, neither deployed it onto any remote repositories. When you run mvn clean site
on the parent project, things happen like this:
mvn clean site
is run on myproj-common. All previous result in myproj-common/target are deleted and myproj-common/target/site is
generated. (Note that after this step, neither compiled classes nor packaged jar exists in myproj-common/target)mvn clean site
is run on myproj-client. Maven first checks the
dependency of this project, and tries to find myproj-common's
artifact (classes or jar) in these places: (a) myproj-common/target (b) local repository (3) remote repositories. mvn site
fails on myproj-client, since it cannot find the artifact of myproj-commonThis explains why mvn clean compile site
and mvn clean package site
works. They both would have prepared myproj-common artifacts in its target directory before mvn site
runs on myproj-client.
And mvn install
followed by mvn site
works also.
A special exception is that if you put something like emma-maven-plugin in reporting, it will automatically compile and instrument classes. In this case, mvn clean site
always works.
I am not sure why Maven tries to find myproj-common's jar in step 3, it seems to have nothing to do with mvn site
. The exception happens quite early in maven core, before getting into maven-site-plugin. It looks not like a problem of maven-site-plugin but a common behavior of all maven lifecycles (except clean I believe).
Upvotes: 13
Reputation: 14449
Heh, for some reason, after I made some changes to module and parent pom files, problem vanished. I don't know exactly what was done, but currently mvn site
on parent project is working normally. Unfortunately I have no time to investigate what is the roots of the problem. But it seems that changing site version to 3.0 put me on the right way. Also I could execute site (before it was fixed) in the following way mvn compile site
, in this case it could find dependency.
Upvotes: 1
Reputation: 23562
This might be an issue with the site plugin not having access to the reactor, and thus not seeing that the project artifact is available in your project sources. (This is merely a hypothesis, perhaps supported by MSITE-302.)
Try running first mvn install
, which installs your artifacts in the local repository, and then running mvn site
.
For more information on the reactor, try:
Upvotes: 3
Reputation: 131
It looks like maven is looking for myproj-common:jar:0.0.1-SNAPSHOT in the repository.
The reason for failure could be: maven is not able to access the snapshot artifacts in the repository.
To enable snapshot artifacts:
please check you pom.xml for snapshots tag under the repository section.
<repository>
<name>xyz</name>
<id>repoid</id>
<url>http://x.y.z</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
Upvotes: -1