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
50
votes
6 answers

No key.store and key.alias properties found in build.properties

I am using ant-release to do a 1-step build of my Android app. My build.properties looks like this: application.package=xxxxx key.store=sonr key.alias=sonr labs key.store.password=xxxx key.alias.password=xxxx When I run ant-release everything is…
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556
49
votes
5 answers

"Unable to locate tools.jar" when running ant

When running ant, I get the following message: Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar I have JAVA_HOME set to C:\Program Files\Java\jdk1.7.0_02, PATH includes C:\Program Files…
john
  • 903
  • 3
  • 9
  • 9
49
votes
7 answers

Best way to integrate Git with Ant?

I am looking for the best way to integrate Git with Ant. Is there a widely used Ant task for Git? Does anyone have any experience using Git through Ant (e.g. dedicated task, exec call, etc)?
Vince
  • 1,441
  • 1
  • 14
  • 19
49
votes
10 answers

Multiple Android Application Package .apk files from single source code

I would like an Android build system procedure, command line or Eclipse, to generate several .apk files from a single source codebase. Some common reasons for this - having specific versions for markets with different requirements or a free and paid…
Walter K
  • 1,474
  • 1
  • 14
  • 24
49
votes
8 answers

Is there a decent HTML Junit report plugin for Maven?

I find the surefire-report plug-in very unsuitable to my working style. I clean the project all the time and I don't want to spend 5 min to rebuild the whole site every time I want to look at the test report in my browser. If I type mvn…
Y.H Wong
  • 7,151
  • 3
  • 33
  • 35
49
votes
10 answers

How to change JAVA.HOME for Eclipse/ANT

I am trying to sign a jar file using an ANT script. I know this has to be pointed at the JDK directory for jarsigner.exe to run, but when I echo java.home it returns the JRE directory. This isn't a problem for javac, because I can set the…
Ken
  • 1,029
  • 2
  • 14
  • 22
48
votes
10 answers

Ant needs tools.jar and unable to find it

I am putting together a dev environment for a Java program and after the first try of my Ant build scripts I got this error: Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk/lib/tools.jar While the path to the jdk is…
Genadinik
  • 18,153
  • 63
  • 185
  • 284
48
votes
5 answers

Ant if else condition?

Is there an if/else condition that I can use for an Ant task? This is what i have written so far: Get file based on condition
Jono
  • 17,341
  • 48
  • 135
  • 217
48
votes
4 answers

How do I set -Dfile.encoding within ant's build.xml?

I've got java source files with iso-8859-1 encoding. When I run ant, I get "warning: unmappable character for encoding UTF-8". I can avoid this if I run ant -Dfile.encoding=iso-8859-1 or add encoding="ISO-8859-1" to each javac statement. Is there…
neu242
  • 15,796
  • 20
  • 79
  • 114
47
votes
8 answers

Using ant to detect os and set property

I want to set a property in an ant task differently by os type. The property is a directory, in windows i want it to be "c:\flag" in unix/linux "/opt/flag". My current script only works when i run it with the default target, but why ?
semantic-dev
  • 1,095
  • 3
  • 14
  • 27
47
votes
8 answers

ERROR: unterminated quoted string at or near

While executing below shown trigger code using ANT I am getting the error org.postgresql.util.PSQLException: ERROR: unterminated quoted string at or near "' DECLARE timeout integer" Position: 57 I am able to sucessfully execute the below code…
Anuj
  • 471
  • 1
  • 4
  • 3
47
votes
9 answers

How do I pass an argument to an Ant task?

I'm not very good with Ant, but we're using it as a build tool. Right now, we can run "ant test" and it'll run through all the unit tests. However, I'd love to be able to do something like ant test some_module and have it accept some_module as a…
Jonathan Haddad
  • 471
  • 1
  • 4
  • 3
47
votes
5 answers

How to put a jar in classpath in Eclipse?

Hi I am n00b in classpath and Ant. While reading the tutorial of GCM for Android I came across a line Step 1: Copy the gcm.jar file into your application classpath To write your Android application, first copy the gcm.jar file from the SDK's…
vincent mathew
  • 4,278
  • 3
  • 27
  • 34
47
votes
1 answer

Xml namespace declaration: auto-substitute package name

I have an android project with multiple build targets (using ant). For testing purposes, those build targets all have different package names (so my package name is com.mycompany.myapp for release build and com.mycompany.myapp.test for test…
Alexey
  • 7,262
  • 4
  • 48
  • 68
46
votes
2 answers

Where are classpath, path and pathelement documented in Ant version 1.8.0?

I'm looking over the documentation that comes with Apache Ant version 1.8.0 and can't find where classpath, path and pathelement are documented. I've found a page that describes path like structures but it doesn't list the valid attributes or nested…
Robert Menteer
  • 2,132
  • 2
  • 17
  • 14