Question

I have a pom file that builds a standalone application that leverages a variety of Spring modules, in particular it uses the integration-file module. Originally my pom file used the Maven Assembly plugin but the uber jar it created didn't run correctly. Further research seems to indicate that there is a bug in the assembly plugin that basically messes up the dependencies in the uber jar. The recommended workaround is the Shade plugin, which is working for me.

However, the assembly plugin is able to create a zip file that contains the uber jar and other resources (properties files, scripts, etc). You can then use that zip to unzip it and run your script which will call your jar and pass in the other items (as example). As far as I can tell the shade plugin does not do this additional feature.

I've tried combining the shade and assembly plugins using profiles but I can't figure out how to get it to use the shade plugin to build the uber jar and then afterwards, use the assembly plugin to build the zip with the other stuff.

Has anyone done anything similar? I just need to be able to create my uber jar and then zip up the uber jar with the scripts, xml and other items.

Is there a way to run the assembly plugin without binding it to a phase? If there were, I could run package and run the shade plugin and then afterwards run the assembly plugin independently? That would solve my issue if it were possible.

Was it helpful?

Solution 2

It is a common practice to use a separate module in a multimodule project just for assembling the zip. There's also the appassembler-maven-plugin which might be interesting for you (I've never used it myself, though).

About running a plugin without a phase: that's always possible. Execute the full name as specified on the goal-page. In this case org.apache.maven.plugins:maven-assembly-plugin:2.4:single, or in short assembly:single.

Don't try o solve this with profiles, they aren't meant for that.

OTHER TIPS

It's a bit late for this answer, but I have the same scenario as you ("package phase": 1. Build uber-jar with shade, 2. Pack it into assembly zip) and all I had to do is alter the order in which plugins are specified in pom.xml.

If shade is specified before assembly, it gets executed before, for the same phase.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top