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
411
votes
7 answers

ant warning: "'includeantruntime' was not set"

I receive the following warning: [javac] build.xml:9: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds What does this mean?
user496949
  • 83,087
  • 147
  • 309
  • 426
324
votes
9 answers

Why use Gradle instead of Ant or Maven?

What does another build tool targeted at Java really get me? If you use Gradle over another tool, why?
IttayD
  • 28,271
  • 28
  • 124
  • 178
209
votes
4 answers

How can I get a list of build targets in Ant?

My codebase has a long build.properties file written by someone else. I want to see the available built targets without having to search through the file manually. Does ant have a command for this - something like ant show-targets - that will make…
Shwetanka
  • 4,976
  • 11
  • 44
  • 68
199
votes
8 answers

How can I install Apache Ant on Mac OS X?

I tried to install Apache Ant on my Mac and I followed the next steps : I downloaded apache-ant-1.8.1-bin.tar.gz into my Downloads folder. I moved the file to /usr/local/ using this commands : sudo sh and mv apache-ant-1.8.1-bin.tar.gz…
florinmatinca
  • 2,063
  • 3
  • 14
  • 7
196
votes
36 answers

Unable to locate tools.jar

I am building a project in Java. I have this error: Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar I have installed a JDK and the folder: C:\Program Files\Java\jre6\lib is in my system but the file…
olidev
  • 20,058
  • 51
  • 133
  • 197
194
votes
27 answers

NoClassDefFoundError - Eclipse and Android

I'm having a problem trying to run an Android app which, up until adding a second external library to its build path, was working fine. Since having added the scoreninja jar, I now get a NoClassDefFoundError when I try to run the app. Here's the…
Tom R
  • 5,991
  • 9
  • 35
  • 41
189
votes
17 answers

Why is no one using make for Java?

Just about every Java project that I've seen either uses Maven or Ant. They are fine tools and I think just about any project can use them. But what ever happened to make? It's used for a variety of non-Java projects and can easily handle Java. …
User1
  • 39,458
  • 69
  • 187
  • 265
187
votes
9 answers

Differences between Ant and Maven

Could someone tell me the differences between Ant and Maven? I have never used either. I understand that they are used to automate the building of Java projects, but I do not know where to start from.
rtacconi
185
votes
11 answers

How to create a signed APK file using Cordova command line interface?

I made a sample application named checkStatus. Now I want to create a signed APK file. So I can install it in different devices for my testing. For this, I Googled and found this documentation. As per the document, I switched to my project directory…
vasan
  • 2,203
  • 3
  • 18
  • 22
156
votes
6 answers

Ant task to run an Ant target only if a file exists?

Is there an ANT Task that would execute a block only if a given file exists? I have the problem that I have a generic ant script that should do some special processing but only if a specific configuration file is present.
Mario Ortegón
  • 18,670
  • 17
  • 71
  • 81
156
votes
5 answers

Ant path style patterns

What are the rules for Ant path style patterns. The Ant site itself is surprisingly uninformative.
MDK
  • 1,631
  • 3
  • 12
  • 5
139
votes
7 answers

Error executing command 'ant' on Mac OS X 10.9 Mavericks when building for Android with PhoneGap/Cordova

Today I tried PhoneGap/Cordova with Mac OS X Mavericks. Building for iOS went just fine, but building for Android wasn't without some guesswork. I installed Android 4.2.2 via the Android SDK Manager (I had to use the older API v17 since it wasn't…
Mobiletainment
  • 22,201
  • 9
  • 82
  • 98
133
votes
8 answers

Should JAVA_HOME point to JDK or JRE?

I pointed the JAVA_HOME to C:\Program Files (x86)\Java\jre7. It works fine. Afterwards, I unzipped ant and set up the environment variables related to Ant, I got the following error messages after typing "ant -version" I searched this forum. Looks…
user297850
  • 7,705
  • 17
  • 54
  • 76
121
votes
11 answers

JUnit: how to avoid "no runnable methods" in test utils classes

I have switched to JUnit4.4 from JUnit3.8. I run my tests using ant, all my tests run successfully but test utility classes fail with "No runnable methods" error. The pattern I am using is to include all classes with name *Test* under test folder. I…
LiorH
  • 18,524
  • 17
  • 70
  • 98
120
votes
4 answers

How do I use Nant/Ant naming patterns?

I have to admit that I always forgot the syntactical intracacies of the naming patterns for Nant (eg. those used in filesets). The double asterisk/single asterisk stuff seems to be very forgettable in my mind. Can someone provide a definitive guide…
berko
  • 2,935
  • 4
  • 26
  • 31
1
2 3
99 100