Quick Start with Ant
Here is a quick guide to building the IDE with Apache Ant.
Basic Steps
The quickest summary: download IDE sources (whichever version you want to use); get JDK 1.4 (or 1.5 for NB 6.0+) and Ant
1.6.5 (1.7.0 for NB 6.0+); run Ant from the nbbuild directory, accept some license terms, and enjoy. In a little more
detail:
Get the sources for the IDE: download the IDE source,
or checkout from Mercurial
using a command like: hg clone http://hg.netbeans.org/main/
Please avoid using spaces in your working directory structure. Spaces
in paths are not supported by the build system.
Get Ant if you
have not already (version 1.6.1 is currently required for NetBeans 3.6 and 4.0, 1.6.2 for 4.1, 1.6.5 for 5.x, 1.7.0 for 6.0+), install it, and make sure it is
set up correctly. You can build it from source according to its
own instructions, or get various binary packages including RPM format.
(Beware however that ant.jar must live in the lib subdirectory
of the installation, not in /usr/share/java as some RPMs have it,
unless they use symlinks to make it appear that there is a complete installation in the usual layout.)
For NetBeans 5.0, you must use a 1.4.2 or later JDK to build the IDE as well as to run
it.
JDK 1.4.2_09 is currently recommended.
Trunk builds require JDK 5 (e.g. 1.5.0_11).
Compilation will fail under JDK 1.4.1 due to a compiler bug.
You may need to increase the maximum heap
memory limit for the Ant process. On Unix, create ~/.antrc:
ANT_OPTS=-Xmx256m
export ANT_OPTS
On Windows, create %HOME%\antrc_pre.bat:
set ANT_OPTS=-Xmx256m
Change directory into nbbuild where the master
build script is. Run: ant. This should create
a file nbantext.jar containing NetBeans-specific Ant extensions.
Then it will continue on to build the IDE. If all goes well, you
will see log messages being printed as it compiles and otherwise
assembles modules and components of the IDE. On a fast machine,
a complete build may only take a few minutes, but your results may vary.
Near the end, it will actually try to start the IDE temporarily
to run some functional tests. So your build machine must be able to display the
IDE graphically (for Unix users, make sure $DISPLAY is
set). This step is optional and is only used to test the build
(not create it).
When the build is done, you should have a file named something
like NetBeans-SOMETHING.zip. This should be a functional
IDE build. Installing and running it is easy; there is a page with details if you need them. You
can also try the IDE right from the build directory: descend into
netbeans/bin/ and run netbeans or netbeans.exe,
as appropriate, from there. Or just type ant tryme.
If you make changes to the source code, just run ant
again; this will perform a faster incremental rebuild of
the IDE. This can be completed within a couple of minutes. (Some kinds
of changes may require recompilation, in which case run various clean
targets first as needed.) You may wish to use configuration file
nbbuild/user.build.properties for common build options (properties),
which overrides default build options set in nbbuild/build.properties
(do not modify build.properties itself).
Running a Build as a Developer
If you are committing to the NetBeans repository, please see the
NetBeans commit guidelines
for additional instructions.
Tip: if you use Linux, you can run a premade script that does the clean
build and test suites for you. Try
nbbuild/misc/full-build-linux.sh
(see the shell script comments for usage instructions).
Common Build Options
There are a few options you can give to the build which would be commonly
used (most specific to NetBeans, some not):
- -Dbuildnumber=666
- Set the build number to 666 instead of the default. Mostly useful
if you are preparing a build for release purposes.
- -Dbuild.compiler.deprecation=true
- Show deprecations.
- -Dstop.when.broken.modules=false
- Useful for "always successful" build, when you don't care of some particular
(and currently broken) modules
- -Dmerge.dependent.modules=false
- Resolve compile time dependencies and merge all dependent modules.
- -Dbuilt.modules.property=propname
- Name of property which will contain the list of successfuly built modules
(useful when used with stop.when.broken.modules.
- -Dresolve.clean.dependencies=true
- Resolve compile-time dependencies during cleaning working repository
- -Dstop.when.clean.error=true
- Set it to
false to ignore build errors during cleaning
- -emacs -Dbuild.compiler.emacs=true
- Make output friendlier to Emacs (when run from M-x compile).