Tutorials Navigation
Apache Ant Tutorial - Property Task
Tutorial Name: Apache Ant Tutorial - Property Task
Category: PC Tutorials
Submitted By: hoot
Date Added:
Comments: 0
Views: 879
Related Forum: PC Building Forum
Share:
Ant build files are written in XML, which does not allow declaring variables as you do in your favorite programming language. However, as you may have imagined, it would be useful if Ant allowed declaring variables such as project name, project source directory, etc.
Ant uses the property element which allows you to specify properties. This allows the properties to be changed from one build to another or from one environment to another.
By default, Ant provides the following pre-defined properties that can be used in the build file
Sr.No.1-ant.file
The full location of the build file.
Sr.No.2-ant.version
The version of the Apache Ant installation.
Sr.No.3-basedir
The basedir of the build, as specified in the basedir attribute of the project element.
Sr.No.4- ant.java.version
The version of the JDK that is used by Ant.
Sr.No.5-ant.project.name
The name of the project, as specified in the name attribute of the project element.
Sr.No.6-ant.project.default-target
The default target of the current project.
Sr.No.7-ant.project.invoked-targets
Comma separated list of the targets that were invoked in the current project.
Sr.No.8-ant.core.lib
The full location of the Ant jar file.
Sr.No.9-ant.home
The home directory of Ant installation.
Sr.No.10-ant.library.dir
The home directory for Ant library files - typically ANT_HOME/lib folder.
Ant also makes the system properties (Example: file.separator) available to the build file.
In addition to the above, the user can define additional properties using the property element. The following example shows how to define a property called sitename
<?xml version = "1.0"?>
<project name = "Hello World Project" default = "info">
<property name = "sitename" value = "www.tutorialspoint.com"/>
<target name = "info">
<echo>Apache Ant version is ${ant.version} - You are at ${sitename} </echo>
</target>
</project>
Running Ant on the above build file produces the following output
C:\>ant
Buildfile: C:\build.xml
info: [echo] Apache Ant version is Apache Ant(TM) version 1.8.2
compiled on December 20 2010 - You are at [ Register or Signin to view external links. ]
BUILD SUCCESSFUL
Total time: 0 seconds
C:\>
Ratings
Comments
Related Tutorials
- 01. Emulating Xbox 360 on PC for Running COD4 With Mods(3,526)
- 02. How to: Matrix Numbers | Batch File(1,913)
- 03. How to Password Protect Files on Windows(859)
- 04. How to play Socom 2/3/ and Combined Assault on PC(6,746)
- 05. Modern Warfare 2 Vac Ban Bypass Tutorial(6,169)
- 06. How to embed an image on TheTechGame(3,104)
- 07. [PC] NIOH 2 OTHER USER SAVE RESIGN(13,017)
- 08. Host bot lobbies! Full Tutorial!(11,356)
- 09. Unban yourself [Plutonium BO2](14,262)
- 10. Fall Guys - How to Change Your Name Color on Fall Guys(8,396)
- 11. Best Crosshair Settings for Valorant(6,534)
- 12. Othercide The Surgeon Boss Guide(2,548)
- 13. Othercide Remembrances Unlock Guide(4,476)
- 14. Othercide Beginners Tips and Tricks(2,719)
- 15. How to Fix Grounded Crashes, Loading Time, Low FPS and Other(4,856)
"Apache Ant Tutorial - Property Task" :: Login/Create an Account :: 0 comments