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
41
votes
2 answers

JAVA_HOME gets mangled by Maven

I'm retrofitting bunch of existing Java projects with unified Maven build. Since each project is mature and has established Ant based build all I'm using maven-antrun-plugin to execute existing build.xml as follows:
Bostone
  • 36,858
  • 39
  • 167
  • 227
41
votes
4 answers

Find working directory from Ant

Is it possible to tell which directory the user ran Ant from? For example, I might want to run only the unit tests in the current working directory, rather than all tests for the entire project. I tried this:
JW.
  • 50,691
  • 36
  • 115
  • 143
41
votes
1 answer

Imperative vs Declarative build systems

I have recently started using Gradle as a build system. They first comparison that Gradle makes with the likes of Ant and Maven is that, Ant is an imperative build system, whereas Maven is a declarative build system. While Gradle is a declarative…
Ankit Dhingra
  • 6,534
  • 6
  • 31
  • 34
41
votes
4 answers

How to wrap an Ant build with Maven?

We use maven for our large-ish product. All of our artifacts are deployed to a shared archiva repository using the maven deploy goal. I am now integrating a third party product that has an ant build. I know how to call ant targets from maven…
digitaljoel
  • 26,265
  • 15
  • 89
  • 115
40
votes
11 answers

‘ant’ is not recognized as an internal or external command

I have the same issue as this user: ant - not recognized as an internal however unfortunately none of the solutions have worked for me in that post or any other. I've also looked at other commands not recognized and specifically adding a path…
user1152440
  • 895
  • 2
  • 13
  • 25
40
votes
7 answers

How can I specify location of debug keystore for Android ant debug builds?

Is it possible to specify the location of a self created debug keystore when creating debug .apk's (-debug.apk) with ant debug? I only see the possibility to specify the location of the release keystore. I would like to share the debug…
Huupke
  • 1,158
  • 1
  • 13
  • 25
40
votes
4 answers

Generate manifest class-path from in Ant

In the build file below, the jar target refers to the jar.class.path property for the manifest class-path. The compile target refers to project.class.path There is redundancy here, because jar.class.path and project.class.path are very similar.…
amarillion
  • 24,487
  • 15
  • 68
  • 80
40
votes
6 answers

Eclipse on Mac, getting "Specified VM install not found" error when trying to build

When I try and do an Ant build on my mac (Snow Leopard, Eclipse 3.6 - Helios) I get an error dialog that says "Problem Occured" 'Launching projectName build.xml' has encountered a problem. Specified VM install not found: type Standard VM,…
cmcculloh
  • 47,596
  • 40
  • 105
  • 130
40
votes
7 answers

Build numbers: major.minor.revision

How would you write a build.xml file, using neither custom code nor external dependencies (such as a shell script), that: Generates a build number of the form major.minor.revision (e.g., 01.02.34). Auto-increments the revision on each compile of…
Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315
39
votes
6 answers

How to pull out a substring in Ant

Is there a way to pull a substring from an Ant property and place that substring into it's own property?
Lark
  • 4,654
  • 7
  • 33
  • 34
39
votes
4 answers

Ant compile doesn't copy the resources

I created my own build.xml which has:
Tomáš Linhart
  • 13,509
  • 5
  • 51
  • 54
39
votes
5 answers

How can I escape double-quotes in ant?

I need to exec the following command from ant, but I can't figure out how to escape the double-quotes: tasklist /FI "IMAGENAME eq java.exe" /FI "MEMUSAGE gt 50000"
sachin
  • 665
  • 3
  • 8
  • 15
39
votes
2 answers

How to recompile with -Xlint:unchecked in Ant build task?

When I run the "compile" target of my Ant "build.xml" file, then I get the following message: Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. My compile target is the following: …
Benny Code
  • 51,456
  • 28
  • 233
  • 198
39
votes
3 answers

How to convert an Eclipse Android project to use Ant for build?

I have an Android project in Eclipse I would like to convert to be built with Ant instead. How can I achieve this? I have tried exporting an Ant build file but I'm pretty sure that's not going to work (nor does it when running ant with the exported…
Jason
  • 4,034
  • 4
  • 40
  • 62
39
votes
9 answers

How to add external jar libraries to an android project from the command line

I'm trying to build an Android project that has some dependencies. The jar files are in the lib/ directory. I can build the project by adding those jar file to my classpath, but of course it Force Closes in the emulator because those libraries…
Jay K
  • 2,081
  • 1
  • 17
  • 19