build.xml(5)
β¨ build.xml β the manual page, but make it cute β¨
okay bestie, gather round, because today we're talking about build.xml, a File Formats Manual entry, and honestly? it's giving "the blueprint of your whole build" π
πΈ NAME πΈ
build.xml β the configuration file Apache Ant uses to build projects. that's it, that's the girl. π
π DESCRIPTION π
so. build.xml is the default configuration file that ant uses to figure out which target to build for a specific project. think of it as the Ant equivalent of a Makefile. same energy, different font. β¨
Ant's format is XML, and you make a separate file for each project. a buildfile is made of one or more tasks. here's an example, look at her:
<project default="compile">
<target name="compile">
<javac srcdir="src"/>
</target>
</project>
this example has one target, and it's the default one. the target itself has one task, javac, which compiles the files in the src directory. simple, clean, iconic. π«Ά
π― TARGETS π―
targets can depend on other targets, bestie. those dependencies get declared with the depends attribute on the <target> element. no cap, that's the whole vibe. π₯
π οΈ TASKS π οΈ
a task is a piece of code that gets executed. Ant knows about built-in tasks and optional tasks, but you can also write your own new tasks if you're feeling main character. π
β Built-in tasks β
the built-in tasks are, in order, and I am NOT skipping a single one because we don't do that here:
Ant, AntCall, AntStructure, AntVersion, Apply, Apt, Available, Basename, BuildNumber, BUnzip2, BZip2, Checksum, Chmod, Concat, Condition, Copy, Componentdef, Cvs, CvsChangeLog, CvsVersion, CVSPass, CvsTagDiff, Defaultexcludes, Delete, Deltree, Dependset, Diagnostics, Dirname, Ear, Echo, EchoXML, Exec, Fail, Filter, FixCRLF, GenKey, Get, HostInfo, GUnzip, GZip, Import, Include, Input, Jar, Java, Javac, Javadoc, Length, LoadFile, LoadProperties, LoadResource, Local, MakeURL, Mail, MacroDef, Manifest, ManifestClassPath, Mkdir, Move, Nice, Parallel, Patch, PathConvert, PreSetDef, Property, PropertyHelper, Record, Replace, ResourceCount, Retry, Rmic, Sequential, SignJar, Sleep, Sql, SubAnt, Sync, Tar, Taskdef, Tempfile, Touch, Truncate, TStamp, Typedef, Unjar, Untar, Unwar, Unzip, Uptodate, Waitfor, WhichResource, War, XmlProperty, XSLT, Zip
seventy-something tasks and they all ate. π
β Java β
executes a Java class within the running (Ant) VM, or forks another VM if specified. here are some of the attributes on the <java> element:
classname(required) β the Java class to execute.forkβ if enabled, it triggers the class execution in another VM. it's disabled by default.jvmβ the command used to invoke the Java Virtual Machine; default isjava. the command gets resolved byjava.lang.Runtime.exec(). ignored ifforkis disabled, so don't come crying to me. π
other arguments are classpath, classpathref, maxmemory, failonerror, dir and output. β¨
π Javac π
compiles a source tree within the running (Ant) VM.
srcdir(required) β location of the java files.destdirβ location to store the class files.debugβ indicates whether source should be compiled with debug information; defaults to off.targetβ generate class files for a specific VM version (e.g.,1.4,1.5, etc).includesβ comma-separated list of patterns of files that must be included; all files are included when omitted.excludesβ comma-separated list of patterns of files that must be excluded; no files (except default excludes) are excluded when omitted.defaultexcludesβ indicates whether default excludes should be used (yes|no); default excludes are used when omitted.
other arguments are includesfile, excludesfile, classpath, bootclasspath, classpathref, bootclasspathref, extdirs, encoding, deprecation, verbose, includeAntRuntime, includeJavaRuntime and failonerror. so many options, so little time. π
π Properties π
a project can have a set of properties, which are a name/value combination. within tasks you use them by wrapping them between "${" and "}", like "${builddir}/classes". it's the original variable interpolation, and she's still serving. π
π§ Built-in Properties π§
Ant gives you access to all system properties as if they'd been defined with a <property> task. for example, ${os.name} expands to the name of the operating system. free real estate. β¨
basedirβ the absolute path of the project's basedir (as set with thebasedirattribute of<project>).ant.fileβ the absolute path of the buildfile.ant.versionβ the version of Ant.ant.project.nameβ the name of the project that is currently executing; it's set in thenameattribute of<project>.ant.java.versionβ the JVM version Ant detected.
π Classpath π
the classpath can be set with the <classpath> element, like so:
<classpath>
<pathelement path="${classpath}"/>
<pathelement location="lib/helper.jar"/>
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset> </classpath>
nested elements, filesets, ${classpath} expansion β she's got range. π
π SEE ALSO π
π«Ά AUTHOR π«Ά
this manpage was made by Egon Willighagen <egonw@sci.kun.nl>, and it's based on the Ant Manual <http://ant.apache.org/manual/>. credit where credit is due, periodt. π
π and that's the whole page, bestie. go forth and build. no cap.
Debian Linux Β· February 2010 β mwah, thanks for reading, ily, bye! πβ¨π π¦πΈ
π¦ where this page comes from
- debian bookworm: ant 1.10.13-1 Β· Apache-2.0
- debian trixie: ant 1.10.15-1 Β· Apache-2.0
- ubuntu jammy: ant 1.10.12-1 Β· Apache-2.0
- ubuntu noble: ant 1.10.14-1 Β· Apache-2.0
- ubuntu questing: ant 1.10.15-1
- ubuntu resolute: ant 1.10.15-1build1 Β· Apache-2.0
- ubuntu stonking: ant 1.10.18-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms