I’m working on a multimodule maven project. Some time ago, the project was partitioned into subprojects:
- “Common” JAR project
- “User” WAR project, depending on Common
- etc.
It’s the same project as described here, in this question.
When I invoke mvn package at superproject level, command succeeds and resulting war can be deployed. But if I try to invoke mvn package at subproject level, command fails.
[ERROR] Failed to execute goal on project User: Could not resolve
dependencies for project xxx.xxx:User:war:0.0.1-SNAPSHOT: Failed
to collect dependencies for [xxx.xxx:Common:jar:0.0.1-SNAPSHOT (compile), ...
Apparently maven is trying to download my own project (Common) from remote repo…
Downloading: http://repository.jboss.org/maven2/xxx/xxx/Common/0.0.1-SNAPSHOT/maven-metadata.xml
Downloading: http://download.java.net/maven/glassfish/xxx/xxx/Common/0.0.1-SNAPSHOT/maven-metadata.xml
[WARNING] Could not transfer metadata xxx.xxx:Common:0.0.1-SNAPSHOT/maven-metadata.xml from/to jboss (http:/
/repository.jboss.org/maven2): Access denied to: http://repository.jboss.org/maven2/xxx/xxx/common/0.0.1-SNA
PSHOT/maven-metadata.xml
What could possibly be wrong in my config?
When you run
mvn packagefromsuperproject, it creates the artifacts in the respectivetargetfolder, but does not install them in your local repository.So, when you run
mvn packageon asubproject, which has adependencyon a siblingmodule, it looks for thedependencyin your local repository, does not find it and thus attempts to download it from the various repositories configured.Once you successfully run an
mvn installfromsuperproject, anmvn packageon the subproject should work.