Questions tagged [ant]

Apache Ant (formerly Jakarta Ant) is a declarative, XML-based build tool created originally for Java projects. It provides a rich set of standard tasks for performing most common build operations, such as compiling Java source, building archives and running tests. Ant's functionality can be extended through custom tasks and macros.

Ant

Apache Ant is a Java open-source library and command-line tool whose mission is to drive processes described in XML build files as targets and extension points dependent upon each other. Most commonly, Ant is used to build Java applications.

It supplies a number of built-in tasks allowing to compile, assemble, test and run applications. Although primarily aimed at building Java applications, Ant can also be used effectively to build non-Java software, for instance C or C++ applications.

More generally, Ant can be used to pilot any type of process which can be described in terms of targets, tasks, and macros. It's a standard and effective framework which transforms a development structure of project to a deployment structure.

Ant was historically meant as a replacement and Java counterpart for the Unix Make build utility.

References

Extensions

Example

Hello, World!

A build.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project name="HelloWorld" default="world" basedir=".">
  <target name="world" depends="message" description="outputs a friendly message">
    <echo message="World!" />
  </target>
  <target name="message">
    <echo message="Hello, " />
  </target>
</project>

This project can be run from the directory containing the build.xml file by just typing:

  • ant
  • or ant -f build.xml

The list of available self-documenting targets can be viewed with ant -p.

15413 questions
39
votes
4 answers

Multiple depends in Ant task

If I have three targets, one all, one compile and one jsps, how would I make all depend on the other two? Would it be: ...or would it be: Or maybe something…
corsiKa
  • 81,495
  • 25
  • 153
  • 204
39
votes
10 answers

SDK.DIR is missing? android update project?

I get this error when I do $ ant release sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var typing in android update project I get another error saying I must specify the…
Code Droid
  • 10,344
  • 17
  • 72
  • 112
38
votes
7 answers

How to check if directory exists before deleting it, using ANT?

Using ANT, how can i make sure that directory exists before attempting to remove it? As part of my current clean task, i
James Raitsev
  • 92,517
  • 154
  • 335
  • 470
38
votes
5 answers

PostgreSQL Error: column am.amcanorder doesn't exist

I am working on CentOS release 6.8 (Final) based server without sudo access. I compiled PostgreSQL v9.6 beta 2. When I am loading data using ant, I get am.amcanorder column doesn't exist error which I don't know how to fix. I am following a tutorial…
player87
  • 1,781
  • 1
  • 14
  • 21
38
votes
8 answers

Including external jar-files in a new jar-file build with Ant

I have just 'inherited' a Java-project and not coming from a Java-background I am a little lost at times. Eclipse is used to debug and run the application during development. I have through Eclipse succeeded in creating a .jar-file that 'includes'…
Christopher
  • 1,102
  • 1
  • 8
  • 17
38
votes
1 answer

Java Build Tools: Ant vs. Maven

I was reading this blog by Kent R.Spillner regarding java build tools. Although I have lightly used Ant and Maven, I didn't have commited to either one seriously which I intend to do. Is the blog post I linked an exagerated one? Most importantly,…
Andromeda
  • 1,370
  • 2
  • 10
  • 15
38
votes
5 answers

build.xml in Java project

What is the file build.xml? I was wondering if it is a possibility to import this project in Eclipse or Netbeans using this build.xml. I tried to import the project but I get some errors since one part is created using J2ME and the other J2SE and I…
Granit
  • 931
  • 3
  • 12
  • 22
37
votes
7 answers

How to check if a property has value in Ant

I have an Ant XML file which I use for build. I have 3 properties. I want to break the build if these properties does not contain any value. Also I want to break the build if the value is empty. How can I do this in Ant? I a using Ant and not…
KK99
  • 1,971
  • 7
  • 31
  • 64
37
votes
6 answers

Android signing with Ant

Using Ant, I'm trying to build an Android application in release mode for distribution. My problem is at the signing process. I've created a keystore and alias via Eclipse using the Export Android Application wizard and the app is correctly signed…
sgimeno
  • 1,883
  • 1
  • 22
  • 35
37
votes
5 answers

jacoco code coverage report generator showing error : "Classes in bundle 'Code Coverage Report' do no match with execution data"

I am generating jacoco report by using jacoco:report tag. I am getting errors like : [jacoco:report] Classes in bundle 'Code Coverage Report' do no match with execution data. For report generation the same class files must be used as at…
Nishant Lakhara
  • 2,295
  • 4
  • 23
  • 46
36
votes
2 answers

How to check if a property exists?

How do I check the existence of a property using Ant? I am open to the use of ant-contrib, if Ant doesn't provide a similar thing. Also, ant-contrib has an assert task, which provides exists, but the assertion is not what I need here since I would…
Abhijeet Kashnia
  • 12,290
  • 8
  • 38
  • 50
36
votes
12 answers

How to call for a Maven goal within an Ant script?

Is it possible to call or execute a Maven goal within an Ant script? Say I have an ant target called 'distribute' and inside which I need to call a maven 'compile' goal from another pom.xml.
Dunith Dhanushka
  • 4,139
  • 6
  • 26
  • 29
36
votes
31 answers

Error installing Ant: ANT_HOME is set incorrectly

I read all the possible solutions but the none worked. I downloaded the ant and put it in C:\ant (so I have C:\ant\bin) On Windows 7 under System variables I have variable called ANT_HOME with value C:\ant and variable called PATH with…
svenkapudija
  • 5,128
  • 14
  • 68
  • 96
36
votes
8 answers

Maven or Ivy for Managing Dependencies from Ant?

I was wondering about the best way to manage projects dependencies from ant. What are the pros and cons of the Maven Ant task and of Ivy?
Loki
  • 29,950
  • 9
  • 48
  • 62
36
votes
9 answers

How to exclude a directory from ant fileset, based on directories contents

How can I create an ant fileset which excludes certain directories based on the contents of the directory? I use ant to create a distribution jar which has each localization in separate directories, some of which are incomplete and should not be…
Chadwick
  • 12,555
  • 7
  • 49
  • 66