During an average day working on an Ant-based NetBeans Platform application, a developer would constantly use the project actions such as “Build”, “Clean” and “Test” in the NetBeans IDE. But when the application needs to be built on a build server, a way needs to be found to perform these actions from the command line. Since the projects are already Ant-based, and the actions in the IDE are linked to Ant build scripts, this is luckily straight forward. The only question is which target(s) to call.
For more information about the Ant-based build harness and how it is structured, have a look at this article. (Note that there are multiple parts, and part 2 is especially useful in this context.) But for now the only really important part to note is that all Ant-based NetBeans Platform Applications (suites) and modules have a build.xml file.
Before listing the Ant targets that are generally useful, I would like to explain how to find them yourself. The first and most difficult way is to find the action in the IDE source code. I have done this before, but it is in almost all cases complete overkill. 🙂 The second option is to expand the Build Script under Important Files in the project, to see a complete list of all the targets that are available. While this is much easier, it is still not the most direct route.
The best option in almost all cases is to perform the action and then look at the title of the Output window. The name of the project appears there, followed by the target(s) in brackets.
Targets applicable to NetBeans module projects
- netbeans – Build action in the IDE – compile the module, creating artifacts in the build folder of the module as well as the build folder of the suite
- clean – Clean action in the IDE – removes the contents of the module’s build folder
- nbm – Create NMB action in the IDE – creates an nmb file for the module in its build folder
- test-unit – Test action in the IDE – executes the unit tests in the module and creates artifacts in the build/test folder of the module
Note: For standalone modules, the same targets apply. The difference is that for the netbeans target, all the artifacts are placed in the module’s build folder.
Targets applicable to NetBeans Platform application suites
- build – Build All action in the IDE – builds all the modules contained in the suite
- clean – Clean All action in the IDE – cleans all the modules in the suite and removes the build and dist folders of the suite
- build-zip – Package as > ZIP Distribution action in the IDE – builds all the modules in the suite and then creates a .zip file in the dist folder of the suite
- nbms – Package as > NBMs action in the IDE – builds all the modules in the suite and then creates a .nbm for each of the modules in the suite’s build/updates folder
- test – Test All action in the IDE – executes the unit tests in each of the modules contained in the suite and creates artifacts in the build/test folder of each module
- run – Run action in the IDE – runs the platform application