Building Hudson

Building Hudson requires JDK1.6.x and Maven 2.x.

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 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.

For those that do not have Subversion installed, but still want to check out 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, try Soylatte or Apple has a developer preview of Java6 you can download from the Developer Connection)
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.
you maybe don't 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

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 users should consider using this NetBeans module for working with Hudson.

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.

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: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.

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".

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

  Edit Labels
(None)
  1. about 7 hours ago

    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?