alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Ant example source code file (scriptselector.xml)

This example Ant source code file (scriptselector.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Ant tags/keywords

The scriptselector.xml source code

<project name="scriptselector" default="def" basedir=".">

  <property name="src.file" location="${ant.file}" />
  
  <macrodef name="testselected">
    <element name="selector" implicit="yes" optional="true"/>
    <attribute name="message"/>
    <sequential>
      <fail message="@{message} failed: file was not selected">
        <condition>
          <not>
            <isfileselected file="{src.file}">
              <selector/>
            </isfileselected>
          </not>
        </condition>
      </fail>
    </sequential>
  </macrodef>  
  
  <macrodef name="testnoselected">
    <element name="selector" implicit="yes" optional="true"/>
    <attribute name="message"/>
    <sequential>
      <fail message="@{message} failed: file was selected">
        <condition>
          <isfileselected file="{src.file}">
            <selector/>
          </isfileselected>
        </condition>
      </fail>
    </sequential>
  </macrodef>    

  <!-- this is here to test the macro is well coded -->
  <target name="testNoSelector">
    <testselected message="testNoSelector" >
    </testselected>
  </target>

  <target name="testNolanguage">
    <testselected message="testNolanguage" >
      <selector>
        <scriptselector >
          self.setSelected(true);
        </scriptselector>
      </selector>
    </testselected>
  </target>

  <target name="testSelectionSetByDefault">
    <testselected message="testSelectionSetByDefault" >
      <selector>
        <scriptselector language="javascript">
        </scriptselector>
      </selector>
    </testselected>
  </target>


  <target name="testSelectionSetWorks">
    <testselected message="testSelectionSetWorks" >
      <selector>
        <scriptselector language="javascript">
          self.setSelected(false);
          self.setSelected(true);
        </scriptselector>
      </selector>
    </testselected>
  </target>

  <target name="testSelectionClearWorks">
    <testnoselected message="testSelectionClearWorks">
      <selector>
        <scriptselector language="javascript">
          self.setSelected(false);
        </scriptselector>
      </selector>
    </testnoselected>
  </target>
  
  <target name="testFileAttribute">
    <testselected message="testFileAttribute" >
      <selector>
        <scriptselector language="javascript">
          self.setSelected(file.equals(self.getFile()));
        </scriptselector>
      </selector>
    </testselected>
  </target>  

  <target name="testFilenameAttribute">
    <testselected message="testFilenameAttribute" >
      <selector>
        <scriptselector language="javascript">
          self.setSelected(filename.equals(self.getFilename()));
        </scriptselector>
      </selector>
    </testselected>
  </target>    
  
  <target name="testBasedirAttribute">
    <testselected message="testBasedirAttribute" >
      <selector>
        <scriptselector language="javascript">
          self.setSelected(basedir.equals(self.getBasedir()));
        </scriptselector>
      </selector>
    </testselected>
  </target>
  
  <target name="notestFilenameLength">
    <testselected message="notestFilenameLength" >
      <selector>
        <scriptselector language="javascript">
          self.setSelected((filename.length%2)==0);
        </scriptselector>
      </selector>
    </testselected>
  </target>    
</project>

Other Ant examples (source code examples)

Here is a short list of links related to this Ant scriptselector.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.