两个项目的Maven配置

Mac*_*rse 2 maven-2

我有一个项目,一个是与MVN装配内置:组件,它让我有依赖关系的JAR文件.该项目基本上获取文件路径并将其转换为XML.

现在我需要创建一个新项目将包裹一个步行的目录,并呼吁几次一个.注意:它们必须是不同的应用程序.我无法修改A更改它的参数.

我希望当B构建时,它将首先构建A并获取它的jar文件.

哪个是在pom文件中配置它的最佳方法?我应该有两个poms吗?同样的pom,但正在建造两个罐子?

谢谢阅读!

Ric*_*ler 5

我会通过添加聚合器POM和A和B作为模块来处理这个问题.然后,您只需构建聚合器,每次都在B之前构建A.这使您可以灵活地单独构建A和B以及两者一起构建.


如果您决定从B中调用A的构建,可以使用maven-exec-plugin来调用另一个Maven实例.

例如:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.1</version>
  <executions>
    <execution>
      <goals>
        <goal>exec</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <executable>mvn</executable>
    <!--specified as a property below-->
    <workingDirectory>${projectA.path}</workingDirectory>
    <arguments>
      <argument>clean</argument>
      <argument>install</argument>
    </arguments>
  </configuration>
</plugin>

...

<properties>
  <projectA.path>/path/to/project/a</projectA.path>
</properties>
Run Code Online (Sandbox Code Playgroud)