Ant Category

How to write to a file in Ant

To write the text message to a file in ant, you can use ant target echo, it provides the way to directly append to an existing file or write to the new file. The below target demostrates how to write the string to a file in ant script <echo file=”myoutput.txt” append=”true”/> The content to be […]

Ant – How to print classpath in Ant script

The below target print_classpath in build xml demonstrates how to print the project classpath in ant script, this gives the ability to check loaded classpath at runtime.

How to enable ANT verbose?

The Ant verbose option can give you the information about what Ant is doing. you can turn on the verbose flag to debug the ant script: How to do? If you use Ant command line, you can execute ant with -verbose flag: ant -verbose  OR  ant -v

Ant – how to get current directory in Ant

how to get current directory in Ant ? To get the current directory, you can directly use ant build-in property ${basedir}, it  gives us the actual directory where ant is ran from (also the parent directory of the buildfile). <target name=”print-directory”> <echo>current directory: ${basedir}</echo> </target> how to get user working directory in Ant ? To get the […]

Ant – How to echo current time and system date in Ant

Ant has task Tstamp which easily get the current date or system time with TODAY property, the output date can be formatted in any particular custom date/time patterns which are defined in the Java SimpleDateFormat class.

Ant – How to get username, computer name and OS Name in ANT

The propose of this tutorial is to retrieve the current logged username, computer name and operation system name in Ant, we echo these values in below example. Computer name and OS name are actually Ant build-in properties.

How Ant echo environment variables

Ant has a build-in task Property that can access OS-specific environment variables, Property’s parameter environment is the prefix to use when retrieving environment variables, plus the prefix and environment variables’name, we can directly echo or use its value.

Ant – How Do I Remote Debug Java Code in Ant and Eclipse

If we execute the Junit test cases in Ant (most of the time we do) and some cases fail, we may expect to debug Java code in Ant to analyze the failures. This tutorial will demonstrate how to remote debug Java code in ant and Eclipse.

How to Check Java version in Ant

Ant has built-in property ${ant.java.version}, you can directly use it to get Java or JVM version, the following example prints out Java version. Build.xml <target name=”print-version”> <echo>Java/JVM version: ${ant.java.version}</echo> <echo>Java/JVM detail version: ${java.version}</echo> </target>

How do I sign Jar files in Ant

When JAR files are published, it has by default no signature included so nobody would likely trust this source, it is best to digitally sign the JAR files, this like you might sign a paper document with pen and ink – to let readers know who wrote or approved. The typical use of signed jars is […]