Attach the maven assembly plugin to a build phase

Several month ago I decided to convert all the development project I manage to Maven. At least those that require a compilation phase. Flex projects are part of them. The problem is that for such projects, the build/compilation result in a myriad of files (.swf, .js, .html, assets) in the target folder. The Flex compilation suite (flex-mojos) only handle the .swf file. As a result, when releasing the project for a specific version, only this file is uploaded to the Maven repository.

As the point of using a versioned artifact repository is mainly to be able to revert to a previous version of the application, it's pretty useless in this case because the .swf is dependent of those companion files. It cannot work without them and they are modified as the project grow.

Thus, it's vital to package all those files together when I want to be able to revert at a certain point of time.

The elegant solution is provided by Maven with the assembly plugin. It allows you to describe which file you want to package, the format of the generated archive, etc. As fas as your assembly descriptor is fine, executing mvn assembly:assembly will build your project and package it.

mvn assembly:assembly did I said ? Huh?! This is not the standard way of building a Maven project. mvn install is. Luckily, you can "attach" the assembly stuff to an existing maven phase.

It seems that there was an old way to do this, now deprecated and throwing a warning, and a new one. They doesn't differ much but google mainly reference the first one.

As a reminder, here's the method for attaching the assembly plugin to an existing phase :

maven-assembly-plugin

single

package

src/assemble/distribution.xml

That post will serve as a reminder when comes the time to write a new pom.xml, not having an existing one around.

References :