如何强制maven安装在依赖项目上? [英] how to force maven install on dependent project?
问题描述
在项目B的pom.xml文件中,我已经声明了一个依赖关系:
<依赖关系>
< groupId>< / groupId>
< artifactId> A< / artifact>
< version> 1< / version>
< scope> compile< / scope>
< / dependency>
但是,每次对项目A进行任何更改,我必须在eclipse上运行maven install将项目安装到我的用户资料库。
如何在项目B构建并运行之前确保项目A已经建成并安装?
使用包装= pom的模块来控制整个构建。在另一个Eclipse项目中,称之为顶级,具有这个pom:
< project xmlns =http:// maven .apache.org / POM / 4.0.0
xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation =http:// maven .apache.org / POM / 4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">
< modelVersion> 4.0.0< / modelVersion>
< groupId>< / groupId>
< artifactId>顶层< / artifactId>
< version> 1< / version>
< packaging> pom< / packaging>
< modules>
< module> ../ A< / module>
< module> ../ B< / module>
< / modules>
< / project>
然后在这个pom上执行你的maven操作(清洁,安装等)。 Maven将找出处理模块的正确顺序。
一个警告词:Maven使用文件系统来访问A和B的相对pom位置。如果所有三个项目都在相同的根目录(Eclipse工作空间根,git repo根目录等)下,则可以工作。
I have project B which depends on project A.
On project B's pom.xml file, I have declared A dependency as:
<dependency>
<groupId></groupId>
<artifactId>A</artifact>
<version>1</version>
<scope>compile</scope>
</dependency>
But every time I make any changes on project A, I have to run maven install on eclipse, to install the project to my user's repository.
How can I make sure project A is built and installed before project B is built and ran?
Use a module with packaging=pom to control the entire build. In another Eclipse project, call it top-level, have this pom:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId></groupId>
<artifactId>top-level</artifactId>
<version>1</version>
<packaging>pom</packaging>
<modules>
<module>../A</module>
<module>../B</module>
</modules>
</project>
Then perform your maven operations (clean, install, etc.) on this pom. Maven will figure out the right order for processing the modules.
One word of warning: Maven uses the file system to access the relative pom locations for A and B. This only works if all three projects are under the same root directory (the Eclipse workspace root, the git repo root directory, etc.)
这篇关于如何强制maven安装在依赖项目上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!