开发者

In maven multi-module project, how to package a single child-project?

I'm working on a multimodule maven project. Some time ago, the project was partitioned into subp开发者_StackOverflow中文版rojects:

  • "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 package from superproject, it creates the artifacts in the respective target folder, but does not install them in your local repository.

So, when you run mvn package on a subproject, which has a dependency on a sibling module, it looks for the dependency in your local repository, does not find it and thus attempts to download it from the various repositories configured.

Once you successfully run an mvn install from superproject, an mvn package on the subproject should work.


You have a (JBoss) repository entry either in your pom.xml or settings.xml. To access this repository it is required to be authenticated. If you call the path with your browser, you get also "403 Forbidden". You have to add a public repository of Jboss. (http://repository.jboss.org/)


I have spent a lot of time to find out this sort of 'ERROR', thanks to Raghuram, I was stupid when trying to find the solution but there was actually no error, just because I did mvn install in a submodule which depends on dependencies of other modules, It should work fine when i run mvn install/package on parent scope.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜