[RSS]
So you want to tinker with the code, build the whole IDE from sources, implement features yourself? This is the minimum to get you started.

Tools

You need the following to be installed on your machine

  • JDK 5 (latest version as of writing is 1.5.0_16): it must be 1.5.0 because NetBeans must be runnable on this version of JDK or newer. By using 1.5.0 you will ensure that you don't use APIs and features available only in JDK 6 or newer.
  • Apache Ant 1.7.1
  • Mercurial 1.0.2 (for NB 6.1 or later), presupposing Python 2.5.1 or later
  • CVS client (for NB 6.0 or earlier)

The whole source tree has NetBeans project metadata so you can just use NetBeans to develop NetBeans.

Mercurial access (NB 6.1 or later only)

hg clone http://hg.netbeans.org/main/

If you want a repository which is guaranteed to always build you can get the main-golden repository:

hg clone http://hg.netbeans.org/main-golden/

NOTE: If you find that building after checkout fails while external binaries are being fetched and your Internet access requires a proxy server, you can work around this by adding a setproxy task to the bootstrap task in nbbuild/build.xml, as shown below:

  <target name="bootstrap"
          description="Bootstrap NetBeans-specific Ant extensions."
          depends="-jdk-init,assure-ant,-load-build-properties">
    <fail message="You need JDK 1.5 to build NetBeans">
        <condition>
            <not>
                <isset property="have-jdk-1.5"/>
            </not>
        </condition>
    </fail>
    
    <!-- add this line -->
    <setproxy proxyhost="myproxy.company.com" proxyport="8999"/>

    <mkdir dir="build/antclasses"/>
    <javac srcdir="antsrc" destdir="build/antclasses" deprecation="true" debug="${build.compiler.debug}" source="1.5" target="1.5">
        <classpath>
...
    <downloadbinaries cache="${binaries.cache}" server="${binaries.server}">
...

CVS access (NB 6.0 or earlier only)

Use this CVSROOT (e.g. for -d option): :pserver:<username>@cvs.netbeans.org:/cvs (Replace <username> with your netbeans.org account name.)

export CVSROOT=:pserver:<username>@cvs.netbeans.org:/cvs

Anonymous access is possible with username anoncvs and an empty password.

export CVSROOT=:pserver:anoncvs@cvs.netbeans.org:/cvs

It is also important to always run cvs checkout with -P and cvs update with -Pd flags. If you don't do this your build will fail. Check your CVS documentation for the meanings of those flags. You may wish to create a .cvsrc file so you do not have to remember these flags for every command. For example:

cvs -z3 -q
update -d -P
checkout -P
diff -u
rdiff -u
tag -c

There are a few web tools available

  • FishEye/Crucible - CVS repository browser and web based code review tool
  • Hudson - Continuous integration build machine. This sends build breakage notifications to broken_builds@netbeans.org

Tracking broken builds

If you push changes back to the Mercurial server you have to be subscribed to broken_builds@netbeans.org (send an empty message to broken_builds-subscribe@netbeans.org). Any build breakage must be dealt with immediately to avoid blocking others' work. (Reply to the alias as soon as you see that you are at fault to let others know you are working on the problem.)

Machine config

You'd be fine with any decent PC or laptop. As usual more RAM, faster CPU are better than less RAM, slower CPU. The source tree in CVS is big. Don't try to check out or update sources via dial-up connection. It'd require a lot of patience and time, both are precious these days.

You should increase the heap size for Ant, the default is not enough, e.g. by setting environment variable

export ANT_OPTS="-Xmx256m -XX:MaxPermSize=96m"

The whole source tree

If you want everything, do this (NB 6.0 or earlier):

mkdir nbsrc
cd nbsrc
cvs checkout -r release60 nbbuild
ant -f nbbuild/build.xml checkout
ant -f nbbuild/build.xml
ant -f nbbuild/build.xml clean

ant checkout will do the right thing, i.e. it will check out the rest of the source tree from the same branch/tag where nbbuild is coming from.

Working with subsets of the source tree

NetBeans IDE consists of module clusters. A cluster is a collection of modules which together implement related functionality. Here is the list

  • nb.cluster.nb, nb.cluster.platform, nb.cluster.ide, nb.cluster.xml, nb.cluster.java, nb.cluster.profiler, nb.cluster.apisupport, nb.cluster.harness, nb.cluster.j2ee, nb.cluster.visualweb, nb.cluster.uml, nb.cluster.mobility, nb.cluster.soa, nb.cluster.ruby

To work on a specific cluster you need to have modules in that cluster checked out from CVS and also clusters which your cluster depends on.

Example: Ruby support only

Based on the cluster dependency matrix we know that we need

  • nb.cluster.nb
  • nb.cluster.platform
  • nb.cluster.ide
  • nb.cluster.ruby
mkdir nbsrc
cd nbsrc

# For CVS access only; for NB 6.1 in Hg, you must get the whole repo:
cvs checkout nbbuild
# End CVS only

# An example "well-known" cluster, if you wish to use a custom list of clusers, use nb.clusters.list rather than cluster.config.
echo cluster.config=ruby>> nbbuild/user.build.properties

# For CVS access only
ant -f nbbuild/build.xml checkout
# End CVS only

ant -f nbbuild/build.xml
ant -f nbbuild/build.xml tryme
ant -f nbbuild/build.xml clean

For the full list of cluster configurations see the file nbbuild/cluster.properties in your CVS checkout.

You can also have a custom list of clusters which doesn't correspond to any "well-known" cluster configuration. For example if you work on the Ruby support in NetBeans you probably want this

echo nb.clusters.list=nb.cluster.nb,nb.cluster.platform,nb.cluster.ide,nb.cluster.ruby,nb.cluster.java,nb.cluster.apisupport,nb.cluster.harness,nb.cluster.profiler>> nbbuild/user.build.properties

to add NetBeans module development support, including the profiler, to the same build which you would use yourself.

Do you want to build just a single cluster? For example, to build the visualweb cluster, run:

ant -Drebuild.cluster.name=nb.cluster.visualweb rebuild-cluster

Common Mistakes, Tips and Tricks

Do not use JDK 6 to build!

NetBeans build uses JDK 1.5.x and some code that compiles with JDK 6 will not compile with 1.5.x. (Check the Java Platform combo in the Libraries tab of one of your modules. This controls nbjdk.home in nbbuild/user.build.properties. It must be set to a JDK 5 instance.) Check this file to make sure it exists and have a line like this

nbjdk.home=/opt/jdk5

On Windows, the file separator must be escaped since it is a metacharacter; e.g.

nbjdk.home=C:\\Program Files\\Java\\jdk1.5.0_16

In NB 6.1+ you can also create ~/.nbbuild.properties for settings which should apply to any NB checkout on the machine unless overridden in user.build.properties. (Changes made from the IDE will always be stored in user.build.properties.)

So long as nbjdk.home is configured, it is fine (and in fact encouraged) to use JDK 6 to actually run Ant, or equivalently to run Ant from inside the IDE running on JDK 6.

Checkout from branch and/or using timestamp (NB 6.0 or earlier only)

All you have to do is to checkout the nbbuild module from appropriate branch using appropriate timestamp. The rest is automatically handled by the checkout target from nbbuild/build.xml

For example get sources for NetBeans 6.0 Milestone 10:

mkdir nbsrc
cd nbsrc
cvs checkout -rrelease60-m10 -D"2007/06/28 14:31 UTC" nbbuild
ant -f nbbuild/build.xml checkout

The rest of build procedure is the same as above. Information about tag/branch and timestamp is stored in file nbbuild/CVS/Tag