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
26
votes
15 answers

Ant + JUnit: NoClassDefFoundError

Ok, I'm frustrated! I've hunted around for a good number of hours and am still stumped. Environment: WinXP, Eclipse Galileo 3.5 (straight install - no extra plugins). So, I have a simple JUnit test. It runs fine from it's internal Eclipse JUnit…
SteveT
  • 959
  • 3
  • 10
  • 17
25
votes
5 answers

How to set ANT_HOME with Windows?

How can I easily set ANT_HOME under Windows? I added "D:\Installz\apache-ant-1.8.2\bin;" to my system environment variable PATH and I also created an ANT_HOME variable.
Bekhbayar
  • 446
  • 2
  • 6
  • 12
25
votes
4 answers

Reading from .properties file in Ant build.xml

I need some help with using Ant's property files. I have the following: A build.properties file. This file contains one piece of information: on=1 An ant.xml file. This file contains my build instructions. I want to read the on attribute from my…
user842650
  • 251
  • 1
  • 3
  • 3
25
votes
2 answers

ant junit task does not report detail

I tried to write an ant with JUnit test, but get below result: unittest: [junit] Running com.mytest.utiltest [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec [junit] Test com.mytest.utiltest FAILED it just shows error…
hetaoblog
  • 1,990
  • 5
  • 26
  • 34
25
votes
2 answers

How to upgrade the ant built into eclipse?

I use ANT for all my builds and I also use eclipse as my IDE and I would like to be able to use the latest version of ANT in my eclipse, frequently the ANT that ships with eclipse is a point release behind. so my questions are. Is there an easy way…
ams
  • 60,316
  • 68
  • 200
  • 288
25
votes
4 answers

How to tell Eclipse to ignore errors in an Ant build.xml?

I have an Eclipse project which is built using Maven, and I'm using the m2eclipse plugin inside Eclipse for it's Maven support. However this project also contains a build.xml which is not used for actually building the project, but just for…
matt b
  • 138,234
  • 66
  • 282
  • 345
25
votes
4 answers

How do I append some text at the end of a file using Ant?

In one of the configuration files for my project I need to append some text. I am looking for some options to do this using Ant. I have found one option - to find something and replace that text with the new text, and the old values. But it does not…
Vijay Shanker Dubey
  • 4,308
  • 6
  • 32
  • 49
25
votes
8 answers

Phonegap/Cordova build android node_modules/q/q.js throw e;

cordova build android gives me the following err node_modules/q/q.js:126 throw e; (*error details) This question has been asked before, but the typical answer regarding PATH and ANDROID_HOME hasn't worked for me. I've put this into code snippet to…
mylord
  • 699
  • 2
  • 12
  • 20
25
votes
3 answers

regular expression to match everything until the last occurrence of /

Using a regular expression (replaceregexp in Ant) how can I match (and then replace) everything from the start of a line, up to and including the last occurrence of a slash? What I need is to start with any of…
user3762977
  • 651
  • 2
  • 15
  • 27
25
votes
5 answers

How to strip the basedir from an absolute path to get a relative path?

In the build.xml of my project I have a property defined: The value of ${somedir.dir} will be an absolute path: /home/myuser/my_project/some_dir. What I need is just the relative path…
blackicecube
  • 1,393
  • 5
  • 15
  • 15
25
votes
1 answer

How to use Jenkins parameterized builds?

Jenkins allows you to parameterize builds, but I can't figure out how to actually make use of it: Say I would normally kick my Ant build off from the command-line like so: ant -buildfile /path/to/my/build.xml -DpackageType=jar package This would…
user1768830
25
votes
1 answer

Ant vs. tasks

I now see Ant has both an task and an task. According to the descriptions: Include Include another build file into the current project. and Import Imports another build file into the current project. So, why use one over the…
David W.
  • 105,218
  • 39
  • 216
  • 337
25
votes
3 answers

Tricky Ant fileset (include most, but not all of a directory)

I've got a case where I just can't figure out how to get Ant to pull in just the files I want in a fileset (why on earth didn't the Ant people just use regex?). Here's the situation. I've got a bunch of classes under the classes directory. I…
Chris Kessel
  • 5,583
  • 4
  • 36
  • 55
24
votes
2 answers

how to call an ant target when overriding the target in a child file

i have a project that uses a parent ant file similar to this: RUN TEST FROM PARENT…
nheid
  • 1,088
  • 2
  • 11
  • 17
24
votes
5 answers

How to solve "Cause: the class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask was not found." while running "ant test"?

I have a target named test and I want to do some tests. I put here the important parts in build.xml. It includes: And I…
xiaohan2012
  • 9,870
  • 23
  • 67
  • 101