Search code examples
mavenmaven-assembly-plugin

How to build two different jar packages with maven-assembly-plugin?


My project consists of three maven packages and application class (in default package). The existing configuration (defined in pom.xml) uses maven-assembly-plugin to create single executable jar-with-dependencies. I'd like to add an execution *descriptorRef* \ whatever to create a distributalbe jar package that will contain only classes from two packages out of three (one is a mock-up). Is it possible?

If I define an configuration can I make it relate to one but not the other?


Solution

  • I have absolutely done this. You can configure multiple executions of the Maven Jar Plugin in the package phase and specify different includes / excludes for each execution.

    See Maven Jar Plugin documentation, particularly the section entitled: "How to create an additional attached jar artifact from the project."

    If you must use the Assembly plugin, you should just create a new assembly descriptor using the jar-with-dependencies as a template, but adding the inclusions / exclusions to your liking.