emmby
emmby

Reputation: 100464

Using maven to create two artifacts with overlapping classes

I have a maven pom that creates an artifact, let's call it everything.jar.

I would like to copy a subset of the classes in everything.jar into another jar, let's call it mini.jar.

What's the best way to structure my maven pom(s) to produce two jar files, one called mini.jar with just a few classes, and the other everything.jar with everything in mini plus some additional classes, without actually making copies of the source?

Upvotes: 1

Views: 783

Answers (1)

Sean Patrick Floyd
Sean Patrick Floyd

Reputation: 298818

I'd do it the other way around.

Create a multi - module project:

      root
    /  |   \
mini extra everything
  • mini contains the core stuff
  • extra has a dependency to mini and defines the additional classes
  • everything has a dependency to both and uses the maven-shade-plugin to create a combined jar from the two other projects (you can also do that from inside the extra project, but I'd call that less elegant)

Reference:

Upvotes: 1

Related Questions