lbear
lbear

Reputation: 820

Is there the equivalent of “<ant antfile=xxx/>” in maven pom.xml?

I have two project which used to be built by ant. I called them P1 and P2, P1 is a java project and P2 is a web project. P2 will include P1 as a jar file. In the past, when I build P2, I can add <ant antfile="${common}/../build.xml" inheritAll="false"></ant> into build.xml to make P1 to a jar file first, and then copy the jar to P2's lib folder.

Now I will convert both of them to Maven project. I don't know how to imply the process above. I know there are some ways to run ant in maven process. But now P1 is a maven project, too. How can I deal with this problem? I want to make a P1.jar before package P2, and I really don't think it is necessary to deploy or install P1.jar to maven repo first. Is there any convenient way?

Upvotes: 0

Views: 722

Answers (1)

David W.
David W.

Reputation: 107090

Why are you converting an Ant project to Maven? Is there some issue that you're trying to resolve with the build? Or, do you think Maven is better, and thus you need to rewrite everything in Maven? Don't touch stuff that works. There's enough broken stuff you can manage.

In Maven, you could make these two independent projects:

  • P1 would build the jar and deploy this jar into your local Maven repository.
  • When P2 builds, it would fetch that pre-built P1 jar from your Maven repository.

You can use Jfrog's Artifactory or Sonatype's Maven as your local Maven repo.

You could also structure the two projects as subprojects. In this scenario, P1 and P2 would be two sub projects, and you'd have a P3 with pretty much nothing but a pom.xml that would build both projects.

Upvotes: 1

Related Questions