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.
Checkout the source code for GlassFish 4.0 yourself from Subversion:
svn checkout https://svn.java.net/svn/glassfish~svn/trunk/main glassfish-main
You need to hack the Maven Settings file for your workstation to exclude Eclipse artifacts.Here is an example of the
settings.xml, which I configured.
<!--Maven http://maven.apache.org/settings.html -->
Before we can compile the entire GlassFish code, we need to hack POM files so that they install artifacts into our private Artifactory server instead of the Maven Central.
Add the following Stanza to the POM files in the distribution:
In the above Stanza, edit the definitions from ACME to the Artifactory server that you privately own, then copy it the following POM files:
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.
MAVEN_OPTS=-Xmx1024m -Xms256m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled
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:
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.
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
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:
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
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!
PS: The EclipseLink uses it own Maven repository for artifacts: http://wiki.eclipse.org/EclipseLink/Maven