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
23
votes
4 answers

Run batch scripts on a remote server (windows) from jenkins

I've got a continuous integration server (Jenkins ) which builds my code (checks for compilation errors) and runs tests and then deploys the files to a remote server (not a war file, but the actual file structure) I do this with a Jenkins plugin…
Øyvind B
  • 331
  • 1
  • 2
  • 6
23
votes
2 answers

Publish to Google Play through command line

Is there any option to publish Android Application to Google Play using command line tool ? I have signed my application but I can't use web browser to publish it.
23
votes
5 answers

How to see the compiler output when running javac through an Ant task?

Is there any clearly explained and simple way to see the compiler output when running javac through an Ant task? Here is my javac Ant tag: Here is the only…
sp00m
  • 47,968
  • 31
  • 142
  • 252
23
votes
1 answer

adding non-code resources to jar file using Ant

I am in the process of packaging my java application into a jar file. I am using ant and eclipse. I need to actually include in the jar a couple of separate, non-code files (xml and txt files) directly under the root folder, not in the same place as…
denchr
  • 4,142
  • 13
  • 48
  • 51
22
votes
1 answer

How do I solve Multiple artifacts of the module X are retrieved to the same file in Apache Ivy?

I was using ANT to deploy my stuff to Tomcat. But I had trouble with missing dependencies and I wanted to add Ivy, cause it was reccomended. Now I added this to my build.xml file:
Jaanus
  • 16,161
  • 49
  • 147
  • 202
22
votes
3 answers

Combine filesets using Ant

I have 2 different filesets defined in Ant as follows: I want to create a third fileset which is the union…
Kryptic Coder
  • 612
  • 2
  • 8
  • 20
22
votes
1 answer

Dump all defined properties in Ant script

I have an Ant script that imports several external scripts and property files which were not written by me. (It's a project that was automatically generated by the Android SDK, but that shouldn't matter.) I added a custom target to the script, but…
Mike Baranczak
  • 8,291
  • 8
  • 47
  • 71
22
votes
3 answers

junit: impact of forkMode="once" on test correctness

I'd like to reduce the time which our build (using ant) takes for running the tests. Currently I am using the default forkMode, which forks a new vm on each test class (perTest). I am thinking about to switch to forkMode="once" but I am unsure if…
MRalwasser
  • 15,605
  • 15
  • 101
  • 147
22
votes
2 answers

How to run all JUnit tests in a category/suite with Ant?

I'm using JUnit Categories and ClassPathSuite in a setup similar to that described in this answer. To recap: public interface FastTests…
Jonik
  • 80,077
  • 70
  • 264
  • 372
22
votes
12 answers

What is build automation software (for example, Ant)?

I see reference of ant a lot but I don't get exactly what its meant to do? from what i've heard its supposed to compile your projects but can't i just do that by clicking Run->Run in eclipse? Edit : I guess I should rephrase my question. I already…
Ali
  • 261,656
  • 265
  • 575
  • 769
22
votes
4 answers

How to include version string in the filename when building Android apk with ant?

Normally we build android package in debug mode with the command ant debug and got the apk filename AppName-debug.apk. Is there any way to generate the apk file in the format of AppName-debug-.apk directly without 'mv'…
stid.smth
  • 1,525
  • 2
  • 11
  • 11
22
votes
4 answers

Example of a build.xml for an EAR that deploys in WebSphere 6

I'm trying to convince my providers to use ANT instead of Rational Application Development so anyone can recompile, recheck, redeploy the solution anyplace, anytime, anyhow. :P I started a build.xml for a project that generates a JAR file but…
ggasp
  • 1,490
  • 3
  • 15
  • 24
22
votes
3 answers

How do I use the Ant exec task to run piped commands?

I'm trying to run the following command using the 'exec' task in Ant: ls -l /foo/bar | wc -l Currently, I have my exec looking like this:
Steve Griff
  • 651
  • 1
  • 6
  • 16
22
votes
9 answers

Run Ant on Eclipse Mars with Java 1.6

I downloaded the latest release of Eclipse (Mars) and changed the required Java version to 1.6 in eclipse.ini file as my project uses Java 1.6. I configured installed JREs inside Eclipse to use Java 1.6. But when I try to execute my ant target it…
22
votes
5 answers

Java, Ant error: unmappable character for encoding Cp1252

I am using Java, Eclipse and Ant in my project. I had some Java code that I needed to edit and add some UTF-8 chars in them. Previously my build.xml had: And it worked fine. Now after adding those UTF-8 chars when I try to run, it throws "error:…
user2666282
  • 381
  • 1
  • 2
  • 15