Maven – Integrating artifacts generated by an ant target into maven build

antmaven-2

I'm trying to build apache-solr webapp (not the whole project) using maven . Also want to reuse the build.xml ant file.

The directory structure is:

+build
+client
+contrib
.....
+src
 +webapp/src --webapp code
+dist --generated artifacts by the ant script
      --must be copied to the webapp WEB-INF/lib
      --some of them are also needed for webapp code compilation

I've successfully called the ant target that compiles and populates the dist dir.

What I need is to:

1) Include some of the jars that reside in the dist directory to compile the webapp code.

2) Package some of the jars in the war artifact maven builds.

Any help would be much appreciated

Best Answer

I think you could you use the maven ant tasks to install the jars in dist into a local repository. Then you could use those jars in the pom for your webapp.

You'd do something like:

<artifact:install file="dist/myjar-1.0.jar">
  <pom refid="myjar-pom"/>
</artifact:install>

where the myjar-pom defines how you would reference myjar inside your webapp's pom.

Then in your webapp pom declare the dependency:

<dependency>
  <groupId>myGroup</groupId>
  <artifactId>myjar</artifactId>
  <version>1.0</version>
</dependency>

Ideally, i think you'd want your webapp's pom to trigger your dependency ant builds for you so you just get a single step. For that you should be able to use maven-antrun-plugin.

I haven't tried these steps, but hopefully it will point you in the right direction.