如何在Maven中编译依赖关系? [英] How to compile dependency in maven?

查看:798
本文介绍了如何在Maven中编译依赖关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景:

我有一个主项目A,在A内有两个子项目B和C,它们由不同的开发人员进行开发,但是他们通过公共接口就抽象达成了共识.

I have a main level project A and within A , two child projects B and C worked on by different developers , but they agree on the abstraction through common interfaces.

B取决于C(依赖关系). 在B的pom中,我添加了

B depends on C (dependency). In B's pom I added

<dependency> .. details of project C..</dependency> .

这样做,除了不重新编译项目C之外,maven会很好地插入依赖项.

Doing this, maven inserts the dependencies fine except that project C is not recompiled.

我希望项目C在每次编译B时自动重新编译.

I want project C to automatically re-compile every time I compile B.

推荐答案

如果要构建B并自动构建它的依赖项,则可以使用Maven反应器的高级选项,例如–-also-make-dependents.

If you want to build B and automatically build it's dependencies you can use the advanced options of the maven reactor like –-also-make-dependents .

mvn clean install –-projects B –-also-make 

mvn clean install -pl B -am

这将编译B依赖的A的所有子模块. 在sonatype博客上有一篇有关maven反应器高级选项的有用文章. http://www.sonatype .com/people/2009/10/maven-tips-tricks-advanced-reactor-options/

That will compile all submodules of A whose B depends on . There are a useful post on sonatype blog on the advanced options of maven reactor. http://www.sonatype.com/people/2009/10/maven-tips-and-tricks-advanced-reactor-options/

这篇关于如何在Maven中编译依赖关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆