Search code examples
javamaven-2migrationreleaseself-contained

Creating a self-contained source release with Maven


Up until now we used Ant in my company. Whenever we wanted to send the application to the client we run a special Ant script that packaged all our source code with all jar libraries and Ant itself along with a simple batch file.

Then the client could put the files on a computer with no network access at all (and not even Ant) and run the batch file. As long as the computer had a valid JDK the batch script would compile all the code using the jars and create a WAR/EAR that would finally be deployed by the client on the application server.

Lately we migrated to Maven 2. But I haven't found a way to do the same thing. I have seen the Maven assembly plugin but this just creates source distributions or binary ones. Our scenario is actually a mix since it contains our source code but binary jars of the libraries we use (e.g. Spring, Hibernate)

So is it possible to create with Maven a self-contained assembly/release/package that one can run in a computer with no network access at all??? That means that all libraries should be contained inside.

Extra bonus if Maven itself is contained inside as well, but this is not a strict requirement. The final package should be easily compiled by just one command (easy for a system administrator to perform).

I was thinking of writing my own Maven plugin for this but I suspect that somebody has already encountered this.


Solution

  • You might try this approach:

    • Use mvn ant:ant to create ant build scripts from a maven project
    • Make sure ant is a project dependency
    • Use the assembly to build an ant
      system

    or plan b:

    • Use mvn ant:ant to create ant build scripts from a maven project
    • Make sure ant is a project dependency
    • Write a "bootstrap class" to call Ant and run the build
    • Use appassembler to build a scripted build and install environment

    In plan b, you'd write scripts to set up a source tree someplace from the packaged source jars, and then use the appassembler build bat or sh scripts to call the bootstrap and build via ant. Your bootstrap can do anything you need to do before or after the build.

    Hope this helps.