More Tutorials| Bioinformatics| Open Source| Photoshop| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Ant Custom Properties 
 

Setting properties in the build file is the first method of providing custom properties with element in an ant build file.

 

Ant Custom Properties

                         

 Setting properties in the build file is the first method of providing custom properties with <property> element in an ant build file. Unlike the <project> and <target> elements, the <property> element is defined as a task. This means that you can include <property> elements inside a target depending on certain conditions or depending on which target has been selected. You can also set properties at the beginning of a build file so that they apply to the entire build file. This means that you can set important constant values in a central location so that they are easy to find and change. You should remember that properties set inside a target override any properties set at the project level. Naming again comes into this and you should consider whether your target level properties should be identified as such by using a prefix to avoid confusion and possible namespaces clashes.

The simplest and most obvious use of the <property> task is to set a property using a name value pair, as shown below. 

You can set the value of a property to the value of another property. This can be useful if you will be referencing a verbose built-in property multiple times. This is as simple as placing a property marker in the value attribute of a <property> task as shown below in source code:

build.xml:

<project name="Properties" default="custom.echo" basedir=".">

  <property name="custom.value" value="1.0"/>
  <property name="fileseperator" value="${file.separator}"/>
  <property name="pathseperator" value="${path.separator}"/>
  
  <target name="custom">
    <echo message="custom.value = ${custom.value}"/>
  </target>

  <target name="custom.echo" depends="custom">
    <echo message="File: ${basedir}${fileseperator}build.xml"/>
    <echo message="Path: ${basedir}${fileseperator}build.xml${pathseperator}${basedir}
                   ${fileseperator}build.properties"/>
  </target>

</project>


Run this program on the appropriate path, then the following output will be displayed.

Download Source Code

                         

» View all related tutorials
Related Tags: sql c database xml file url data ui build property user sed password word driver vi name using this element

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.