This post is about building GlassFish 4.0 snapshots release yourself and includes hacks.

I found the official Instruction for FullBuild of GlassFish and then decided to build the server myself. Sometimes, you may not want to wait for the GlassFish build files to be promoted by the team. In this entry, I reference Artifactory as a private Maven repository, of course, you can use something else as well.

In the above Stanza, edit the definitions from ACME to the Artifactory server that you privately own, then copy it the following POM files:

main/pom.xml

main/appserver/javaee-api/pom.xml

main/appserver/pom.xml

main/nuclues/pom.xml

This is a nasty hack, because I don’t like that you can’t set change the deployment server and credentials from a configuration. Other source code allow configuration of the deployment server through Maven Profiles or even property files.

Make sure that your Maven settings are correct for Artifactory deployment and also we set up Maven build process. Set the environment variable MAVEN_OPTS so that there Maven has enough memory and the permanent generation is high enough to avoid out of memory exceptions during compilation.

If you have 16GB RAM workstation, why not just max it out for compiling the entire GlassFish? The Garbage Collection algorithm is changed to the concurrent mark and sweep algorithm and we also set the enabled class unloading enabled.

You are ready to compile, entering the following commands:

cd glassfish-main
svn update
mvn clean
mvn install -DskipTests=true

Make yourself a hot beverage and snack for about 20 minutes on a decent Intel Core i5/i7 machine (2012). Have a break. Notice that we avoid running the unit tests here, we skip the tests, because we just want a working release in repo, quickly, which is just not to say testing is bad.

After successful compilation of all of the modules, now you are ready to deploy to the private Maven repository. If you have followed the earlier instruction, about copying the stanza to the individual POM files, then you can execute this command from root.

cd glassfish-main
mvn deploy -DskipTests=true

After deploying the artifacts to Artifactory, check the repository for snapshot 4.0 release, they should all be there.

Now descend to the Java EE project folder. Hack the POM file, glassfish-main/appserver/javaee-api/javax.javaee-api/pom.xml. It is missing the maven source plugin in the build section, and therefore, by default, it does not generate the sources JAR, which is useful for seeing the new JavaEE 7 APIs!

Find the XPath project/build/plugins and append the following stanza to this POM.

Execute the following command line, to deploy the Java EE api artifacts

cd glassfish-main/appserver/javaee
mvn deploy -DskipTests=true

For some reason, the main execution does not install javax.javaee-api artifacts automatically. Executing this line generates JAR and SOURCES JAR for the three underlying modules: javax.javaee-api, javax.javaee-web-api and javax.javaee-endorsed-api.

Go Artifactory and see that the artifacts have all been deployed. You can then write a Gradle build file like this:

Especially, note that the build version are annotated as 7.0-bpeter-private.

The last piece of the puzzle, which I have not yet worked out is how to configure the build.id Maven property so that I can customize the build number. It is a mystery, still. If you happen to know the answer, please give me a bell. Cheers!