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
36
votes
2 answers

Migrating complex project from Ant to Maven - How to handle unusual folder structures?

In my new project I am confronted with a complex infrastructure with several modules which have grown over the years in an unpleasant, uncontrolled way. To come to the point: The build process is the horror. There are over 40 different, complex Ant…
softandsafe
  • 2,465
  • 3
  • 15
  • 14
35
votes
2 answers

How to write a variable in to file in ant?

i have a variable abc and had the value this is ant script. This abc variable will keep on changing. Using ANT script, how can i write the value out to the file?
kores
  • 351
  • 1
  • 3
  • 4
35
votes
5 answers

How do I check out an SVN project into Eclipse as a Java project?

I was trying to check out a project from SVN using Eclipse. I tried using "Checkout As" to make it into a "Java project from existing Ant script", but the project wizard requires the file to have already been downloaded. Is there a way to checkout…
Hosam Aly
  • 41,555
  • 36
  • 141
  • 182
34
votes
5 answers

Ivy fails to resolve a dependency, unable to find cause

While using ivy:retrieve, it fails to resolve the dependency that should be downloaded. The output looks like this: Buildfile: C:\Users\Simon\workspace\apollo\build.xml init: resolve: BUILD FAILED C:\Users\Simon\workspace\apollo\build.xml:42:…
Simon Sheehan
  • 745
  • 2
  • 8
  • 17
34
votes
5 answers

Create cross platform Java SWT Application

I have written a Java GUI using SWT. I package the application using an ANT script (fragment below).
mchr
  • 6,161
  • 6
  • 52
  • 74
34
votes
10 answers

What's with all the Java Build tools?

what's the point of using ant, maven, and buildr? won't the using build in eclipse or netbeans work fine? i'm just curious what the purpose and benefit of extended build tools are.
cesar
  • 8,944
  • 12
  • 46
  • 59
33
votes
15 answers

Ant, Tomcat Build Error: java.lang.NoClassDefFoundError: org/apache/tomcat/util/buf/B2CConverter

Tomcat Version: 7.0.20 I am attempting to work my way through the following Spring MVC tutorial: http://static.springsource.org/docs/Spring-MVC-step-by-step/part1.html In this tutorial, an ant build script is setup to deploy to tomcat using the…
Jason Turner
  • 1,184
  • 2
  • 10
  • 18
33
votes
14 answers

How do I change the JAVA_HOME for ant?

I'm doing java work on a class server where I don't have root. Whenever I try to compile using ant, it points to the wrong directory (/usr/tomcat instead of /usr/tomcat/jre ). One of the things we were told to do when setting up our user accounts…
Eugene M
  • 47,557
  • 14
  • 38
  • 44
33
votes
3 answers

How can I allow an Ant property file to override the value set in another?

I have an ant file that does the following:
Chris R
  • 17,546
  • 23
  • 105
  • 172
33
votes
19 answers

Getting Error running javac.exe compiler message, while using Ant in Eclipse

When I run my Ant build in Eclipse, I'm getting the following error message and the Ant build fails. Error Message: Error running javac.exe compiler Line where the build stops:
Veera
  • 32,532
  • 36
  • 98
  • 137
33
votes
6 answers

ant task to remove files from a jar

How to write an ant task that removes files from a previously compiled JAR? Let's say the files in my JAR are: aaa/bbb/ccc/Class1 aaa/bbb/ccc/Class2 aaa/bbb/def/Class3 aaa/bbb/def/Class4 ... and I want a version of this JAR file without the…
bguiz
  • 27,371
  • 47
  • 154
  • 243
32
votes
4 answers

Why does Zipping the same content twice gives two files with different SHA1?

I have run into a strange problem with git and zip files. My build script takes a bunch of documentation html pages and zips them into a docs.zip I then check this file into git. The problem I am having is that every time I re-run the build script…
ams
  • 60,316
  • 68
  • 200
  • 288
32
votes
3 answers

Ant: passing compilerarg into javac

I have ant script that compiles: ... I need to increase heap memory of compiler,…
32
votes
14 answers

Ant: Malformed \uxxxx encoding in propertyfile task

I get the error below with an Ant skript I wrote. I already did some googling and found out, that the problem lies with strings containing \u, which happens under Windows because of the directory separator. I changed all those to / but the error…
Michael Niemand
  • 1,578
  • 3
  • 23
  • 39
32
votes
2 answers

How do I find the latest version of an artifact from a maven repository

As part of an automated deployment I need a script to download the latest version of an artifact from our internal repository. Ideally this script will be with ant or a unix shell script. So for example: I have myArtifact.war and it has versions 1.0…
Pablojim
  • 8,542
  • 8
  • 45
  • 69