javamavenjarantmaven-jar-plugin

How to package an Ant project with Maven?


In the project I'm working on, there's a extenal dependency that's not avaliable on the public Maven artifact index, but there's a public repository with the project code. The project is natively built using ant.

What we are planning to do is to automatically download the dependency code, provide it with a POM file, then build it as a part of our big project, which is Maven based.

So far I've managed to create a POM file that compiles the dependency using maven-ant-plugin but I've been unable to install the project into a local Maven repository, mvn install skips the jar and classes compiled using ant and just installs an empty dummy jar.

Googling so far gave no results, everybody suggests to rearrange the code to fit the default maven directory structure and just build it using maven, but this would make updating the dependency from upstream impossible, because then I would have to rearrange the files again when the new upstream version is released.

The goal is to have a POM file that I can put into the root of the ant project, update the version number, and do mvn install and have the compiled jar avaliable in the local maven repository.

How do I make maven recognize the ant-compiled jar or the ant-compiled classes?


Solution

  • I suggest you use the install:install-file goal.

    It allows you to explicitly state which jar and which POM should be installed.

    I once did it in the very same way: Added a POM that first builds everything through Ant and then calls the install-file goal for the generated artifact.