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

How can I import one Gradle script into another?

I have a complex Gradle script that wraps up a load of functionality around building and deploying a number of NetBeans projects to a number of environments. The script works very well, but in essence it is all configured through half a dozen maps…
Anthony Roy
  • 1,835
  • 3
  • 15
  • 16
110
votes
11 answers

How to copy a directory using Ant

I have used copydir to copy a directory tree but it is deprecated. My directory contains some sub-directories, and some of those contain files and others contain more sub-directories. How can I copy the entire tree?
Sunil Kumar Sahoo
  • 53,011
  • 55
  • 178
  • 243
100
votes
8 answers

Ant: How to execute a command for each file in directory?

I want to execute a command from an Ant buildfile, for each file in a directory. I am looking for a platform-independent solution. How do I do this? Sure, I could write a script in some scripting language, but this would add further dependencies to…
ivan_ivanovich_ivanoff
  • 19,113
  • 27
  • 81
  • 100
94
votes
11 answers

Replacing characters in Ant property

Is there a simple way of taking the value of a property and then copy it to another property with certain characters replaced? Say propA=This is a value. I want to replace all the spaces in it into underscores, resulting in propB=This_is_a_value.
aberrant80
  • 12,815
  • 8
  • 45
  • 68
86
votes
11 answers

Specified VM install not found: type Standard VM, name jre7

Specified VM install not found: type Standard VM, name jre7 Have you ever encountered this problem in Eclipse while building an ant file? Then this article is for you. Deleting and recreating the workspace is not the solution. There is an easy…
Shanewaj
  • 2,078
  • 1
  • 20
  • 16
84
votes
17 answers

Ant is using wrong java version

I'm using Ant 1.7.0 and installed java 1.6 which is in JAVA_HOME. I want to build a project using java 1.5, so I've exported JAVA_HOME to be my java 1.5 directory. java -version says "1.5". When I run Ant it uses java 1.6.
Diogo Ribeiro
83
votes
2 answers

Is it possible to have Ant print out the classpath for a particular target? If so, how?

I'm trying to get a target to build that has quite a long list of and elements in its element (in the build.xml file). I keep getting "package…
Daryl Spitzer
  • 143,156
  • 76
  • 154
  • 173
83
votes
13 answers

javac1.8 class not found

I have installed two jdks - jdk 1.5 and jdk 1.8. I have following Ant build.xml config file :
kamilz
  • 833
  • 1
  • 6
  • 7
77
votes
6 answers

Why do I get compilation error "org/codehaus/groovy/control/CompilationFailedException"?

I am trying to compile my JasperReports template using an Ant script and Java. I am getting this error: jasper java.lang.NoClassDefFoundError: org/codehaus/groovy/control/CompilationFailedException There is nothing complex in the template, but I…
user726478
77
votes
5 answers

Unable to locate tools.jar

Possible Duplicate: Unable to locate tools.jar I'm trying to use ant to compile using this command : ant compile I don't know if the problem comes from my windows 64bit, or by something else. Because I have java Installed in the 64 & 32 prog…
Wassim AZIRAR
  • 10,823
  • 38
  • 121
  • 174
77
votes
1 answer

How do I convert a relative path in Ant to an absolute path?

I would like to convert a relative path to an absolute path. How is that done?
JavaRocky
  • 19,203
  • 31
  • 89
  • 110
77
votes
12 answers

SASS implementation for Java?

I'm looking for SASS implementation in Java (could be used with JSP/JSF). For Python I've found CleverCSS, but there is nothing for Java. Anyone heard something about this sort of tool for generating CSS?
user213225
  • 879
  • 1
  • 7
  • 3
77
votes
5 answers

Why do we need Maven or Ant, if we already have Eclipse?

I think this question is an extension of Compare to the IDE for Java,do we still need Ant? There are answers for the question above, but I wish to know a concrete example of using Maven or Ant over just Eclipse. When I develop in Eclipse, Eclipse…
Jackson Tale
  • 25,428
  • 34
  • 149
  • 271
76
votes
7 answers

Any way to generate ant build.xml file automatically from Eclipse?

From Eclipse, I found I can easily export an Ant build file for my project. It provides references to 3rd party libraries and some base targets. I'm using it from my global build file. The only thing that bothers me about this, is that if something…
Joanis
  • 1,669
  • 3
  • 20
  • 32
75
votes
6 answers

Do I have a way to check the existence of a directory in Ant (not a file)?

How do I check for the existence of a folder using Ant? We can check the existence of a file, but can we do the same for a folder as well?
Chathuranga Chandrasekara
  • 20,548
  • 30
  • 97
  • 138