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.
<settings xmlns='http://maven.apache.org/SETTINGS/1.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://maven.apache.org/SETTINGS/1.0.0http://maven.apache.org/xsd/settings-1.0.0.xsd'> <!--Maven http://maven.apache.org/settings.html --> <localRepository/> <interactiveMode/> <usePluginRegistry/> <offline/> <pluginGroups/> <servers> <server> <id>ACME-ARTIFACTORY-PRIVATE</id> <username>administrator</username> <password>password</password> </server> </servers> <mirrors> <mirror> <id>maven-central</id> <url>http://repo1.maven.org/maven2/</url> <mirrorOf>central,!eclipselink.repository</mirrorOf> </mirror> </mirrors> <proxies/> <profiles/> <activeProfiles/></settings>
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:
<distributionManagement> <repository> <id>ACME-ARTIFACTORY-PRIVATE</id> <name>acme-releases</name> <url>http://peabody.internal.acme.com/artifactory/ACME-ARTIFACTORY-PRIVATE</url> </repository> <snapshotRepository> <id>ACME-ARTIFACTORY-PRIVATE</id> <name>acme-snapshots</name> <url>http://peabody.internal.acme.com/artifactory/ACME-ARTIFACTORY-PRIVATE</url> </snapshotRepository> </distributionManagement>
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.
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:
cd glassfish-mainsvn updatemvn cleanmvn 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-mainmvn 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.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <executions> <execution> <id>attach-sources</id> <phase>package</phase> <goals> <goal>jar-no-fork</goal> </goals> </execution> </executions> </plugin>
Execute the following command line, to deploy the Java EE api artifacts
cd glassfish-main/appserver/javaeemvn 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:
repositories { maven { credentials { username 'administrator' password 'passowrd' } url 'http://peabody.internal.acme.com/artifactory/ACME-ARTIFACTORY-PRIVATE' } maven { url 'https://maven.java.net/content/groups/promoted' } maven { url 'http://repository.jboss.org/nexus/content/groups/public' }}dependencies { providedCompile 'org.glassfish.main.extras:glassfish-embedded-all:4.0-SNAPSHOT' providedCompile 'javax:javaee-api:7.0-bpeter-private' providedCompile 'javax:javaee-web-api:7.0-bpeter-private' compile 'org.glassfish.main.extras:glassfish-embedded-all:4.0-SNAPSHOT' compile 'javax:javaee-api:7.0-bpeter-private' testCompile 'junit:junit:4.10'}
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!
Reference: Build GlassFish 4.0 Snapshots Yourself from our JCG partner Peter Pilgrim at the Peter Pilgrim’s blog blog.
Source : feedproxy[dot]google[dot]com
No comments:
Post a Comment