问题
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?
回答1:
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.)
来源:https://stackoverflow.com/questions/23396169/how-to-force-maven-install-on-dependent-project