{"id":221,"date":"2026-10-12T20:11:28","date_gmt":"2026-10-12T20:11:28","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2010\/03\/21\/power-point-ppt-introduction-of-apache-ant-2\/"},"modified":"2026-10-12T20:11:28","modified_gmt":"2026-10-12T20:11:28","slug":"power-point-ppt-introduction-of-apache-ant-2","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/power-point-ppt-introduction-of-apache-ant-2\/","title":{"rendered":"Apache Ant Fundamentals: build.xml, Targets, Commands, and CI\/CD Usage"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><em>Originally published on 2010-03-21; fully revised and updated.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Apache Ant is a build automation tool used heavily in Java ecosystems to turn source code into repeatable artifacts. This guide helps DevOps and build engineers understand how Ant works, how to run it reliably in CI\/CD, and when Ant is the right choice compared with Maven or Gradle.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The original post was a SlideShare-only teaser. This revision provides a complete written reference and keeps the original permalink for context: <a href=\"https:\/\/www.devopsschool.com\/blog\/power-point-ppt-introduction-of-apache-ant-2\/\">Power Point PPT: Introduction of Apache Ant<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Archival reference to the original embed shortcode:<\/strong><\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs language-text\">{slideshare}&#91;slideshare id=1117750&amp;doc=introductiontoant1-090308134214-phpapp01]{\/slideshare}<\/code><\/span><\/pre>\n\n\n<h2 class=\"wp-block-heading\">What Apache Ant does well<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Ant uses an XML build file (typically <code>build.xml<\/code>) where you define explicit tasks and target dependencies. It is especially useful when you need precise control over build steps, custom file operations, or compatibility with existing enterprise Java projects.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Task-oriented:<\/strong> You define exactly what happens and in what order.<\/li><li><strong>Extensible:<\/strong> You can use built-in tasks or add custom tasks.<\/li><li><strong>Scriptable in CI:<\/strong> Ant is straightforward to execute from any runner that can run shell commands.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Core concepts: project, targets, tasks, and properties<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Project:<\/strong> The root element of an Ant build file.<\/li><li><strong>Target:<\/strong> A named stage (for example, <code>compile<\/code> or <code>package<\/code>) that can depend on other targets.<\/li><li><strong>Task:<\/strong> An action inside a target (for example, <code>javac<\/code>, <code>copy<\/code>, <code>jar<\/code>).<\/li><li><strong>Property:<\/strong> A key-value setting reused across the build (for example, directory paths).<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Minimal build.xml example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This sample compiles Java source and creates a JAR artifact. It is intentionally small so you can adapt it quickly.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">project<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\">\"sample-ant-app\"<\/span> <span class=\"hljs-attr\">default<\/span>=<span class=\"hljs-string\">\"package\"<\/span> <span class=\"hljs-attr\">basedir<\/span>=<span class=\"hljs-string\">\".\"<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">property<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\">\"src.dir\"<\/span> <span class=\"hljs-attr\">value<\/span>=<span class=\"hljs-string\">\"src\"<\/span>\/&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">property<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\">\"build.dir\"<\/span> <span class=\"hljs-attr\">value<\/span>=<span class=\"hljs-string\">\"build\"<\/span>\/&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">property<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\">\"dist.dir\"<\/span> <span class=\"hljs-attr\">value<\/span>=<span class=\"hljs-string\">\"dist\"<\/span>\/&gt;<\/span>\n\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">target<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\">\"clean\"<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">delete<\/span> <span class=\"hljs-attr\">dir<\/span>=<span class=\"hljs-string\">\"${build.dir}\"<\/span>\/&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">delete<\/span> <span class=\"hljs-attr\">dir<\/span>=<span class=\"hljs-string\">\"${dist.dir}\"<\/span>\/&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">target<\/span>&gt;<\/span>\n\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">target<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\">\"compile\"<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">mkdir<\/span> <span class=\"hljs-attr\">dir<\/span>=<span class=\"hljs-string\">\"${build.dir}\"<\/span>\/&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">javac<\/span> <span class=\"hljs-attr\">srcdir<\/span>=<span class=\"hljs-string\">\"${src.dir}\"<\/span> <span class=\"hljs-attr\">destdir<\/span>=<span class=\"hljs-string\">\"${build.dir}\"<\/span> <span class=\"hljs-attr\">includeantruntime<\/span>=<span class=\"hljs-string\">\"false\"<\/span>\/&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">target<\/span>&gt;<\/span>\n\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">target<\/span> <span class=\"hljs-attr\">name<\/span>=<span class=\"hljs-string\">\"package\"<\/span> <span class=\"hljs-attr\">depends<\/span>=<span class=\"hljs-string\">\"compile\"<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">mkdir<\/span> <span class=\"hljs-attr\">dir<\/span>=<span class=\"hljs-string\">\"${dist.dir}\"<\/span>\/&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">jar<\/span> <span class=\"hljs-attr\">destfile<\/span>=<span class=\"hljs-string\">\"${dist.dir}\/app.jar\"<\/span> <span class=\"hljs-attr\">basedir<\/span>=<span class=\"hljs-string\">\"${build.dir}\"<\/span>\/&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">target<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">project<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">How an Ant build executes<\/h2>\n\n\n\n<pre class=\"mermaid\">\nflowchart TD\n    A[Run ant package] --> B[Read build.xml]\n    B --> C[Resolve target dependencies]\n    C --> D[Run compile tasks]\n    D --> E{Compile succeeded}\n    E -- no --> F[Stop and report error]\n    E -- yes --> G[Run package target]\n    G --> H[Write artifact to dist]\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Common Ant commands<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Command<\/th><th>Purpose<\/th><th>Typical use<\/th><\/tr><\/thead><tbody><tr><td><code>ant -p<\/code><\/td><td>List available targets<\/td><td>Discover runnable stages in a project<\/td><\/tr><tr><td><code>ant clean<\/code><\/td><td>Run cleanup target<\/td><td>Remove previous build outputs<\/td><\/tr><tr><td><code>ant compile<\/code><\/td><td>Compile source code<\/td><td>Fast validation in local development<\/td><\/tr><tr><td><code>ant package<\/code><\/td><td>Create distributable artifact<\/td><td>Produce JAR or WAR before deploy<\/td><\/tr><tr><td><code>ant -Denv=prod package<\/code><\/td><td>Set runtime property<\/td><td>Switch behavior by environment<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php language-bash\"><span class=\"hljs-comment\"># Show targets<\/span>\nant -p\n\n<span class=\"hljs-comment\"># Clean and build<\/span>\nant clean package\n\n<span class=\"hljs-comment\"># Pass a property<\/span>\nant -Denv=prod package<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Ant vs Maven vs Gradle<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These tools all build Java projects, but they differ in how much convention they impose and how you express build logic.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Tool<\/th><th>Build style<\/th><th>Dependency management<\/th><th>Best for<\/th><\/tr><\/thead><tbody><tr><td>Apache Ant<\/td><td>Imperative, task-by-task control<\/td><td>Possible, but not the primary design focus<\/td><td>Custom workflows and legacy build systems<\/td><\/tr><tr><td>Apache Maven<\/td><td>Declarative lifecycle with conventions<\/td><td>Built-in and central to workflow<\/td><td>Standardized enterprise Java builds<\/td><\/tr><tr><td>Gradle<\/td><td>Programmable DSL plus conventions<\/td><td>Built-in and flexible<\/td><td>Complex multi-module or highly customized modern builds<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Using Ant in CI\/CD pipelines<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">At minimum, a CI job needs Java and Ant installed, then executes target commands the same way you do locally. Keep outputs in a predictable directory (such as <code>dist\/<\/code>) so artifacts can be archived or deployed.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs language-yaml\">stages:\n  - build\n\nbuild_with_ant:\n  stage: build\n  script:\n    - ant clean package\n  artifacts:\n    paths:\n      - dist\/<\/code><\/span><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Best practices and common pitfalls<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Keep target names clear and action-oriented (<code>clean<\/code>, <code>compile<\/code>, <code>test<\/code>, <code>package<\/code>).<\/li><li>Avoid hidden side effects between targets; make dependencies explicit with <code>depends<\/code>.<\/li><li>Externalize environment differences with properties instead of hardcoding paths.<\/li><li>Use a consistent artifact output directory for CI\/CD traceability.<\/li><li>Document required tools (JDK and Ant) to reduce onboarding friction and pipeline drift.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">If you inherit an Ant-based system, first make the target graph reproducible and observable; then evaluate whether migration to Maven or Gradle is worth the effort.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This updated guide explains Apache Ant from a DevOps perspective: how build.xml works, how targets and tasks execute, and how to run Ant reliably in CI\/CD. It also compares Ant with Maven and Gradle so you can choose the right tool.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[8],"tags":[],"class_list":["post-221","post","type-post","status-publish","format-standard","hentry","category-training"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/221","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=221"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/221\/revisions"}],"predecessor-version":[{"id":79038,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/221\/revisions\/79038"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}