Redefine property in the children target : Properties « Ant « Java





Redefine property in the children target

 
/*
Buildfile: build.xml

print-global:
     [echo] In print-global
     [echo] The value of property.example is: Local File

print-target:
     [echo] In print-target
     [echo] The value of property.example is: Local File

BUILD SUCCESSFUL
Total time: 0 seconds
C:\Java_Dev\WEB\dev\java\api\Proant\ch03>
*/       
       
<?xml version="1.0"?>

<project name="Apache Ant Properties Project" default="print-target" basedir=".">

  <property file="build.properties"/>
  <property file="build.properties.default"/>
  <property name="property.example" value="Global"/>

  <target name="print-global">
    <echo message="In print-global"/>
    <echo message="The value of property.example is: ${property.example}"/>
  </target>

  <target name="print-target" depends="print-global">
    <property name="property.example" value="Target"/>

    <echo message="In print-target"/>
    <echo message="The value of property.example is: ${property.example}"/>
  </target>

</project>




--------------------------------------------------------------------------------------
File: build.properties

property.example=Local File
property.file.example=build.properties

--------------------------------------------------------------------------------------
File: build.properties.default

property.example=Default File
property.file.example=build.properties.default


           
         
  










AntBasicTags.zip( 2 k)

Related examples in the same category

1.Value in the properties file overwrite the value in the build.xml
2.Redefine property in the children target 2
3.Load file through URL
4.Referrence property: basedir
5.Custom properties
6.Define custom property based on existing properties
7.Ant buildin properties
8.Separate two values
9.Reference ant.project.name
10.In init target set the properties
11.Define and reference property