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
5
votes
1 answer

How do I add a build.xml to an existing GWT project in Eclipse?

I have a running Java GWT application, that I can compile using Eclipse. Now I wan't to also be able to build this application from the command line using ant. As of my understanding I therefore need a build.xml file. I used the webAppCreator tool,…
JochenJung
  • 7,183
  • 12
  • 64
  • 113
5
votes
1 answer

Ant Plugin Task IntelliJ java.lang.OutOfMemoryError

Environment: IntelliJ IDEA 2016.3.1 Build #IU-163.9166.29, built on December 9, 2016 JRE: 1.8.0_112-release-408-b2 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Mac OS 10.12.2 I have the Ant Support plugin installed in IntelliJ and am…
Ian G
  • 498
  • 3
  • 16
5
votes
1 answer

Ant exec task: How can I read input from console stdin?

I have a call to Ant exec task that needs to accept input from console stdin. Unfortunately, I cannot find a way to do this. The stdin filehandle seems closed to console input at runtime. It is possible to specify input using attributes input and…
kevinarpe
  • 20,319
  • 26
  • 127
  • 154
5
votes
1 answer

Apache Ant: Terminate process started by when ant process is terminated

I have an ant task which executes a lengthy build operation using . Ant is started by a batch file from the windows command line. If I terminate the ant task by closing the window, the process started by keeps running. How can I achieve…
Cybran
  • 2,203
  • 2
  • 17
  • 34
5
votes
0 answers

How to correctly generate an R.java file for an Android library project when building APK from pure Makefile?

In order to understand better how the Android app development tools work, I started on a pure GNU Makefile in order to create an APK completely independent of ant or gradle. From this Makefile I call low-level tools (plumber commands) such as aapt,…
rubund
  • 7,603
  • 3
  • 15
  • 24
5
votes
3 answers

Ant task to extract image dimensions (height, width) from PNG and JPEG files?

Per the Google Page Speed recommendations, I want to Specify image dimensions to "Optimize browser rendering." Specifying a width and height for all images allows for faster rendering by eliminating the need for unnecessary reflows and…
Kevin Hakanson
  • 41,386
  • 23
  • 126
  • 155
5
votes
5 answers

How to run "ant update" in Hybris with only "Update Running System"?

I'm trying to run ant update from the command line after building my Hybris project but it runs Update Running System, Clear hMC Configuration from Database, Create essential data and Localize type (please refer the following image): Is there a way…
ANIL
  • 2,542
  • 4
  • 25
  • 44
5
votes
1 answer

mxmlc and framework linkage - how to specify linkage as rsl

I'm trying to build my flex 4 project using ant. In Flash Builder 4, in project properties it's possible to set the "Framework linkage" to one of "Merged into code", "Runtime Shared Library (RSL)" or "Use SDK Default (Runtime Shared library)". How…
cybertoast
  • 1,343
  • 13
  • 19
5
votes
1 answer

Eclipse runs ANT twice, even sending run only once

In Netbeans, after some research, I managed to edit the file build.xml to customize the way the IDE generated my jar and my manifest file. I had to migrate a project for Eclipse, and even found the option to build jar, but I need to build my jar…
5
votes
2 answers

How to replace newline in ant in outputfilterchain?

In my build.xml, I want to do the equivalent of cmd1 | xargs cmd2 (and also store the list of files from cmd1 into the variable ${dependencies}), where cmd1 gives a newline-separated list of paths. I can't figure out how to do this in Ant.
yonran
  • 18,156
  • 8
  • 72
  • 97
5
votes
6 answers

Best way to alter constants in Java build process

I have inherited a Java application (servlets) that runs under Tomcat. For historical reasons, the code has different "look and feel" options based on where the application will be deployed (essentially a matter of branding). There are several…
Huntrods
  • 2,561
  • 3
  • 22
  • 29
5
votes
2 answers

NetBeans Clean & Build Android error: Java.Lang X500Principal access

I’m wondering if anyone can help on this one. An error occurs when cleaning and building the simplest of projects. (see below) Steps leading to error: As a new employee and therefore new user on a machine no older than 4 months, I started by…
Zeenglishking
  • 83
  • 2
  • 11
5
votes
2 answers

How do I share data between custom Ant tasks?

I wrote two different custom Ant tasks. They are trying to share data through a static member in a base class. This is not working for me. I assume I am using static members correctly within Java. I think this is a dynamic loading issue with the…
kevinarpe
  • 20,319
  • 26
  • 127
  • 154
5
votes
2 answers

Ant propertyfile task: how can I set an integer with no thousand separators?

I have a property defined in one of my property files: I read this property using: Once this number gets bigger than 999,…
Nikita
  • 769
  • 2
  • 8
  • 18
5
votes
2 answers

Netbeans - adding resource files to jar file with Ant

I want add some resource files (non-code text-based files) to the jar file in a Java project using Netbeans 6.9, I'd expect using Ant. I had thought that this would be reasonably simple...but after quite a bit of searching I can't find how to do…
Alistair Collins
  • 2,200
  • 5
  • 25
  • 44