WorkingWithNetBeansSources
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.
If you are interested in sources for NetBeans 6.0 or earlier, see: WorkingWithNetBeansSourcesPre61
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
- Latest Mercurial release (at least 1.0.2), presupposing Python 2.5.1 or later
The whole source tree has NetBeans project metadata so you can just use NetBeans to develop NetBeans.
Mercurial access
hg clone http://hg.netbeans.org/main-silver/
(If you are going to be pushing changesets directly, you will be cloning a team repository instead.)
NOTE: If you find that building after checkout fails while external binaries are being fetched and your Internet access requires a proxy server, you need to let Ant know about your proxy. The easiest way to do this is via the ANT_OPTS environment variable. For example,
set ANT_OPTS="-Dhttp.proxyHost=proxy.mycompany.com -Dhttp.proxyPort=8080"
on MS Windows. Replace set with export to achieve the same result on Unix.
Tracking broken builds
If you push changes to the Mercurial server you have to be subscribed to broken_builds@netbeans.org (send an empty message to broken_builds-subscribe@netbeans.org). Hudson, the continuous integration build machine, sends messages to this alias. 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 is big, so dial-up users may have difficulty getting it.
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"
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. An old list is as follows:
- 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
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 # 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 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 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:<br>Program Files<br>Java<br>jdk1.5.0_16
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.