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 is java. the command gets resolved by java.lang.Runtime.exec(). ignored if fork is 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 the basedir attribute 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 the name attribute 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