2

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?

2 Answers2

1

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.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
0

The best practice is:

  1. Try to contact the project and ask them to release the library to Maven Central (e.g. using Ant Ivy)
  2. If this is not possible/ process is to slow, host the library in your Maven Repository Manager (such as Nexus) using some coordinates (groupId, artifactId, version) you choose and is unlikely to conflict with one published on Maven Central
Puce
  • 37,247
  • 13
  • 80
  • 152
  • This is exactly what we are aiming not to do as the overall aim of the work is to decouple the project from our local infrastructure such as nexus so it will be compilable without it. – user2774404 Jun 30 '20 at 13:25