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
74
votes
5 answers

How to set an Ant property only if it is unset

I can't figure out how to set an Ant property on the condition that it has not been set (i.e it is not defined in the properties file and should automatically default). So far, I only have the following code:
user64133
  • 1,149
  • 3
  • 9
  • 10
74
votes
10 answers

Server certificate verification failed: issuer is not trusted

I am getting below error when running a target of ANT script. Error message saying that "server certificate verification is failed". Please help how to remove this problem. I am working in Windows XP. C:\apache-ant-1.8.1>ant checkout Buildfile:…
Shaun
  • 765
  • 2
  • 6
  • 10
73
votes
4 answers

Setting the target version of Java in ant javac

I need to compile a jar file using ant (1.7.0) to run under a specific version of Java (1.5). I currently have Java 1.6 on my machine. I have tried setting: I…
peter.murray.rust
  • 37,407
  • 44
  • 153
  • 217
69
votes
4 answers

Can someone explain the ivy.xml dependency's conf attribute?

I can't find any thorough explanation of the Ivy dependency tag's conf attribute: See that conf attribute? I can't find any explanation (that I…
Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356
69
votes
3 answers

How to build the Android sample projects using Ant? build.xml does not exist

I believe I've followed the instructions in the Android SDK, and I'm now trying to build the sample LunarLander (random one picked) $ cd samples/android-11/LunarLander $ ant debug Buildfile: build.xml does not exist! Build failed I believe all…
Kalen
  • 3,106
  • 8
  • 29
  • 42
69
votes
3 answers

Importing ant build.xml in Eclipse

I have an android project that uses ant to build, is it possible to import this ant project in eclipse IDE? update : There is an option to create project using ant build.xml in eclipse File->New->Project->Java->Java project from existing ant…
Suresh
  • 9,495
  • 14
  • 49
  • 63
69
votes
4 answers

Creating a bundle jar with ant

I'm using Ant to build some Java projects. In some, I've got a lib/ directory, which contains external dependencies, in the form on JAR files. During the build, I create a bundled jar, that contains the project's code, alongside the dependencies, by…
abyx
  • 69,862
  • 18
  • 95
  • 117
65
votes
7 answers

Disable DTD warning for Ant scripts in Eclipse?

I'm using Eclipse Ganymede. Everything works fine, but I have an anal-retentive yearning for a warning-free Problems tab. Right now it (correctly) complains about my Ant scripts: "No grammar constraints (DTD or XML schema) detected for the…
Brian Deacon
  • 21,384
  • 13
  • 39
  • 41
65
votes
12 answers

Java "constant string too long" compile error. Only happens using Ant, not when using Eclipse

I have a few really long strings in one class for initializing user information. When I compile in Eclipse, I don't get any errors or warnings, and the resulting .jar runs fine. Recently, I decided to create an ant build file to use. Whenever I…
Allan
  • 1,635
  • 4
  • 15
  • 19
63
votes
11 answers

Clean way to combine multiple jars? Preferably using Ant

I have runtime dependencies on some external jars that I would like to "rejar" into a single jar. These external dependencies are stored in an external_jars directory, and I'd like to be able to not have to list them all (i.e., not to need to change…
Jacob
  • 1,671
  • 4
  • 23
  • 26
62
votes
14 answers

Automated unit testing with JavaScript

I'm trying to incorporate some JavaScript unit testing into my automated build process. Currently JSUnit works well with JUnit, but it seems to be abandonware and lacks good support for Ajax, debugging, and timeouts. Has anyone had any luck…
Chris MacDonald
  • 5,975
  • 4
  • 34
  • 35
62
votes
24 answers

Why does ANT tell me that JAVA_HOME is wrong when it is not?

I get the error: C:\dev\ws\springapp\build.xml:81: Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK. It is currently set to "C:\Program Files\Java\jre6" But I have…
Ankur
  • 50,282
  • 110
  • 242
  • 312
62
votes
1 answer

Make javac treat warnings as errors

I have an Ant file that compiles my program. I want the javac task to fail if any warning was reported by the compiler. Any clue on how to do that?
Itay Maman
  • 30,277
  • 10
  • 88
  • 118
61
votes
4 answers

parameter for xcodebuild for using latest sdk.

I using ant exec task to execute xcodebuild to build some iOS projects hudson. I would like to be able to crate script that way that allows not to specify sdk version, because after updating sdk on hudson slave or my iOS projects all my projects…
Maciek Sawicki
  • 6,717
  • 9
  • 34
  • 48
61
votes
9 answers

What is the best way to avoid maven-jar?

I am using a different plugin (ant4eclipse) to jar my files. What is the best way to avoid the maven-jar plugin from executing? I tried to remove the maven-jar-plugin I tried to ** / * < / exclude> I tried to…
unj2
  • 52,135
  • 87
  • 247
  • 375