Description of the Build Phases in JBuilder

Abstract: Description of the Build Phases in JBuilder

Introduction:

The first thing to know about the build system is that JBuilder internally uses Ant for all operations. Also, Make, Rebuild and Clean commands only appear on the context menu when an appropriate node is selected. The basic functionality is that:

the Make command executes build tasks on various nodes (a node may be a project, Java source, archives, documentation, etc.). These build tasks are defined internally in the JBuilder build system.
the Clean command removes all of the build output
the Rebuild command performs a Make, and then a Clean

The Make command:

Make is a phase that establishes dependencies (more details below) among the stand-alone phases. The Make command is not to be confused with the Java compile make, which only compiles Java source files.

Smart Dependencies Checking:

When compiling, instead of deciding whether to recompile a source file based only on the time stamp of the file, JBuilder analyzes the nature of the changes you make to source files.

There are several possible reasons for recompiling the source:

One or more of the class files the source would produce are missing.
The source has been modified since it was last compiled.
One or more of the classes that the source produces depends on a member in another class that changed.
A change in one source file may change the way other source files are compiled.
When you compile source files for the first time, a dependency file is automatically created for each package and is placed in the output directory along with the class files.

The dependency file:

Has an extension of .dependency.
Contains detailed information about which class uses which for all the classes in that package
Must be on the classpath so the compiler can find them.
Important: Libraries are considered "stable" and are not checked by the Dependency Checker.


Make has the following dependencies in the order listed:

Pre-compile: tasks that occur before compiling. (e.g. IDL files, which are converted to Java source files before compiling)
Compile: generation of Java class files from Java source files.
Post-compile: tasks that occur after compiling. This phase requires Java class files to be executed. (e.g. java2iiop and obfuscated code could be targets of this phase).
Package: tasks that generate archive files.
Deploy: tasks that move deployed files to another location. (e.g. this phase might have a task to FTP files.)
Make executes various build tasks, depending on the nodes selected. A node may be a project, packages, Java source files, archive, documentation, WebApp, external build task, or Ant target nodes.

Here are some examples with descriptions:

Project: compiles the Java source files in the project, as well as executing the appropriate build tasks on any buildable nodes
Packages: Java source files are compiled and resources in these packages are copied to the project's output path
Archive: generates an archive file

There are several ways to Make a file, project, package, or other appropriate node:

Choose Project | Make Project
Choose Project | Make <filename>
Choose the Make Project button on the toolbar, if available.
Right-click a node in the project pane and choose Make.
Right-click the file tab in the content pane and select Make <filename>.


The Clean command

This command may be applied to any target project node that is also buildable. The Clean command removes all build output of the other targets, such as the classes directory, JARs, WARs, and so on. If the source and output paths are the same, the output directory is not deleted but the build output is deleted.

What Clean removes is dependent upon the node selected:

Project nodes:
- Recursively deletes the output directory if the output directory is a subdirectory of the project.
- Clean doesn't delete the output directory if it's the same as the source directory or a subdirectory of the source directory.

Java nodes:
- Deletes the corresponding .class files and any generated files, such as java2iiop.
- Deletes resources.

Package nodes:
- Deletes the corresponding .class files and any resources.

Resource nodes:
- Deletes the copies in the output directory.

Documentation nodes:
- Deletes all HTML and HTM files in the Javadoc output directory.

Archive nodes:
- Deletes the archive file(s) and executables.

WebApp nodes:
- Deletes any WAR files and the WEB-INF/lib and WEB-INF/classes directories.

There are several ways to Clean a project, package, or other appropriate node:

Right-click the project file in the project pane and choose Clean.
Right-click an appropriate node or nodes in the project pane and choose Clean.


The Rebuild command:

Rebuild deletes all the build output by first executing a Clean command, which removes all of the build output (described in more detail below), and then performs a Make. The target for the rebuild may be any particular project node, for example: projects, packages, Java source files, archives, and resources.

This command is useful when you want a clean build, which would be useful under many circumstances:

Here are a few examples:

After deleting Java source files (If you were to do a Make after deleting the Java source files, their class files would still exist)
After moving source files into another package
After renaming a source file
After altering debug options
After altering obfuscation options


There are several ways to Rebuild a file, project, package, or other appropriate node:

Choose Project | Rebuild Project.
Choose Project | Rebuild <filename>
Right-click a node in the project pane and choose Rebuild.
Right-click the file tab in the content pane and select Rebuild <filename>
Choose the drop-down list next to the Make button on the toolbar and choose Rebuild Project.