Java Reference
In-Depth Information
but it's best to keep it close to the project. To create a new build file, follow
these steps:
In the
Project
window, select the directory in which you wish to create
the build file.
1
Right-click the directory, and select
New | File
(
Alt+Insert
).
2
Specify the name of the build file with an
XML
extension.
3
The editor's
XML
and Ant awareness make it a great platform for developing
build files, but the design of the targets and steps is up to you. For
IDEA
to treat
XML
files as Ant build scripts (and provide the Ant-specific extensions that come
with the designation), the
XML
build file must be added to the
Ant Build
tool
window, described in the next section. If you don't include the file in the
Ant
Build
tool window,
IDEA
treats it as a regular
XML
file with only basic support.
The Ant build file editor flags any references to property values not ex-
plicitly defined in the file, even though they may be valid at runtime.
You can appease the editor by setting up default values for every exter-
nal property referenced in the build file. Any values present in the sys-
tem will override these default values anyway.
WARNING
Generating the Ant builds
Since version 4.5,
IDEA
provides the ability to automatically generate Ant build
files, based on your project structure. Using
Build | Generate Ant Build
is a
good start, especially if you're new to using Ant. This command can generate a
single Ant file that builds your entire project or a series of Ant files that build each
individual module. Once generated, the files can be edited, customized, and
maintained as per normal.
The
Generate Ant Build
dialog also gives you the option to either back up or
overwrite previously generated files and to enable the compilation of
IDEA
's
UI
forms.
IDEA
custom
UI
form designer and the implications of using it on your
build scripts are dealt with in chapter 10.
The Ant Build window
The
Ant Build
window is where you interact with your project's build files. The
window is accessed by clicking the
Ant Build
icon on the right margin of
IDEA
or
by selecting
Window | Ant Build
. Initially, this window appears empty, because
you haven't added any build files to the project yet. Briefly, here's what each of
the buttons in the Ant toolbar does: