tags:

views:

51

answers:

1

Hi: I am having a project A being built with mvn assembly:assembly which gives me a jar file with dependencies. This project basically gets a file path and converts it to XML.

Now I need to create a new project B which will wrap A by walking a directory and calling several times to A. NOTE: They must be different applications. I am not able to modify A changing it's parameters.

I would like that when B builds, it will first build A and gets it's jar file.

Which is the best way to configure this in a pom file? Should I have two poms? Same pom but two jars being build?

Thanks for reading!

+4  A: 

I would handle this by adding an aggregator POM with A and B as modules. Then you simply build the aggregator each time to have A built before B. This gives you the flexibility to build A and B individually as well as both together.


If you are determined to invoke A's build from within B, it could be done by using the maven-exec-plugin to invoke another Maven instance.

For example:

<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>
Rich Seller