WorkingWithNetBeansSources

Revision as of 16:16, 11 May 2012 by Everflux (Talk | contribs)

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]

Contents

Tools

You need the following to be installed on your machine:

  • JDK 6
  • Recent Apache Ant release (1.8.2 is current as of this writing)
  • Recent Mercurial release (1.9 is current as of this writing), presupposing Python 2.5.1 or later

Running ant at the root of the source tree should suffice to build the complete IDE. The whole source tree has NetBeans project metadata so you can just use NetBeans to develop NetBeans. For example, open any module project (top-level directory), make some edits, and click Run Project to try the IDE with your modifications.

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

If you are having difficulty cloning the repository from this server, you may wish to try an unofficial mirror: https://bitbucket.org/netbeans/main-silver/

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.

Heap size

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"

If you still experience a java.lang.OutOfMemoryError: Java heap space error during the build, further increase the heap size.

Proxies

If you find that building after checkout fails while ExternalBinaries are being fetched and your Internet access requires a proxy server, you need to let Ant know about your proxy.

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

Assuming your proxy is configured at the operating system level, an easier way is to add to ~/.antrc (Unix):

ANT_ARGS='-autoproxy'

Windows would be similar. This style is convenient because each Ant invocation will pick up your _current_ proxy settings automatically.

Working with clusters

The NetBeans IDE consists of several module clusters. A cluster is a collection of modules which together implement related functionality, such as Java EE support. A cluster often (but not necessarily) corresponds to a "Category" in Plugin Manager.

Cluster configurations are sets of clusters which form a complete IDE. Clusters usually depend on other clusters, so a valid config must include dependencies. nbbuild/cluster.properties lists available clusters and configs as well as some other metadata about clusters.

You can select a config to build with the cluster.config property, either on the Ant command line, or in user.build.properties. For example, to build just Java SE support:

echo cluster.config=java >> nbbuild/user.build.properties
ant

To build just a single cluster at a time, for example java, try:

ant -Dname=java rebuild-cluster

assuming that any clusters it depends on (like ide) have already been built.

Common Mistakes, Tips and Tricks

Using the wrong JDK

NetBeans 6.9 and up require JDK 6 to build. You will be prevented from building using JDK 7, to prevent you from accidentally using 7+ APIs.

(NetBeans 6.8 and older build with JDK 5 and similarly refuse by default to be built using JDK 6+.)

Check the Java Platform combo in the Libraries tab of one of your modules. This controls nbjdk.home in nbbuild/user.build.properties. Check this file to make sure it exists and have a line like this

nbjdk.home=/opt/jdk6

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

nbjdk.home=C:\\Program Files\\Java\\jdk1.6.0_25

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 to use a different JDK version to actually run Ant, or equivalently to run Ant from inside the IDE running on a different JDK. For example, you can run NetBeans 7.0 on JDK 7, and build its own sources so long as nbjdk.home is set to JDK 6. Targets like ant tryme or ant -f some.module/build.xml run will use the configured JDK for the tested IDE instance.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo