| Author | 
              Topic: Ant -- Target  |  
           
         | 
        
          
            
              
                
                	
                  
                    
                      ant member offline     |  
                    
                      |   |  
                    
                      
                        
                          
                            | posts: | 
                            20 |  
                          
                            | joined: | 
                            04/19/2010 |  
                          
                            | from: | 
                            San Jose, CA |  
                         
                       |  
                    | 
                  | 
                
                  
                    
                       |  
                    
                       |  
                    
                      
                        
                          | 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
 
 
  |  
                        
                           |  
                        |  
                    
                       |  
                    
                       |  
                    |  
                | 
        
          
            
              
                
                	
                  
                    
                      ant member offline     |  
                    
                      |   |  
                    
                      
                        
                          
                            | posts: | 
                            20 |  
                          
                            | joined: | 
                            04/19/2010 |  
                          
                            | from: | 
                            San Jose, CA |  
                         
                       |  
                    | 
                  | 
                
                  
                    
                       |  
                    
                       |  
                    
                      
                        
                          | 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.
 
  |  
                        
                           |  
                        |  
                    
                       |  
                    
                       |  
                    |  
                | 
        
          
            
              
                
                	
                  
                    
                      ant member offline     |  
                    
                      |   |  
                    
                      
                        
                          
                            | posts: | 
                            20 |  
                          
                            | joined: | 
                            04/19/2010 |  
                          
                            | from: | 
                            San Jose, CA |  
                         
                       |  
                    | 
                  | 
                
                  
                    
                       |  
                    
                       |  
                    
                      
                        
                          | 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)
 
  |  
                        
                           |  
                        |  
                    
                       |  
                    
                       |  
                    |  
                | 
        
          
            
              
                
                	
                  
                    
                      ant member offline     |  
                    
                      |   |  
                    
                      
                        
                          
                            | posts: | 
                            20 |  
                          
                            | joined: | 
                            04/19/2010 |  
                          
                            | from: | 
                            San Jose, CA |  
                         
                       |  
                    | 
                  | 
                
                  
                    
                       |  
                    
                       |  
                    
                      
                        
                          | 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
 |  
                        
                           |  
                        |  
                    
                       |  
                    
                       |  
                    |  
                |