GlassFish V3 Developer Instruction
First, make sure your maven can find artifacts from the java.net maven2 repository.
This is done by making sure that your ~/.m2/settings.xml has a proper entry like this:
<settings>
...
<profiles>
<profile>
<id>v3</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>glassfish-repository</id>
<url>http://download.java.net/maven/glassfish</url>
</repository>
<repository>
<id>java.net</id>
<url>http://download.java.net/maven/1</url>
<layout>legacy</layout>
</repository>
</repositories>
</profile>
</profiles>
...
<!-- only if you are behind the proxy -->
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>proxy.somewhere.com</host>
<port>8080</port>
<username>proxyuser</username>
<password>somepassword</password>
<nonProxyHosts>www.google.com|*.somewhere.com</nonProxyHosts>
</proxy>
</proxies>
</settings>
Next, check out the part of the glassfish that you are interested in working on. For example,
if you are working on appserv-webtier, you'd do the following.
svn checkout https://svn.dev.java.net/svn/glassfish-svn/trunk/v3/web/appserv-webtier
You can then generate project files for your IDE by running the command like below. Due to the directory layout, this does not work for some of the modules. NetBeans and Intellij don't need such additional step as it can understand Maven natively by using a plugin
.
mvn -DdownloadSources=true eclipse:eclipse // for Eclipse
After you make your changes, you can build your module by running the following command.
mvn install
Once you are satisfied with your change, use svn to commit the changes.
Edit/Build/Debug Cycle
You'll be spending most of time going through edit/build/debug cycle, so making this step efficient is important for your productivity.
After you make changes, you can launch Glassfish with your local changes by running the following command:
mvn gf:run
This starts Glassfish with your module's target/classes and all the other pre-built binaries. The first time around it will take some time to download all those additional binaries, but from then on this should run fairly quickly.
To launch this Glassfish under the debugger, do as follows. You'll be running this often, so it's usually a good idea to make this a little shell script or an alias:
UNIX:
export MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5050
Windows:
setlocal
set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5050
mvn gf:run
endlocal
The same technique is also used if you need to tweak the VM launch parameter. See the plugin documentation
for more about gf:run goal and how to customize its behavior.
Once Maven starts under debugger, connect your IDE remotely to the port, and you can debug it all you like. Also, be sure to learn about hot swapping
, so that you can make simple changes from your IDE without restarting Glassfish.
Further Reading
Read more about
how GFv3 build/development works to get a better understanding why this works. Also, see this
jenblog
entry for more build tips.
Other Productivity Tips
- For building your module, Maven occasionally needs to hit the remote repository to check if any of your dependencies are updated. You can avoid this by running mvn with the -o option. This often reduces the build time.
- Contrarily, if you want to force Maven to check updates to all your dependencies, run mvn with -U -up. This is often necessary when a change in your code depends on another change another developer made in another module.
- Sun employees can use the internal maven repository mirrors
for faster repository access.
TODO
- Automate deployment via Hudson.
This page (revision-26) was last changed on
27-Jun-08 13:05 PM, -0700
by Administrator.
This page was created on
16-Mar-07 12:11 PM, -0700 by Kohsuke Kawaguchi.
Back to V3DevelopmentInstructions