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
45
votes
12 answers

Why is Ant giving me a Unsupported major.minor version error

I'm running this target in Ant. It's giving me this…
coder
  • 6,111
  • 19
  • 54
  • 73
45
votes
4 answers

Ant unable to find javac, JAVA_HOME won't set on Ubuntu

I have an Android Project called Hello on my Ubuntu 10.04 i386 Server (headless). It contains all things an Android project folder should have. I first build the project in bash while in the Project folder using this synax: ./android create project…
lollercoaster
  • 15,969
  • 35
  • 115
  • 173
45
votes
3 answers

good ivy tutorial for local repository?

Can anyone point me at a good tutorial for making & using a local repository with Ivy? (Please don't point me at the Ivy docs, the tutorials are rather confusing) I need to make a local repository to include .jar files that aren't necessarily…
Jason S
  • 184,598
  • 164
  • 608
  • 970
44
votes
3 answers

Getting Ant to recognise a classpath

I have an Apache Ant build file with a command that requires four specific JARs to be on the build classpath. I've tried to do this:
Paul Fisher
  • 9,618
  • 5
  • 37
  • 53
44
votes
2 answers

How can I print a fileset to a file, one file name per line?

I have a populated fileset and I need to print the matching filenames into a text file. I tried this:
Tomas Andrle
  • 13,132
  • 15
  • 75
  • 92
44
votes
16 answers

How do you speed up java unit tests?

Currently our project has over 3000 unit tests, and "ant testAll" takes well over 20 minutes. besides getting better hardware, are there ways to speed things up?
James Geng
  • 471
  • 1
  • 5
  • 6
43
votes
7 answers

Unable to find a javac compiler

I am trying to package my web application into war file using Ant. When I build, I am getting the following error: C:\Documents and Settings\Administrator\workspace\Assignment7\build.xml:67: Unable to find a javac compiler; com.sun.tools.javac.Main…
Sarin Jacob Sunny
  • 2,138
  • 3
  • 29
  • 61
43
votes
7 answers

How to set the path environment variable from ant script

How to set the path environment variable from ant script
user855
  • 19,048
  • 38
  • 98
  • 162
43
votes
4 answers

Execute Ant task just if a condition is met

I need to execute an Ant task within a specific target only if a condition is met. I found a way to define the condition at the target level, but not at the task level. I have also found a contribution that implements an IF task. My question is, are…
Jose Miguel Ordax
  • 1,151
  • 1
  • 9
  • 20
42
votes
2 answers

How in Ant output values of properties?

With ant there exists the echo markup: but it seems useless. I need to check values in an ant script, e.g. but it only yields: [echo]…
user810430
  • 11,181
  • 15
  • 38
  • 43
42
votes
8 answers

Ant error when trying to build file, can't find tools.jar?

When I run ant it says: Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar Buildfile: build.xml does not exist! Build failed What package can I use to download the file required > C:\Program…
Derek
  • 4,985
  • 4
  • 20
  • 9
42
votes
8 answers

How to debug Java code when using ANT script in Eclipse

I have a java class and I need to debug it (put breakpoints and continue using F6). I am using ANT script to init, build, deploy and run the code. I am using:
zengr
  • 38,346
  • 37
  • 130
  • 192
42
votes
3 answers

adding comment in .properties files

By using following block of code in build.xml file
Ashwin Hegde
  • 1,733
  • 4
  • 19
  • 49
41
votes
2 answers

generate jars with source code using Ant

I use ant for creating .jar files in Eclipse. I need to generate jar for my project which also contains source code along with the class file. How do we do it? Another question: what is a debug jar and how to create it using ant? (have heard about…
Anand
  • 11,872
  • 10
  • 39
  • 51
41
votes
3 answers

Echoing out ant fileset to screen for Debugging

I have this:
mainstringargs
  • 13,563
  • 35
  • 109
  • 174