Tutorials Navigation
Apache Ant Tutorial - Property Files
Tutorial Name: Apache Ant Tutorial - Property Files
Category: PC Tutorials
Submitted By: hoot
Date Added:
Comments: 0
Views: 474
Related Forum: PC Building Forum
Share:
Setting properties directly in the build file is fine, if you are working with a handful of properties. However, for a large project, it makes sense to store the properties in a separate property file.
Storing the properties in a separate file offers the following benefits
-It allows you to reuse the same build file, with different property settings for different execution environment. For example, build properties file can be maintained separately for DEV, TEST, and PROD environments.
-It is useful when you do not know the values for a property (in a particular environment) up-front. This allows you to perform the build in other environments where the property value is known.
There is no hard and fast rule, but typically the property file is named build.properties and is placed along-side the build.xml file. You could create multiple build properties files based on the deployment environments - such as build.properties.dev and build.properties.test.
The contents of the build property file are similar to the normal java property file. They contain one property per line. Each property is represented by a name and a value pair. The name and value pairs are separated by an equals (=) sign. It is highly recommended that the properties are annotated with proper comments. Comments are listed using the hash (#) character.
The following example shows a build.xml file and its associated build.properties file
build.xml
<?xml version = "1.0"?>
<project name = "Hello World Project" default = "info">
<property file = "build.properties"/>
<target name = "info">
<echo>Apache Ant version is ${ant.version} - You are at ${sitename} </echo>
</target>
</project>
build.properties
# The Site Name
sitename = example
buildversion = 3.3.2
In the above example, sitename is a custom property which is mapped to the website name. You can declare any number of custom properties in this fashion. Another custom property listed in the above example is the buildversion, which, in this instance refers to the version of the build.
In addition to the above, Ant comes with a number of predefined build properties, which are listed in the previous Tutorials of mine.
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 Files" :: Login/Create an Account :: 0 comments