Expie
Expie

Reputation: 47

How to make maven use separate target folders for every version of program?

As example, i have program with version 0.0.1. Maven must create separate folder for it - "target/0.0.1/" instead of "target/". It must be done for version "0.0.2", "0.0.3", etc.

I use Eclipse & it's Maven: Version: Oxygen.3a Release (4.7.3a) Build id: 20180405-1200

JDK 1.8.0_172

Upvotes: 1

Views: 333

Answers (1)

Sean Patrick Floyd
Sean Patrick Floyd

Reputation: 298818

Maven doesn't work that way, and trying to do something like that will lead to a path of suffering. Options I see include

  • Creating a separate assembly (and output Jar) for each version (see Maven Assembly Plugin)
  • Create a multi-project reactor with a separate output configuration for every project. Keep common code in one project that you link as dependency from the others. Possibly use the maven-shade-plugin to re-link the packages in your common project into the individual output projects

As you can see, both of these approaches are pretty hacky and require advanced Maven skills. It would be much easier to have parameterized builds where you pass in the output version. But that would make sense on a CI server like Jenkins.

Upvotes: 4

Related Questions