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

Using FileUtils in eclipse

When trying to use FileUtils I get "cannot be resolved" error. Then, how do I install FileUtils library to be able to use it in Eclipse? I see it is an Ant utility, but I am not sure how many jars I need to install.
prosseek
  • 182,215
  • 215
  • 566
  • 871
27
votes
1 answer

Ant target failing: Antlib or Ivy issue?

Possible Duplicate: Ivy fails to resolve a dependancy, unable to find cause I'm trying to run the following build task (initIvy):
IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756
26
votes
3 answers

What's the best way to set up a per-test or per-class timeout when using in perBatch forkmode?

I want to fail the build if anyone writes a test that takes longer than 1 second to run, but if I run in perTest mode it takes much, much longer. I could probably write a custom task that parses the junit reports and fails the build based on that,…
26
votes
2 answers

How to put a newline in ant property

This doesn't seem to work: I use the property value in the body of an e-mail message (which is sent as plain text): some text${foo} and I get literal "\n" in the e-mail…
Yoni
  • 10,171
  • 9
  • 55
  • 72
26
votes
2 answers

Promoting several modules (integration -> milestone) in ivy

Ivy is great for managing dependencies, but it isn't meant to handle the entire software lifecycle across many modules. That said, it does have several features that seem to support it (such as the status and branch attributes), and the ivy best…
oksayt
  • 4,333
  • 1
  • 22
  • 41
26
votes
3 answers

How do I generate Emma code coverage reports using Ant?

How do I setup an Ant task to generate Emma code coverage reports?
Rob Spieldenner
  • 1,697
  • 1
  • 16
  • 26
26
votes
5 answers

How to get the next build number in Gradle

Is there any way to get the next version when publishing to a repository in gradle? For e.g. if I have the version 3.0.1 in my repository I want the published version to be 3.0.2. ivy has a task for ant named buildnumber which does exactly…
Daniel Taub
  • 5,133
  • 7
  • 42
  • 72
26
votes
2 answers

In Ant, how do I get the return value from an exec?

In this task, the executable will return a value which will indicate the state of my app. How could I get the value returned in the Ant build file. I will use this value to…
Hyden
  • 527
  • 2
  • 7
  • 17
26
votes
3 answers

How to convert Ant project to Maven project

How to convert a Ant project to Maven project? A sample project that would link (a Wicket project) Thanks
adelarsq
  • 3,718
  • 4
  • 37
  • 47
26
votes
4 answers

How does ivy:publish work?

I'm completely at loss how the ant task ivy:publish is supposed to work. I would expect that I do my normal build, which creates a bunch of jar files, then I would push those jars to the (local) repository. How can I specify from where to retrieve…
Mauli
  • 16,863
  • 27
  • 87
  • 114
26
votes
4 answers

How to import existing Ant build.xml into IntelliJ IDEA

I have an existing project that uses an Ant build.xml file to maintain the location of dependency jars. In Eclipse it's very easy to import from an existing Ant file. I have searched online and looked through all of the "new project" options in…
Mike S
  • 11,329
  • 6
  • 41
  • 76
26
votes
3 answers

Can Gradle handle a build directory structure that does not conform default conventions?

I am working on a java ant+ivy based project that has the following directory structure: projectRoot/src projectRoot/classes projectRoot/conf projectRoot/webservices this works perfectly well in ant but I am looking to migrate to gradle. Is there a…
liam.j.bennett
  • 424
  • 1
  • 4
  • 11
26
votes
3 answers

ExceptionWithContext gets thrown when trying to build an Android app with Ant

I've tried searching around both on Google and on stackoverflow for an answer to this, but I've been unable to find anyone with the exact issue I'm having. I'm attempting to set up a continuous integration server (Bamboo, specifically) to update,…
Alex
  • 980
  • 8
  • 20
26
votes
1 answer

How to create build.xml for an Android project?

I've been trying to run simple programs that I obtained directly from the Source Code download for the book 'Beginning Android 4'. However, I have lots of problems with the build.xml files (see previous questions, which are unanswered). My latest…
JB_User
  • 3,117
  • 7
  • 31
  • 51
26
votes
6 answers

Ant run command with pipes

I must to implement command : java -jar test.jar page.xml | mysql -u user -p base in ant. So i Have tried with this task: But i have got en exception with…
Le_Coeur
  • 1,521
  • 5
  • 28
  • 44