Building Hudson

Building Hudson requires JDK1.6.x and Maven 2.x (If using a 2.0.x release, then 2.0.6 or greater is required) .

Issues:

To build Hudson so that you can make modifications, follow the steps below:

// check out the workspace
$ svn co https://svn.dev.java.net/svn/hudson/trunk/hudson
$ svn co https://svn.dev.java.net/svn/hudson/trunk/www
$ cd hudson
// use maven2 for build
$ mvn install

If you just want to build the core without all the plugins, do:

 $ cd hudson/main
 $ mvn install

If it asks for username/password, you can either use your java.net ID, or simply specify "guest" as the user name and empty password.
The trunk/hudson directory is where the Hudson product itself is located -- all the source, etc.   The trunk/www directory is information for the Hudson website and contains changelog.html, which you should update if/when you become a committer.

To check out the hudson sources, first install Subversion. When 'svn' is available on the path Maven can be used to get the Hudson sources. This is the maven command to run:
mvn scm:checkout -DconnectionUrl=scm:svn:https://svn.dev.java.net/svn/hudson/trunk/hudson -DcheckoutDirectory=hudson
mvn scm:checkout -DconnectionUrl=scm:svn:https://svn.dev.java.net/svn/hudson/trunk/www -DcheckoutDirectory=www
This command will create a subdirectory 'hudson' from the directory where you run the command.

The first build will take a while, because it has to download million jars from all over the world. You'll also need to have Java6 to build Hudson (even though Hudson will run on Java5. Mac users, Java 6 is only available for Core 2 Duo machines - see http://landonf.bikemonkey.org/2009/05/17#OpenJDK6_MacPorts.20090516 for a beta of OpenJDK for 10.4 and 10.5)
If it succeeds with BUILD SUCCESSFUL at the end, you are good to go.

If the build failed with the following messages:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
It may be that you are not using Java6.

At the end you should have hudson/main/war/target/hudson.war, which is the hudson you just built.

If you are building behind a http proxy, you will need to use Maven 2.0.5 or newer as there is a well known bug fetching artifacts from a https:// repository via a http proxy with Maven 2.0.4.
Currently, Due to a bug in javac, the build may fail with the following error. If you hit this, try rebuilding it without doing 'clean'.
The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2964)
at com.sun.tools.javac.code.Types.adapt(Types.java:2995)
at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2956)
.......
.........
INFO ------------------------------------------------------------------------
ERROR BUILD ERROR
INFO ------------------------------------------------------------------------
INFO Fatal error compiling

It has been reported that setting MAVEN_OPTS to include "-Xmx177M" before invoking NetBeans allows Hudson to build.  For OS X this can be done in Terminal.app with

export MAVEN_OPTS="-Xmx177M"
open /Applications/NetBeans/NetBeans\ 6.7.app 
 

If on "mvn clean" you get this error

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) org.jvnet.hudson.plugins.hudsontrayapp:client:jar:0.7.3-SNAPSHOT

  Try downloading the file manually from the project website.

you can work around this by doing a mvn install in plugins/hudsontrayapp


Configure work environment

To work on the Hudson code productively, you should generate your IDE project files (note: these commands run maven offline (i.e. -o), which is faster but might not work correctly if you have not just run a "mvn install"):

// if you are using IntelliJ
$ mvn -DdownloadSources=true idea:idea
// if you are using Eclipse
$ mvn -DdownloadSources=true eclipse:eclipse

NetBeans (6.7+) users can just open the module directly,  with File -> Open Project and navigate to the hudson folder. 

There is a step-by-step guide to working with Eclipse once you've run the above commands. Due to a bug in Eclipse, Eclipse users may need to remove src/main/resources from the source folder list after projects are imported to the workspace. See this e-mail thread for more details.

If your IDE complains that 'Messages' class is not found, they are missing because they are supposed to be generated. Run a Maven build once and you should see them all. If that doesn't fix the problem, make sure your IDE added target/generated-sources to the compile source roots.

Debugging Hudson

Maven Jetty plugin offers a convenient debugging environment, but for a few reasons we maintain a modified version of the plugin under a different name, so the plugin name is different but the configuration parameters are the same. Do the following to run Hudson under the debugger, and open http://localhost:8080/ in your browser:

$ cd main/war
$ export MAVEN_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n"
$ mvn hudson-dev:run

This will launch maven with the debugger port for 8000. You can connect to this port from your IDE by using the remote debug feature. Once this starts running, keep it running. Jetty will pick up all the changes automatically.

  1. When you make changes to view files in core/src/main/resources, just hit F5 in your browser to see the changes.
  2. When you make changes to static resources in war/resources, just hit F5 in your browser to see the changes.
  3. When you change Java source files. Compile them in your IDE and Jetty should pick that up. You don't need to run mvn at all for this.
  4. NetBeans users can just hit Debug with main/war open.

Other Tips

  1. Consider running Maven like mvn -o ... to avoid hitting repositories every time. This will make various operations considerably faster.
  2. When Maven complains about something, try "cd $HUDSON/main; mvn clean install".
  3. If you don't want to waste time running tests, run Maven with "-Dmaven.test.skip=true" to skip tests.

Credits

The sponsor statement from YourKit Java Profiler, which gave us a free license for the Hudson project.

Open-source license for YourKit Java Profiler
YourKit is kindly supporting open source projects with its full-featured Java Profiler. YourKit, LLC is creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look at YourKit's leading software products: YourKit Java Profiler and YourKit ASP.NET Profiler


Labels:

Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.
  1. Jul 08, 2008

    Karl Palsson says:

    Under debugging hudson, have you got any advice on how to debug plugins?

    Under debugging hudson, have you got any advice on how to debug plugins?

    1. Aug 26, 2008

      Kohsuke Kawaguchi says:

      See Plugin tutorial for how to develop and debug plugins.

      See Plugin tutorial for how to develop and debug plugins.

  2. Nov 18, 2008

    Philippe Martel says:

    [content removed by the poster]

    [content removed by the poster]

  3. Nov 26, 2008

    yongjun says:

    I have a question about the IDE eclipse. I followed the build steps and download...

    I have a question about the IDE eclipse. I followed the build steps and downloaded hudson source codes. If I use eclipse3.2, build always failed. The common error is 'some type is collides with a package". Then I change to eclipse3.4, there are still some compile errors but I can deal with them finally.

    So Kohsuke, may you suggest which IDE we can use for hudson development? 

    BTW, I am in solaris 10, x86. The top support Eclipse version is 3.2.

    Thank you very much.

  4. Jun 09

    Pete says:

    Recently I have had issues with building.  If I do this before hand, it wor...

    Recently I have had issues with building.  If I do this before hand, it works fine. 

    # 177 used below is the minimum, using 256M would allow for future needs.
    
    MAVEN_OPTS="-Xmx177M"
    mvn -Dmaven.test.skip=true install  
    
  5. Sep 01

    Eric Badiere says:

    This is my first attempt at building hudson and I am getting the following when ...

    This is my first attempt at building hudson and I am getting the following when I run 'mvn -o install' :

     [INFO] ------------------------------------------------------------------------
    [ERROR] BUILD ERROR
    [INFO] ------------------------------------------------------------------------
    [INFO] Internal error in the plugin manager executing goal 'org.jvnet.hudson.tools:maven-hpi-plugin:1.31:apt-compile': Unable to find the mojo 'org.jvnet.hudson.tools:maven-hpi-plugin:1.31:apt-compile' in the plugin 'org.jvnet.hudson.tools:maven-hpi-plugin

    Any help wold be appreciated.

  6. Oct 14

    Clifton Craig says:

    I get a compile error when building from source: [INFO] [stapler:apt-compile] ...

    I get a compile error when building from source:

    [INFO] [stapler:apt-compile]

    [INFO] Compiling 561 source files to /Users/cliftoncraig07/java-apps/Hudson-src/hudson/main/core/target/classes

    [INFO] ------------------------------------------------------------------------

    [ERROR] BUILD ERROR

    [INFO] ------------------------------------------------------------------------

    [INFO] Fatal error compiling

    Embedded error: Error while executing the external compiler.

    error=2, No such file or directory

    [INFO] ------------------------------------------------------------------------

    [INFO] For more information, run Maven with the -e switch

    [INFO] ------------------------------------------------------------------------

    [INFO] Total time: 1 minute 31 seconds

    [INFO] Finished at: Wed Oct 14 19:07:23 EDT 2009

    [INFO] Final Memory: 65M/81M

    [INFO] ------------------------------------------------------------------------

    cliffmac:main cliftoncraig07$ javac -version

    javac 1.6.0_13