go to  ForumEasy.com   
JavaPro  
 
 
   Home  |  MyForum  |  FAQ  |  Archive    You are not logged in. [Login] or [Register]  
Forum Home » Java Deploying » Ant -- Target
Email To Friend  |   Set Alert To This Topic Rewarding Points Availabe: 0 (What's this) New Topic  |   Post Reply
Author Topic: Ant -- Target
ant
member
offline   
 
posts: 20
joined: 04/19/2010
from: San Jose, CA
  posted on: 08/11/2010 06:16:47 PM    Edit  |   Quote  |   Report 
Ant -- Target
A target is a container of tasks that cooperate to reach a desired state during the build process.

<target name="A"/>
<target name="B" depends="A"/>
<target name="C" depends="B"/>
<target name="D" depends="C,B,A"/>


Call-Graph:  A --> B --> C --> D


 Profile | Reply Points Earned: 0
ant
member
offline   
 
posts: 20
joined: 04/19/2010
from: San Jose, CA
  posted on: 08/11/2010 06:19:47 PM    Edit  |   Quote  |   Report 
If/unless Conditional Target

A target has the ability to perform its execution if (or unless) a property has been set.

<target name="build-module-A" if="module-A-present"/>


If the module-A-present property is set (to any value, e.g. false), the target will be run.


<target name="build-own-fake-module-A" unless="module-A-present"/>


If the module-A-present property is set (again, to any value), the target will not be run.

 Profile | Reply Points Earned: 0
ant
member
offline   
 
posts: 20
joined: 04/19/2010
from: San Jose, CA
  posted on: 08/11/2010 06:21:22 PM    Edit  |   Quote  |   Report 
Want more controls?

<target name="myTarget" depends="myTarget.check" if="myTarget.run">
    <echo>Files foo.txt and bar.txt are present.</echo>
</target>

<target name="myTarget.check">
    <condition property="myTarget.run">
        <and>
            <available file="foo.txt"/>
            <available file="bar.txt"/>
        </and>
    </condition>
</target>


Call-Graph:  myTarget.check --> maybe(myTarget)

 Profile | Reply Points Earned: 0
ant
member
offline   
 
posts: 20
joined: 04/19/2010
from: San Jose, CA
  posted on: 08/11/2010 06:29:33 PM    Edit  |   Quote  |   Report 
One more example
<target name="local_config">
    <condition property="local.config.properties"  value="../conf/${local.config}">
      <and>
        <isset property="local.config"/>
        <not>
          <equals arg1="" arg2="${local.config}"/>
        </not>
      </and>
    </condition>
</target>

  <target name="echo_local_config" depends="local_config" if="local.config.properties">
      <echo message="Using local config: ${local.config.properties}"/>
  </target>


Output:
Buildfile: C:\temp\project\build.xml
local_config:
echo_local_config:
     [echo] Using local config: ../conf/config.properties-demo
BUILD SUCCESSFUL
Total time: 1 second
 Profile | Reply Points Earned: 0

 
Powered by ForumEasy © 2003-2005, All Rights Reserved. | Privacy Policy | Terms of Use
 
Get your own forum today. It's easy and free.