Déjà Vu – Using the Maven Assembly Plugin correctly

If you want to create an archive (.zip, .tar.gz, etc.) file as part of a Maven 2 build you need to use the Assembly Plug-in. Furthermore, if you want to install it into your local repository or deploy it to a remote repository you will need the assistance of the Builder Helper Plug-in.

But if you are building a multi-module project you need to do it properly or you can severely mess up your build. I’ve just spent the last 2 weeks going round in circles trying to figure out why we couldn’t build our project from the root project. In the end it turned out to be the fact that I was incorrectly using the assembly goal instead of the singlegoal. This was causing Maven to fork and try to build all the project dependencies again. To us it looked like our dependencies were not getting installed into the local repository and it was going out to get the last good snapshot build of the components from our remote repository which were 2 weeks out of date by this time.

Of course. Once I found the solution a little light bulb went off and I remembered I’d already seen this problem before. About two years ago in fact.

Here is a sample POM snippet that assumes an assembly descriptor with an id of bin and a format of .tar.gz:

Leave a Reply

Your email address will not be published. Required fields are marked *