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
32
votes
16 answers

JAVA_HOME does not point to the JDK

I am trying to follow a tutorial about how to use ant to build and run your application. I've followed all the steps and have created the build file, but when I try to run ant it gives me this error. BUILD FAILED /home/bilal/tmp/ant/build.xml:19:…
comatose
  • 1,952
  • 7
  • 26
  • 42
31
votes
5 answers

Refresh an Eclipse project with Ant

We have some Ant script fosr building the different jars we use, in several Eclipse projects. There is some interdependency At the end of the build, we have to refresh some of the Eclipse projects in order to make the build path valid. Without…
Antoine Claval
  • 4,923
  • 7
  • 40
  • 68
31
votes
5 answers

ant filtering - fail if property not set

I've got a ant build.xml that uses the task to copy a variety of xml files. It uses filtering to merge in properties from a build.properties file. Each environment (dev, stage, prod) has a different build.properties that stores…
James Cooper
  • 2,320
  • 2
  • 23
  • 23
31
votes
3 answers

Custom JUnit Report?

I am using the ant tasks 'junit' and 'junitreport' to run my JUnit Tests and generate a report at the end (=> "Unit Test Results"). Is it there some easy way to extend this output somehow to get more information displayed in the report? For example…
blackicecube
  • 1,393
  • 5
  • 15
  • 15
30
votes
3 answers

Ant renaming while copying file

How to rename file while copying it to directory in ant?
Martin
  • 767
  • 2
  • 9
  • 21
30
votes
2 answers

How to generate build.xml for a new java project?

I am learning about build.xml file for ant build. I have a simple "Hello World" project in Eclipse. Is there any way to generate a build.xml file in Eclipse for this project? Thanks in Advance.
kanap008
  • 2,800
  • 2
  • 25
  • 24
30
votes
1 answer

Apache Ant difference - exec vs apply

Can anyone tell me the difference between and in Apache Ant?
Matty F
  • 3,763
  • 4
  • 30
  • 48
30
votes
2 answers

is there a way to set ant -verbose inside build.xml?

I would like to get verbose console output while building from eclipse and hudson. There seems to be no verbose property for and and it seems very wrong to call on ant from inside the script just to pass the verbose…
kostja
  • 60,521
  • 48
  • 179
  • 224
30
votes
12 answers

What is wrong with my ant configuration?

I installed Ant on a Fedora 5 machine using yum, but Ant does not launch. I get this error message: [bash]# ant Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher Caused by:…
Scottie T
  • 11,729
  • 10
  • 45
  • 59
30
votes
9 answers

How to over-write the property in Ant?

Is there a way to re-assign the value for the Ant property task? Or is there another task available for that purpose?
Priya
30
votes
6 answers

ant machine name property

Is there a way to get the machine name as ant property, for both Linux and Windows OS.
Drejc
  • 14,196
  • 16
  • 71
  • 106
30
votes
1 answer

Where is the documentation for the "path" taskelement in Ant?

I must be missing something obvious here... I found the online documentation for the task, but I can't find it for the task, e.g.:
Jason S
  • 184,598
  • 164
  • 608
  • 970
30
votes
3 answers

Ant: copy the same fileset to multiple places

I need an Ant script that will copy one folder to several other places. As a good obedient programmer, I want not to repeat myself. Is there any way of taking a fileset like this:
Marcus Downing
  • 10,054
  • 10
  • 63
  • 85
29
votes
3 answers

How come there is no Apache Ant xml schema definition or DTD for build scripts?

Could please anybody explain to me why is that? I've been always using Maven and absence of xml definition for Ant build script is something that makes me searching through internet and documentation instead of one look at the xsd or DTD. For…
lisak
  • 21,611
  • 40
  • 152
  • 243
29
votes
1 answer

The ant/ folder is suddenly missing from Android SDK. Did Google remove it?

I've tried compiling libreoffice core project (choosing Android module) (with make, no Gradle involved yet), and I'm getting this error: /home/aleksandar/libreoffice/workdir/UnpackedTarball/owncloud_android_lib/build.xml:90: Cannot find…
Aleksandar Stefanović
  • 1,583
  • 2
  • 20
  • 36