stevel      2005/03/10 15:20:04

  Modified:    .        build.xml
               docs/manual/CoreTasks conditions.html
               src/main/org/apache/tools/ant/types defaults.properties
  Added:       src/main/org/apache/tools/ant/taskdefs/condition
                        IsReachable.java
               src/etc/testcases/taskdefs/conditions isreachable.xml
               src/testcases/org/apache/tools/ant/taskdefs/condition
                        IsReachableTest.java
  Removed:     src/main/org/apache/tools/ant/taskdefs/optional/condition
                        IsPingable.java
  Log:
  Moving isreachable to reflect on the new method. On java <=1.4; if the 
hostname can be resolved then we are reachable.
  All tests run against localhost. This *should* work everywhere, but no doubt 
someone with a confused /etc/hosts or no IPv4 stack will have different 
opinions.
  
  Revision  Changes    Path
  1.463     +281 -281  ant/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/ant/build.xml,v
  retrieving revision 1.462
  retrieving revision 1.463
  diff -u -r1.462 -r1.463
  --- build.xml 9 Mar 2005 22:56:38 -0000       1.462
  +++ build.xml 10 Mar 2005 23:20:02 -0000      1.463
  @@ -31,6 +31,7 @@
   
     <property name="ant.package" value="org/apache/tools/ant"/>
     <property name="taskdefs.package" value="${ant.package}/taskdefs"/>
  +  <property name="condition.package" value="${taskdefs.package}/condition"/>
     <property name="optional.package" value="${taskdefs.package}/optional"/>
     <property name="optional.condition.package" 
value="${optional.package}/condition"/>
     <property name="type.package" value="${ant.package}/types"/>
  @@ -56,7 +57,7 @@
     <property name="junit.fork" value="false"/>
     <property name="junit.filtertrace" value="off"/>
     <property name="junit.summary" value="no"/>
  -  <property name="test.haltonfailure" value="yes" />
  +  <property name="test.haltonfailure" value="yes"/>
     <property name="junit.forkmode" value="once"/>
     <property name="unfiltered.files" 
value="**/*.gif,**/*.jpg,**/*.ico,**/*.pdf,**/*.zip"/>
   
  @@ -113,13 +114,13 @@
   
     <!-- turn this path into a string which is passed to the tests -->
     <property name="tests-classpath.value"
  -            refid="tests-classpath"/>
  +    refid="tests-classpath"/>
   
  - <!--
  -       ===================================================================
  -         Set up properties for the distribution area
  -       ===================================================================
  -  -->
  +  <!--
  +        ===================================================================
  +          Set up properties for the distribution area
  +        ===================================================================
  +   -->
     <property name="dist.name" value="apache-${name}-${version}"/>
     <property name="dist.base" value="distribution"/>
     <property name="dist.dir" value="dist"/>
  @@ -157,7 +158,6 @@
   
     <selector id="needs.jdk1.5+">
       <or>
  -      <filename name="${optional.condition.package}/IsPingable*"/>
         <filename name="${taskdefs.package}/AptTest*"/>
       </or>
     </selector>
  @@ -166,10 +166,10 @@
          but not all of them -->
     <selector id="not.in.kaffe">
       <or>
  -      <filename name="${optional.condition.package}/IsPingable*"/>
  +      <filename name="${condition.package}/IsReachable*"/>
       </or>
     </selector>
  -  
  +
     <selector id="needs.sun.uue">
       <filename name="${ant.package}/taskdefs/email/UUMailer*"/>
     </selector>
  @@ -312,7 +312,7 @@
     <selector id="needs.jai">
       <or>
         <filename name="${optional.package}/image/*"/>
  -      <filename name="${ant.package}/types/optional/image/*"/>
  +      <filename name="${optional.type.package}/image/*"/>
       </or>
     </selector>
   
  @@ -392,110 +392,110 @@
       <available property="jdk1.5+" classname="java.lang.Readable"/>
       <available property="kaffe" classname="kaffe.util.NotImplemented"/>
       <available property="bsf.present"
  -               classname="org.apache.bsf.BSFManager"
  -               classpathref="classpath"/>
  +      classname="org.apache.bsf.BSFManager"
  +      classpathref="classpath"/>
       <available property="netrexx.present"
  -               classname="netrexx.lang.Rexx"
  -               classpathref="classpath"/>
  +      classname="netrexx.lang.Rexx"
  +      classpathref="classpath"/>
       <available property="trax.present"
  -               classname="javax.xml.transform.Transformer"
  -               classpathref="classpath"/>
  +      classname="javax.xml.transform.Transformer"
  +      classpathref="classpath"/>
       <condition property="trax.impl.present">
         <or>
           <and>
             <isset property="javax.xml.transform.TransformerFactory"/>
             <available classname="${javax.xml.transform.TransformerFactory}"
  -                     classpathref="classpath"/>
  +            classpathref="classpath"/>
           </and>
           <available 
resource="META-INF/services/javax.xml.transform.TransformerFactory"/>
         </or>
       </condition>
       <available property="xslp.present"
  -               classname="com.kvisco.xsl.XSLProcessor"
  -               classpathref="classpath"/>
  +      classname="com.kvisco.xsl.XSLProcessor"
  +      classpathref="classpath"/>
       <available property="apache.resolver.present"
  -               classname="org.apache.xml.resolver.tools.CatalogResolver"
  -               classpathref="classpath" />
  +      classname="org.apache.xml.resolver.tools.CatalogResolver"
  +      classpathref="classpath"/>
       <available property="xalan.present"
  -               classname="org.apache.xalan.xslt.XSLTProcessorFactory"
  -               classpathref="classpath"/>
  +      classname="org.apache.xalan.xslt.XSLTProcessorFactory"
  +      classpathref="classpath"/>
       <available property="xalan2.present"
  -               classname="org.apache.xalan.transformer.TransformerImpl"
  -               classpathref="classpath"/>
  +      classname="org.apache.xalan.transformer.TransformerImpl"
  +      classpathref="classpath"/>
       <available property="ejb.ejbc.present"
  -               classname="weblogic.ejbc"
  -               classpathref="classpath"/>
  +      classname="weblogic.ejbc"
  +      classpathref="classpath"/>
       <available property="ejb.DDCreator.present"
  -               classname="weblogic.ejb.utils.DDCreator"
  -               classpathref="classpath"/>
  +      classname="weblogic.ejb.utils.DDCreator"
  +      classpathref="classpath"/>
       <available property="ejb.wls.present"
  -               classname="weblogic.Server"
  -               classpathref="classpath"/>
  +      classname="weblogic.Server"
  +      classpathref="classpath"/>
       <available property="junit.present"
  -               classname="junit.framework.TestCase"
  -               classpathref="classpath"/>
  +      classname="junit.framework.TestCase"
  +      classpathref="classpath"/>
       <available property="commons.net.present"
  -               classname="org.apache.commons.net.ftp.FTPClient"
  -               classpathref="classpath"/>
  +      classname="org.apache.commons.net.ftp.FTPClient"
  +      classpathref="classpath"/>
       <available property="starteam.present"
  -               classname="com.starbase.util.Platform"
  -               classpathref="classpath"/>
  +      classname="com.starbase.util.Platform"
  +      classpathref="classpath"/>
       <available property="antlr.present"
  -               classname="antlr.Tool"
  -               classpathref="classpath"/>
  +      classname="antlr.Tool"
  +      classpathref="classpath"/>
       <available property="vaj.present"
  -               classname="com.ibm.ivj.util.base.Workspace"
  -               classpathref="classpath"/>
  +      classname="com.ibm.ivj.util.base.Workspace"
  +      classpathref="classpath"/>
       <available property="stylebook.present"
  -               classname="org.apache.stylebook.Engine"
  -               classpathref="classpath"/>
  +      classname="org.apache.stylebook.Engine"
  +      classpathref="classpath"/>
       <available property="apache.regexp.present"
  -               classname="org.apache.regexp.RE"
  -               classpathref="classpath"/>
  +      classname="org.apache.regexp.RE"
  +      classpathref="classpath"/>
       <available property="apache.oro.present"
  -               classname="org.apache.oro.text.regex.Perl5Matcher"
  -               classpathref="classpath"/>
  +      classname="org.apache.oro.text.regex.Perl5Matcher"
  +      classpathref="classpath"/>
       <available property="jmf.present"
  -               classname="javax.sound.sampled.Clip"
  -               classpathref="classpath"/>
  +      classname="javax.sound.sampled.Clip"
  +      classpathref="classpath"/>
       <available property="jai.present"
  -               classname="javax.media.jai.JAI"
  -               classpathref="classpath"/>
  +      classname="javax.media.jai.JAI"
  +      classpathref="classpath"/>
       <available property="icontract.present"
  -               classname="com.reliablesystems.iContract.IContracted"
  -               classpathref="classpath"/>
  +      classname="com.reliablesystems.iContract.IContracted"
  +      classpathref="classpath"/>
       <available property="jdepend.present"
  -               classname="jdepend.framework.JDepend"
  -               classpathref="classpath"/>
  +      classname="jdepend.framework.JDepend"
  +      classpathref="classpath"/>
       <available property="log4j.present"
  -               classname="org.apache.log4j.Logger"
  -               classpathref="classpath"/>
  +      classname="org.apache.log4j.Logger"
  +      classpathref="classpath"/>
       <available property="commons.logging.present"
  -               classname="org.apache.commons.logging.LogFactory"
  -               classpathref="classpath"/>
  +      classname="org.apache.commons.logging.LogFactory"
  +      classpathref="classpath"/>
       <available property="xalan.envcheck"
  -               classname="org.apache.xalan.xslt.EnvironmentCheck"
  -               classpathref="classpath"/>
  +      classname="org.apache.xalan.xslt.EnvironmentCheck"
  +      classpathref="classpath"/>
       <available property="which.present"
  -               classname="org.apache.env.Which"
  -               classpathref="classpath"/>
  +      classname="org.apache.env.Which"
  +      classpathref="classpath"/>
   
       <available property="xerces.present"
  -               classname="org.apache.xerces.parsers.SAXParser"
  -               classpathref="classpath"/>
  +      classname="org.apache.xerces.parsers.SAXParser"
  +      classpathref="classpath"/>
       <available property="bcel.present"
  -               classname="org.apache.bcel.Constants"
  -               classpathref="classpath"/>
  +      classname="org.apache.bcel.Constants"
  +      classpathref="classpath"/>
       <available property="sunuue.present"
  -               classname="sun.misc.UUEncoder"
  -               classpathref="classpath"/>
  +      classname="sun.misc.UUEncoder"
  +      classpathref="classpath"/>
   
       <condition property="javamail.complete">
         <and>
           <available classname="javax.activation.DataHandler"
  -                   classpathref="classpath"/>
  +          classpathref="classpath"/>
           <available classname="javax.mail.Transport"
  -                   classpathref="classpath"/>
  +          classpathref="classpath"/>
         </and>
       </condition>
   
  @@ -528,10 +528,10 @@
         <or>
           <!-- relative paths in CLASSPATH -->
           <contains string="${java.class.path}"
  -                  substring="${build.tests}"/>
  +          substring="${build.tests}"/>
           <!-- absolute paths in CLASSPATH -->
           <contains string="${java.class.path}"
  -                  substring="${build.tests.resolved}"/>
  +          substring="${build.tests.resolved}"/>
           <istrue value="${junit.fork}"/>
         </or>
       </condition>
  @@ -549,7 +549,7 @@
             <isset property="kaffe"/>
           </not>
           <available classname="javax.swing.ImageIcon"
  -                   classpathref="classpath"/>
  +          classpathref="classpath"/>
         </or>
       </condition>
   
  @@ -565,7 +565,7 @@
   
       <condition property="wsdl.found">
         <or>
  -        <available file="wsdl"     filepath="${env.PATH}"/>
  +        <available file="wsdl" filepath="${env.PATH}"/>
           <available file="wsdl.exe" filepath="${env.PATH}"/>
           <available file="wsdl.exe" filepath="${env.Path}"/>
         </or>
  @@ -573,8 +573,8 @@
       <echo level="verbose"> wsdl.found=${wsdl.found}</echo>
       <condition property="csc.found">
         <or>
  -        <available file="mcs"     filepath="${env.PATH}"/>
  -        <available file="csc"     filepath="${env.PATH}"/>
  +        <available file="mcs" filepath="${env.PATH}"/>
  +        <available file="csc" filepath="${env.PATH}"/>
           <available file="csc.exe" filepath="${env.PATH}"/>
           <available file="csc.exe" filepath="${env.Path}"/>
         </or>
  @@ -589,17 +589,17 @@
       <echo level="verbose"> dotnetapps.found=${dotnetapps.found}</echo>
   
       <available property="rhino.present"
  -               classname="org.mozilla.javascript.Scriptable"
  -               classpathref="classpath"/>
  +      classname="org.mozilla.javascript.Scriptable"
  +      classpathref="classpath"/>
       <available property="beanshell.present"
  -               classname="bsh.StringUtil"
  -               classpathref="classpath"/>
  +      classname="bsh.StringUtil"
  +      classpathref="classpath"/>
       <available property="xerces1.present"
  -               classname="org.apache.xerces.framework.XMLParser"
  -               classpathref="classpath"/>
  +      classname="org.apache.xerces.framework.XMLParser"
  +      classpathref="classpath"/>
       <available property="jsch.present"
  -               classname="com.jcraft.jsch.Session"
  -               classpathref="classpath"/>
  +      classname="com.jcraft.jsch.Session"
  +      classpathref="classpath"/>
   
       <condition property="build.compiler" value="classic">
         <not>
  @@ -646,19 +646,19 @@
          ===================================================================
     -->
     <target name="build"
  -          depends="prepare, check_for_optional_packages"
  -          description="--> compiles the source code">
  +    depends="prepare, check_for_optional_packages"
  +    description="--> compiles the source code">
       <mkdir dir="${build.dir}"/>
       <mkdir dir="${build.classes}"/>
       <mkdir dir="${build.lib}"/>
   
       <javac srcdir="${java.dir}"
  -           destdir="${build.classes}"
  -           debug="${debug}"
  -           deprecation="${deprecation}"
  -           target="${javac.target}"
  -           source="${javac.source}"
  -           optimize="${optimize}" >
  +      destdir="${build.classes}"
  +      debug="${debug}"
  +      deprecation="${deprecation}"
  +      target="${javac.target}"
  +      source="${javac.source}"
  +      optimize="${optimize}">
         <classpath refid="classpath"/>
   
         <selector id="conditional-patterns">
  @@ -677,12 +677,12 @@
               <selector refid="needs.apache-resolver" 
unless="apache.resolver.present"/>
               <selector refid="needs.junit" unless="junit.present"/>
               <selector refid="needs.apache-regexp"
  -                      unless="apache.regexp.present"/>
  +              unless="apache.regexp.present"/>
               <selector refid="needs.apache-oro" unless="apache.oro.present"/>
               <selector refid="needs.apache-bcel" unless="bcel.present"/>
               <selector refid="needs.apache-log4j" unless="log4j.present"/>
               <selector refid="needs.commons-logging"
  -                      unless="commons.logging.present"/>
  +              unless="commons.logging.present"/>
               <selector refid="needs.apache-bsf" unless="bsf.present"/>
               <selector refid="needs.stylebook" unless="stylebook.present"/>
               <selector refid="needs.javamail" unless="javamail.complete"/>
  @@ -690,7 +690,7 @@
               <selector refid="needs.netrexx" unless="netrexx.present"/>
               <selector refid="needs.weblogic.ejbc" unless="ejb.ejbc.present"/>
               <selector refid="needs.weblogic.ddcreator"
  -                      unless="ejb.DDCreator.present"/>
  +              unless="ejb.DDCreator.present"/>
               <selector refid="needs.weblogic.server" 
unless="ejb.wls.present"/>
               <selector refid="needs.commons-net" 
unless="commons.net.present"/>
               <selector refid="needs.starteam" unless="starteam.present"/>
  @@ -699,7 +699,7 @@
               <selector refid="needs.jmf" unless="jmf.present"/>
               <selector refid="needs.jai" unless="jai.present"/>
               <selector refid="needs.jdepend" unless="jdepend.present"/>
  -            <selector refid="needs.swing"  unless="swing.present"/>
  +            <selector refid="needs.swing" unless="swing.present"/>
               <selector refid="needs.jsch" unless="jsch.present"/>
               <selector refid="needs.xmlschema" unless="xmlschema.present"/>
             </or>
  @@ -715,7 +715,7 @@
       </copy>
   
       <copy todir="${build.classes}"
  -          overwrite="true" encoding="UTF-8">
  +      overwrite="true" encoding="UTF-8">
         <fileset dir="${java.dir}">
           <include name="**/version.txt"/>
           <include name="**/defaultManifest.mf"/>
  @@ -724,10 +724,10 @@
       </copy>
   
       <copy todir="${build.classes}/${optional.package}/junit/xsl">
  -       <fileset dir="${etc.dir}">
  -         <include name="junit-frames.xsl"/>
  -         <include name="junit-noframes.xsl"/>
  -       </fileset>
  +      <fileset dir="${etc.dir}">
  +        <include name="junit-frames.xsl"/>
  +        <include name="junit-noframes.xsl"/>
  +      </fileset>
       </copy>
     </target>
   
  @@ -737,8 +737,8 @@
          ===================================================================
     -->
     <target name="jars"
  -          depends="build"
  -          description="--> creates the Apache Ant jars">
  +    depends="build"
  +    description="--> creates the Apache Ant jars">
   
       <copy todir="${build.dir}">
         <fileset dir=".">
  @@ -755,24 +755,24 @@
       <manifest file="${manifest.tmp}">
         <section name="${optional.package}/">
           <attribute name="Extension-name"
  -                   value="org.apache.tools.ant"/>
  +          value="org.apache.tools.ant"/>
           <attribute name="Specification-Title"
  -                   value="Apache Ant"/>
  +          value="Apache Ant"/>
           <attribute name="Specification-Version"
  -                   value="${manifest-version}"/>
  +          value="${manifest-version}"/>
           <attribute name="Specification-Vendor"
  -                   value="Apache Software Foundation"/>
  +          value="Apache Software Foundation"/>
           <attribute name="Implementation-Title"
  -                   value="org.apache.tools.ant"/>
  +          value="org.apache.tools.ant"/>
           <attribute name="Implementation-Version"
  -                   value="${manifest-version}"/>
  +          value="${manifest-version}"/>
           <attribute name="Implementation-Vendor"
  -                   value="Apache Software Foundation"/>
  +          value="Apache Software Foundation"/>
         </section>
       </manifest>
   
       <jar destfile="${build.lib}/${name}-launcher.jar"
  -         basedir="${build.classes}">
  +      basedir="${build.classes}">
         <selector refid="ant.launcher"/>
         <manifest>
           <attribute name="Main-Class" 
value="org.apache.tools.ant.launch.Launcher"/>
  @@ -780,8 +780,8 @@
       </jar>
   
       <jar destfile="${build.lib}/${name}.jar"
  -         basedir="${build.classes}"
  -         manifest="${manifest}">
  +      basedir="${build.classes}"
  +      manifest="${manifest}">
         <not>
           <selector id="non-core">
             <or>
  @@ -807,19 +807,19 @@
         <manifest>
           <section name="${ant.package}/">
             <attribute name="Extension-name"
  -                     value="org.apache.tools.ant"/>
  +            value="org.apache.tools.ant"/>
             <attribute name="Specification-Title"
  -                     value="Apache Ant"/>
  +            value="Apache Ant"/>
             <attribute name="Specification-Version"
  -                     value="${manifest-version}"/>
  +            value="${manifest-version}"/>
             <attribute name="Specification-Vendor"
  -                     value="Apache Software Foundation"/>
  +            value="Apache Software Foundation"/>
             <attribute name="Implementation-Title"
  -                     value="org.apache.tools.ant"/>
  +            value="org.apache.tools.ant"/>
             <attribute name="Implementation-Version"
  -                     value="${manifest-version}"/>
  +            value="${manifest-version}"/>
             <attribute name="Implementation-Vendor"
  -                     value="Apache Software Foundation"/>
  +            value="Apache Software Foundation"/>
           </section>
         </manifest>
   
  @@ -829,8 +829,8 @@
       </jar>
   
       <jar destfile="${build.lib}/${bootstrap.jar}"
  -         basedir="${build.classes}"
  -         manifest="${manifest}">
  +      basedir="${build.classes}"
  +      manifest="${manifest}">
         <include name="${ant.package}/Main.class"/>
         <metainf dir="${build.dir}">
           <include name="LICENSE.txt"/>
  @@ -838,13 +838,13 @@
         </metainf>
         <manifest>
           <attribute name="Class-Path"
  -                   value="ant.jar xml-apis.jar xercesImpl.jar xalan.jar"/>
  +          value="ant.jar xml-apis.jar xercesImpl.jar xalan.jar"/>
         </manifest>
       </jar>
   
       <jar destfile="${build.lib}/ant-nodeps.jar"
  -         basedir="${build.classes}"
  -         manifest="${manifest.tmp}">
  +      basedir="${build.classes}"
  +      manifest="${manifest.tmp}">
         <and>
           <selector refid="non-core"/>
           <not>
  @@ -922,11 +922,11 @@
       <optional-jar dep="jdepend"/>
   
       <jar destfile="${build.lib}/${optional.jars.prefix}-weblogic.jar"
  -         basedir="${build.classes}"
  -         manifest="${manifest.tmp}">
  +      basedir="${build.classes}"
  +      manifest="${manifest.tmp}">
         <or>
           <selector refid="needs.weblogic.ejbc"/>
  -        <selector refid="needs.weblogic.ddcreator" />
  +        <selector refid="needs.weblogic.ddcreator"/>
           <selector refid="needs.weblogic.server"/>
         </or>
       </jar>
  @@ -935,15 +935,15 @@
   
     <!--   Creates jar of test utility classes -->
     <target name="test-jar"
  -          depends="compile-tests"
  -          description="--> creates the Apache Ant Test Utilties jar">
  +    depends="compile-tests"
  +    description="--> creates the Apache Ant Test Utilties jar">
   
       <fail unless="junit.present">
         We cannot build the test jar unless JUnit is present,
         as JUnit is needed to compile the test classes.
       </fail>
       <jar destfile="${build.lib}/${name}-testutil.jar"
  -         basedir="${build.tests}">
  +      basedir="${build.tests}">
         <patternset refid="useful.tests"/>
       </jar>
     </target>
  @@ -954,8 +954,8 @@
          ===================================================================
     -->
     <target name="dist-lite"
  -          depends="jars"
  -          description="--> creates a minimum distribution to run Apache Ant">
  +    depends="jars"
  +    description="--> creates a minimum distribution to run Apache Ant">
   
       <mkdir dir="${dist.dir}"/>
       <mkdir dir="${dist.bin}"/>
  @@ -986,25 +986,25 @@
       </fixcrlf>
   
       <chmod perm="ugo+rx" dir="${dist.dir}" type="dir" includes="**"
  -           failonerror="${chmod.fail}"/>
  +      failonerror="${chmod.fail}"/>
       <chmod perm="ugo+r" dir="${dist.dir}" type="file" includes="**"
  -           failonerror="${chmod.fail}" maxparallel="${chmod.maxparallel}"/>
  +      failonerror="${chmod.fail}" maxparallel="${chmod.maxparallel}"/>
       <chmod perm="ugo+x" type="file" failonerror="${chmod.fail}">
  -       <fileset dir="${dist.bin}">
  -         <include name="**/ant"/>
  -         <include name="**/antRun"/>
  -         <include name="**/*.pl"/>
  -         <include name="**/*.py"/>
  -       </fileset>
  +      <fileset dir="${dist.bin}">
  +        <include name="**/ant"/>
  +        <include name="**/antRun"/>
  +        <include name="**/*.pl"/>
  +        <include name="**/*.py"/>
  +      </fileset>
       </chmod>
   
     </target>
   
  - <!--
  -       ===================================================================
  -         Create the complete distribution
  -       ===================================================================
  -  -->
  +  <!--
  +        ===================================================================
  +          Create the complete distribution
  +        ===================================================================
  +   -->
     <target name="dist" description="--> creates a complete distribution">
       <antcall inheritAll="false" target="internal_dist">
         <param name="dist.dir" value="${dist.name}"/>
  @@ -1055,34 +1055,34 @@
       </copy>
   
       <chmod perm="ugo+rx" dir="${dist.dir}" type="dir" includes="**"
  -           failonerror="${chmod.fail}"/>
  +      failonerror="${chmod.fail}"/>
       <chmod perm="ugo+r" dir="${dist.dir}" type="file" includes="**"
  -           failonerror="${chmod.fail}" maxparallel="${chmod.maxparallel}"/>
  +      failonerror="${chmod.fail}" maxparallel="${chmod.maxparallel}"/>
       <chmod perm="ugo+x" type="file" failonerror="${chmod.fail}">
  -       <fileset dir="${dist.bin}">
  -         <include name="**/ant"/>
  -         <include name="**/antRun"/>
  -         <include name="**/*.pl"/>
  -         <include name="**/*.py"/>
  -       </fileset>
  +      <fileset dir="${dist.bin}">
  +        <include name="**/ant"/>
  +        <include name="**/antRun"/>
  +        <include name="**/*.pl"/>
  +        <include name="**/*.py"/>
  +      </fileset>
       </chmod>
   
       <!-- publish some useful stylesheets -->
       <copy todir="${dist.etc}">
  -        <fileset dir="${etc.dir}">
  -            <include name="junit-frames.xsl"/>
  -            <include name="junit-noframes.xsl"/>
  -            <include name="junit-frames-xalan1.xsl"/>
  -            <include name="coverage-frames.xsl"/>
  -            <include name="maudit-frames.xsl"/>
  -            <include name="mmetrics-frames.xsl"/>
  -            <include name="changelog.xsl"/>
  -            <include name="jdepend.xsl"/>
  -            <include name="jdepend-frames.xsl"/>
  -            <include name="checkstyle/*.xsl"/>
  -            <include name="log.xsl"/>
  -            <include name="tagdiff.xsl"/>
  -        </fileset>
  +      <fileset dir="${etc.dir}">
  +        <include name="junit-frames.xsl"/>
  +        <include name="junit-noframes.xsl"/>
  +        <include name="junit-frames-xalan1.xsl"/>
  +        <include name="coverage-frames.xsl"/>
  +        <include name="maudit-frames.xsl"/>
  +        <include name="mmetrics-frames.xsl"/>
  +        <include name="changelog.xsl"/>
  +        <include name="jdepend.xsl"/>
  +        <include name="jdepend-frames.xsl"/>
  +        <include name="checkstyle/*.xsl"/>
  +        <include name="log.xsl"/>
  +        <include name="tagdiff.xsl"/>
  +      </fileset>
         <fileset dir="${build.lib}">
           <include name="${bootstrap.jar}"/>
         </fileset>
  @@ -1109,7 +1109,7 @@
          ===================================================================
     -->
     <target name="src-dist"
  -          description="--> creates a source distribution">
  +    description="--> creates a source distribution">
   
       <mkdir dir="${src.dist.dir}"/>
   
  @@ -1167,16 +1167,16 @@
       </fixcrlf>
   
       <chmod perm="ugo+x" dir="${src.dist.dir}" type="dir"
  -           failonerror="${chmod.fail}"/>
  +      failonerror="${chmod.fail}"/>
       <chmod perm="ugo+r" dir="${src.dist.dir}" failonerror="${chmod.fail}"/>
       <chmod perm="ugo+x" failonerror="${chmod.fail}">
  -       <fileset dir="${src.dist.dir}">
  -         <include name="**/.sh"/>
  -         <include name="**/.pl"/>
  -         <include name="**/.py"/>
  -         <include name="**/ant"/>
  -         <include name="**/antRun"/>
  -       </fileset>
  +      <fileset dir="${src.dist.dir}">
  +        <include name="**/.sh"/>
  +        <include name="**/.pl"/>
  +        <include name="**/.py"/>
  +        <include name="**/ant"/>
  +        <include name="**/antRun"/>
  +      </fileset>
       </chmod>
   
     </target>
  @@ -1187,7 +1187,7 @@
          ===================================================================
     -->
     <target name="main_distribution"
  -          description="--> creates the zip and tar distributions">
  +    description="--> creates the zip and tar distributions">
       <delete dir="${dist.name}"/>
       <mkdir dir="${dist.base}"/>
       <mkdir dir="${dist.base}/src"/>
  @@ -1212,7 +1212,7 @@
         </fileset>
       </zip>
       <tar longfile="gnu"
  -         destfile="${dist.base}/bin/${dist.name}-bin.tar">
  +      destfile="${dist.base}/bin/${dist.name}-bin.tar">
         <tarfileset dir="${dist.name}/.." mode="755" username="ant" 
group="ant">
           <include name="${dist.name}/bin/ant"/>
           <include name="${dist.name}/bin/antRun"/>
  @@ -1228,9 +1228,9 @@
         </tarfileset>
       </tar>
       <gzip destfile="${dist.base}/bin/${dist.name}-bin.tar.gz"
  -          src="${dist.base}/bin/${dist.name}-bin.tar"/>
  +      src="${dist.base}/bin/${dist.name}-bin.tar"/>
       <bzip2 destfile="${dist.base}/bin/${dist.name}-bin.tar.bz2"
  -           src="${dist.base}/bin/${dist.name}-bin.tar"/>
  +      src="${dist.base}/bin/${dist.name}-bin.tar"/>
       <delete file="${dist.base}/bin/${dist.name}-bin.tar"/>
       <delete dir="${dist.name}"/>
       <checksum fileext=".md5">
  @@ -1256,7 +1256,7 @@
         </fileset>
       </zip>
       <tar longfile="gnu"
  -         destfile="${dist.base}/src/${dist.name}-src.tar" >
  +      destfile="${dist.base}/src/${dist.name}-src.tar">
         <tarfileset dir="${dist.name}/.." mode="755" username="ant" 
group="ant">
           <include name="${dist.name}/bootstrap.sh"/>
           <include name="${dist.name}/build.sh"/>
  @@ -1268,9 +1268,9 @@
         </tarfileset>
       </tar>
       <gzip destfile="${dist.base}/src/${dist.name}-src.tar.gz"
  -          src="${dist.base}/src/${dist.name}-src.tar"/>
  +      src="${dist.base}/src/${dist.name}-src.tar"/>
       <bzip2 destfile="${dist.base}/src/${dist.name}-src.tar.bz2"
  -           src="${dist.base}/src/${dist.name}-src.tar"/>
  +      src="${dist.base}/src/${dist.name}-src.tar"/>
       <delete file="${dist.base}/src/${dist.name}-src.tar"/>
       <delete dir="${dist.name}"/>
       <checksum fileext=".md5">
  @@ -1283,7 +1283,7 @@
     </target>
   
     <target name="distribution" depends="main_distribution"
  -          description="--> creates the full Apache Ant distribution">
  +    description="--> creates the full Apache Ant distribution">
     </target>
   
   
  @@ -1293,7 +1293,7 @@
          ===================================================================
     -->
     <target name="clean"
  -          description="--> cleans up build and dist directories">
  +    description="--> cleans up build and dist directories">
       <delete dir="${build.dir}"/>
       <delete dir="${dist.base}"/>
       <delete dir="${dist.dir}"/>
  @@ -1308,8 +1308,8 @@
          ===================================================================
     -->
     <target name="allclean"
  -          depends="clean"
  -          description="--> cleans up everything">
  +    depends="clean"
  +    description="--> cleans up everything">
       <delete file="${bootstrap.dir}/bin/antRun"/>
       <delete file="${bootstrap.dir}/bin/antRun.bat"/>
       <delete file="${bootstrap.dir}/bin/*.pl"/>
  @@ -1340,28 +1340,28 @@
     -->
     <target name="javadoc_check">
       <uptodate property="javadoc.notrequired"
  -              targetfile="${build.javadocs}/packages.html" >
  -        <srcfiles dir= "${java.dir}" includes="**/*.java"/>
  +      targetfile="${build.javadocs}/packages.html">
  +      <srcfiles dir="${java.dir}" includes="**/*.java"/>
       </uptodate>
       <uptodate property="tests.javadoc.notrequired"
  -              targetfile="${build.tests.javadocs}/packages.html" >
  -      <srcfiles dir= "${tests.dir}">
  +      targetfile="${build.tests.javadocs}/packages.html">
  +      <srcfiles dir="${tests.dir}">
           <patternset refid="useful.tests"/>
         </srcfiles>
       </uptodate>
     </target>
   
     <target name="javadocs" depends="prepare, javadoc_check"
  -          unless="javadoc.notrequired"
  -          description="--> creates the API documentation">
  +    unless="javadoc.notrequired"
  +    description="--> creates the API documentation">
       <mkdir dir="${build.javadocs}"/>
       <javadoc useexternalfile="yes"
  -             destdir="${build.javadocs}"
  -             author="true"
  -             version="true"
  -             locale="en"
  -             windowtitle="${Name} API"
  -             doctitle="${Name}">
  +      destdir="${build.javadocs}"
  +      author="true"
  +      version="true"
  +      locale="en"
  +      windowtitle="${Name} API"
  +      doctitle="${Name}">
   
         <packageset dir="${java.dir}"/>
   
  @@ -1383,16 +1383,16 @@
     </target>
   
     <target name="test-javadocs" depends="prepare, javadoc_check"
  -          unless="tests.javadoc.notrequired"
  -          description="--> creates the API documentation for test utilities">
  +    unless="tests.javadoc.notrequired"
  +    description="--> creates the API documentation for test utilities">
       <mkdir dir="${build.tests.javadocs}"/>
       <javadoc useexternalfile="yes"
  -             destdir="${build.tests.javadocs}"
  -             author="true"
  -             version="true"
  -             locale="en"
  -             windowtitle="${Name} Test Utilities"
  -             doctitle="${Name}">
  +      destdir="${build.tests.javadocs}"
  +      author="true"
  +      version="true"
  +      locale="en"
  +      windowtitle="${Name} Test Utilities"
  +      doctitle="${Name}">
   
         <fileset dir="${tests.dir}">
           <patternset refid="useful.tests"/>
  @@ -1411,11 +1411,11 @@
       <mkdir dir="${build.tests}"/>
   
       <javac srcdir="${tests.dir}"
  -           destdir="${build.tests}"
  -           debug="${debug}"
  -           target="${javac.target}"
  -           source="${javac.source}"
  -           deprecation="${deprecation}" >
  +      destdir="${build.tests}"
  +      debug="${debug}"
  +      target="${javac.target}"
  +      source="${javac.source}"
  +      deprecation="${deprecation}">
         <classpath refid="tests-classpath"/>
   
         <selector refid="conditional-patterns"/>
  @@ -1423,16 +1423,16 @@
   
       <!-- Used by AntlibTest.testAntlibResource: -->
       <jar 
jarfile="${build.tests}/org/apache/tools/ant/taskdefs/test2-antlib.jar">
  -        <zipfileset dir="${tests.etc.dir}" 
fullpath="taskdefs/test.antlib.xml">
  -            <include name="taskdefs/test2.antlib.xml"/>
  -        </zipfileset>
  +      <zipfileset dir="${tests.etc.dir}" fullpath="taskdefs/test.antlib.xml">
  +        <include name="taskdefs/test2.antlib.xml"/>
  +      </zipfileset>
       </jar>
     </target>
   
     <target name="dump-info" depends="dump-sys-properties,run-which"/>
   
     <target name="dump-sys-properties" unless="which.present"
  -          depends="xml-check">
  +    depends="xml-check">
       <echo message="java.vm.info=${java.vm.info}"/>
       <echo message="java.vm.name=${java.vm.name}"/>
       <echo message="java.vm.vendor=${java.vm.vendor}"/>
  @@ -1446,27 +1446,27 @@
   
     <!-- helper class from Xalan2 to check for jar versioning of xml/xsl 
processors -->
     <target name="xml-check" depends="check_for_optional_packages"
  -          if="xalan.envcheck" unless="which.present">
  -      <java classname="org.apache.xalan.xslt.EnvironmentCheck"/>
  +    if="xalan.envcheck" unless="which.present">
  +    <java classname="org.apache.xalan.xslt.EnvironmentCheck"/>
     </target>
   
     <target name="run-which" depends="check_for_optional_packages"
  -          if="which.present">
  -      <java classname="org.apache.env.Which" taskname="which"/>
  +    if="which.present">
  +    <java classname="org.apache.env.Which" taskname="which"/>
     </target>
   
     <!-- test to see if we are online or not. can take a while when we are off 
line, so
       setting the property is a good shortcut-->
     <target name="probe-offline">
  -      <condition property="offline">
  +    <condition property="offline">
         <or>
           <isset property="offline"/>
           <not>
  -          <http  url="http://www.apache.org/"/>
  +          <http url="http://www.apache.org/"/>
           </not>
         </or>
       </condition>
  -    <echo level="verbose" > offline=${offline}</echo>
  +    <echo level="verbose"> offline=${offline}</echo>
     </target>
   
     <!--
  @@ -1489,10 +1489,10 @@
       </condition>
   
       <junit printsummary="${junit.summary}" 
haltonfailure="${test.haltonfailure}"
  -           filtertrace="${junit.filtertrace}"
  -           fork="${junit.fork}" forkmode="${junit.forkmode}"
  -           failureproperty="tests.failed">
  -<!--      <jvmarg value="-classic"/> -->
  +      filtertrace="${junit.filtertrace}"
  +      fork="${junit.fork}" forkmode="${junit.forkmode}"
  +      failureproperty="tests.failed">
  +      <!--      <jvmarg value="-classic"/> -->
         <classpath refid="tests-classpath"/>
   
         <sysproperty key="ant.home" value="${ant.home}"/>
  @@ -1500,7 +1500,7 @@
         <sysproperty key="offline" value="${offline}"/>
         <sysproperty key="build.tests.value" value="${build.tests.value}"/>
         <sysproperty key="tests-classpath.value"
  -                   value="${tests-classpath.value}"/>
  +        value="${tests-classpath.value}"/>
         <sysproperty key="root" file="${basedir}"/>
         <sysproperty key="build.compiler" value="${build.compiler}"/>
   
  @@ -1540,102 +1540,102 @@
             <!-- runtime dependencies that are different from compile
                  time dependencies -->
             <exclude name="${optional.package}/ReplaceRegExpTest.java"
  -                   unless="some.regexp.support"/>
  +            unless="some.regexp.support"/>
             <exclude name="${optional.package}/sitraka/*.java"
  -                   unless="some.regexp.support"/>
  +            unless="some.regexp.support"/>
             <exclude 
name="${ant.package}/types/selectors/ContainsRegexpTest.java"
  -                   unless="some.regexp.support"/>
  +            unless="some.regexp.support"/>
             <exclude 
name="${ant.package}/types/mappers/RegexpPatternMapperTest.java"
  -                   unless="some.regexp.support"/>
  +            unless="some.regexp.support"/>
             <exclude name="${optional.package}/Rhino*.java"
  -                   unless="bsf.present"/>
  +            unless="bsf.present"/>
             <exclude name="${optional.package}/Rhino*.java"
  -                   unless="rhino.present"/>
  +            unless="rhino.present"/>
             <exclude name="${optional.package}/script/*.java"
  -                   unless="bsf.present"/>
  +            unless="bsf.present"/>
             <exclude name="${optional.package}/script/*.java"
  -                   unless="rhino.present"/>
  +            unless="rhino.present"/>
             <exclude name="${optional.package}/BeanShellScriptTest.java"
  -                   unless="bsf.present"/>
  +            unless="bsf.present"/>
             <exclude name="${optional.package}/BeanShellScriptTest.java"
  -                   unless="beanshell.present"/>
  +            unless="beanshell.present"/>
             <exclude name="${optional.type.package}/Script*.java"
  -                   unless="bsf.present"/>
  +            unless="bsf.present"/>
             <exclude name="${optional.type.package}/Script*.java"
  -                   unless="rhino.present"/>
  +            unless="rhino.present"/>
   
             <!-- fail if testcases can be loaded from the system classloader 
-->
             <exclude name="${ant.package}/AntClassLoaderDelegationTest.java"
  -                   if="tests.are.on.system.classpath"/>
  +            if="tests.are.on.system.classpath"/>
             <exclude name="${optional.package}/junit/JUnitClassLoaderTest.java"
  -                   if="tests.are.on.system.classpath"/>
  +            if="tests.are.on.system.classpath"/>
             <exclude name="${optional.package}/sitraka/XMLReportTest.java"
  -                   if="tests.are.on.system.classpath"/>
  +            if="tests.are.on.system.classpath"/>
   
             <!-- these tests need to be localised before being ran???? -->
             <exclude name="${optional.package}/PvcsTest.java"/>
   
             <!-- These tests need a TraX implementation like xalan2 or saxon 
-->
             <exclude name="${optional.package}/TraXLiaisonTest.java"
  -                   unless="trax.impl.present"/>
  +            unless="trax.impl.present"/>
             <exclude name="${optional.package}/XsltTest.java"
  -                   unless="trax.impl.present"/>
  +            unless="trax.impl.present"/>
             <exclude name="${ant.package}/types/XMLCatalogBuildFileTest.java"
  -                   unless="trax.impl.present"/>
  +            unless="trax.impl.present"/>
             <exclude name="${optional.package}/junit/JUnitReportTest.java"
  -                   unless="run.junitreport"/>
  +            unless="run.junitreport"/>
             <exclude name="${taskdefs.package}/StyleTest.java"
  -                   unless="trax.impl.present"/>
  +            unless="trax.impl.present"/>
   
             <!-- needs BSF to work -->
             <exclude name="${optional.package}/XalanLiaisonTest.java"
  -                   unless="bsf.present"/>
  +            unless="bsf.present"/>
             <exclude name="${optional.package}/XalanLiaisonTest.java"
  -                   unless="xerces1.present"/>
  +            unless="xerces1.present"/>
             <exclude name="${optional.package}/XslpLiaisonTest.java"
  -                   unless="xerces1.present"/>
  +            unless="xerces1.present"/>
   
             <!-- needs resolver.jar to work -->
             <exclude name="${optional.package}/XmlValidateCatalogTest.java"
  -                   unless="apache.resolver.present"/>
  +            unless="apache.resolver.present"/>
   
             <!-- needs jasperc -->
             <exclude name="${optional.package}/JspcTest.java"
  -                   unless="jasper.present"/>
  +            unless="jasper.present"/>
   
             <!-- misc oneoff tests -->
             <exclude name="${optional.package}/WsdlToDotnetTest.java"
  -                   unless="dotnetapps.found"/>
  +            unless="dotnetapps.found"/>
             <exclude name="${optional.package}/DotnetTest.java"
  -                   unless="dotnetapps.found"/>
  +            unless="dotnetapps.found"/>
   
             <!--  These tests only passes if testcases and Ant classes have
             been loaded by the same classloader - will throw
             IllegalAccessExceptions otherwise.  -->
             <exclude name="${ant.package}/DirectoryScannerTest.java"
  -                   unless="tests.and.ant.share.classloader"/>
  +            unless="tests.and.ant.share.classloader"/>
             <exclude name="${taskdefs.package}/SQLExecTest.java"
  -                   unless="tests.and.ant.share.classloader"/>
  +            unless="tests.and.ant.share.classloader"/>
             <exclude name="${taskdefs.package}/cvslib/ChangeLogWriterTest.java"
  -                   unless="tests.and.ant.share.classloader"/>
  +            unless="tests.and.ant.share.classloader"/>
             <exclude name="${optional.package}/sos/SOSTest.java"
  -                   unless="tests.and.ant.share.classloader"/>
  +            unless="tests.and.ant.share.classloader"/>
             <exclude name="${optional.package}/vss/MSVSSTest.java"
  -                   unless="tests.and.ant.share.classloader"/>
  +            unless="tests.and.ant.share.classloader"/>
             <exclude name="${optional.package}/TraXLiaisonTest.java"
  -                   unless="tests.and.ant.share.classloader"/>
  +            unless="tests.and.ant.share.classloader"/>
             <exclude name="${optional.package}/metamata/MAuditParserTest.java"
  -                   unless="tests.and.ant.share.classloader"/>
  +            unless="tests.and.ant.share.classloader"/>
             <exclude name="${taskdefs.package}/ProcessDestroyerTest.java"
  -                   unless="tests.and.ant.share.classloader"/>
  +            unless="tests.and.ant.share.classloader"/>
             <exclude name="${taskdefs.package}/ProtectedJarMethodsTest.java"
  -                   unless="tests.and.ant.share.classloader"/>
  +            unless="tests.and.ant.share.classloader"/>
   
             <!-- can only run if cvs is installed on your machine
                  enable by setting the property have.cvs
             -->
             <exclude name="${taskdefs.package}/AbstractCvsTaskTest.java"
  -                   unless="have.cvs"/>
  +            unless="have.cvs"/>
   
             <!-- needs a local ftp server and the entry of a user/password 
combination -->
             <exclude name="${optional.package}/net/FTPTest.java"/>
  @@ -1646,7 +1646,7 @@
             <!-- test fails if build/classes and ant.jar are using the same
                  classloader  -->
             <exclude name="${ant.package}/util/ClasspathUtilsTest.java"
  -                   if="tests.and.ant.share.classloader"/>
  +            if="tests.and.ant.share.classloader"/>
           </fileset>
         </batchtest>
       </junit>
  @@ -1661,16 +1661,16 @@
   
   
       <junit printsummary="${junit.summary}"
  -          haltonfailure="${test.haltonfailure}"
  -          fork="${junit.fork}"
  -          filtertrace="${junit.filtertrace}">
  -<!--      <jvmarg value="-classic"/> -->
  +      haltonfailure="${test.haltonfailure}"
  +      fork="${junit.fork}"
  +      filtertrace="${junit.filtertrace}">
  +      <!--      <jvmarg value="-classic"/> -->
         <sysproperty key="ant.home" value="${ant.home}"/>
         <sysproperty key="build.tests" file="${build.tests}"/>
         <sysproperty key="build.tests.value" value="${build.tests.value}"/>
  -      <sysproperty key="offline" value="${offline}"/>      
  +      <sysproperty key="offline" value="${offline}"/>
         <sysproperty key="tests-classpath.value"
  -                   value="${tests-classpath.value}"/>
  +        value="${tests-classpath.value}"/>
         <sysproperty key="root" file="${basedir}"/>
         <sysproperty key="build.compiler" value="${build.compiler}"/>
         <classpath refid="tests-classpath"/>
  @@ -1680,11 +1680,11 @@
     </target>
   
     <target name="interactive-tests" description="--> runs interactive tests"
  -          depends="compile-tests"
  -          if="jdk1.3+">
  +    depends="compile-tests"
  +    if="jdk1.3+">
       <java classpathref="tests-classpath"
  -          classname="org.apache.tools.ant.taskdefs.TestProcess"
  -          fork="true"/>
  +      classname="org.apache.tools.ant.taskdefs.TestProcess"
  +      fork="true"/>
     </target>
   
     <!--
  @@ -1693,7 +1693,7 @@
          ===================================================================
     -->
     <target name="main"
  -          description="--> creates a minimum distribution in ./dist"
  -          depends="dist-lite"/>
  +    description="--> creates a minimum distribution in ./dist"
  +    depends="dist-lite"/>
   
   </project>
  
  
  
  1.33      +5 -1      ant/docs/manual/CoreTasks/conditions.html
  
  Index: conditions.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/CoreTasks/conditions.html,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- conditions.html   10 Mar 2005 14:09:39 -0000      1.32
  +++ conditions.html   10 Mar 2005 23:20:02 -0000      1.33
  @@ -537,7 +537,11 @@
   
   <p>Uses Java1.5+ networking APIs to probe for a (remote) system being
   reachable. Exactly what probe mechanisms are used is an implementation
  -feature of the JVM. They may include ICMP "ping" packets
  +feature of the JVM. They may include ICMP "ping" packets, UDP or TCP 
connections
  +to port 7 "echo service" or other means. On Java1.4 and earlier, being able
  +to resolve the hostname is considered success. This means that if DNS is not
  +working or a URL/hostname is bad, the test will fail, but otherwise succeed
  +even if the remote host is actually absent.
   
   </p>
   <p>
  
  
  
  1.39      +1 -1      
ant/src/main/org/apache/tools/ant/types/defaults.properties
  
  Index: defaults.properties
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/types/defaults.properties,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- defaults.properties       10 Mar 2005 14:09:39 -0000      1.38
  +++ defaults.properties       10 Mar 2005 23:20:03 -0000      1.39
  @@ -37,7 +37,7 @@
   concatfilter=org.apache.tools.ant.filters.ConcatFilter
   issigned=org.apache.tools.ant.taskdefs.condition.IsSigned
   isfileselected=org.apache.tools.ant.taskdefs.condition.IsFileSelected
  -isreachable=org.apache.tools.ant.taskdefs.optional.condition.IsPingable
  +isreachable=org.apache.tools.ant.taskdefs.condition.IsReachable
   mavenrepository=org.apache.tools.ant.taskdefs.repository.MavenRepository
   scriptselector=org.apache.tools.ant.types.optional.ScriptSelector
   scriptcondition=org.apache.tools.ant.types.optional.ScriptCondition
  
  
  
  1.1                  
ant/src/main/org/apache/tools/ant/taskdefs/condition/IsReachable.java
  
  Index: IsReachable.java
  ===================================================================
  /*
   * Copyright  2004-2005 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   *
   */
  
  package org.apache.tools.ant.taskdefs.condition;
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Project;
  import org.apache.tools.ant.ProjectComponent;
  
  import java.lang.reflect.InvocationTargetException;
  import java.lang.reflect.Method;
  import java.net.InetAddress;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.net.UnknownHostException;
  
  /**
   * Test for a host being reachable using ICMP "ping" packets & echo 
operations.
   * Ping packets are very reliable for assessing reachability in a LAN or WAN,
   * but they do not get through any well-configured firewall. Echo (port 7) 
may.
   * <p/>
   * This condition turns unknown host exceptions into false conditions. This is
   * because on a laptop, DNS is one of the first services when the network 
goes;
   * you are implicitly offline.
   * <p/>
   * If a URL is supplied instead of a host, the hostname is extracted and used 
in
   * the test - all other parts of the URL are discarded.
   * <p/>
   * The test may not work through firewalls, that is, something may be 
reachable
   * using a protocol such as HTTP, while the lower level ICMP packets get 
dropped
   * on the floor. Similarly, a host may detected as reachable with ICMP, but 
not
   * reachable on other ports (i.e. port 80), because of firewalls.
   * <p/>
   * Requires Java1.5+ to work properly. On Java1.4 and earlier, if a hostname 
is
   * resolveable, the destination is assumed to be reachable.
   *
   * @ant.condition name="isreachable"
   * @since Ant1.7
   */
  public class IsReachable extends ProjectComponent implements Condition {
  
      private String host;
      private String url;
  
      /**
       * The default timeout.
       */
      public static final int DEFAULT_TIMEOUT = 30;
      private int timeout = DEFAULT_TIMEOUT;
      /**
       * Error when no hostname is defined
       */
      public static final String ERROR_NO_HOSTNAME = "No hostname defined";
      /**
       * Error when invalid timeout value is defined
       */
      public static final String ERROR_BAD_TIMEOUT = "Invalid timeout value";
      /**
       * Unknown host message is seen.
       */
      public static final String WARN_UNKNOWN_HOST = "Unknown host:";
      /**
       * Network error message is seen.
       */
      public static final String ERROR_ON_NETWORK = "network error to ";
      public static final String ERROR_BOTH_TARGETS = "Both url and host have 
been specified";
      public static final String MSG_NO_REACHABLE_TEST = "cannot do a proper 
reachability test on this Java version";
      public static final String ERROR_BAD_URL = "Bad URL ";
      public static final String ERROR_NO_HOST_IN_URL = "No hostname in URL ";
  
      /**
       * The host to ping.
       *
       * @param host the host to ping.
       */
      public void setHost(String host) {
          this.host = host;
      }
  
      /**
       * A URL to extract the hostname from
       *
       * @param url
       */
      public void setUrl(String url) {
          this.url = url;
      }
  
      /**
       * Timeout for the reachability test -in seconds.
       *
       * @param timeout the timeout in seconds.
       */
      public void setTimeout(int timeout) {
          this.timeout = timeout;
      }
  
      /**
       * emptyness test
       *
       * @param string param to check
       *
       * @return true if it is empty
       */
      private boolean empty(String string) {
          return string == null || string.length() == 0;
      }
  
      private static Class[] parameterTypes = {Integer.class};
  
      /**
       * Is this condition true?
       *
       * @return true if the condition is true.
       *
       * @throws org.apache.tools.ant.BuildException
       *          if an error occurs
       */
      public boolean eval() throws BuildException {
          if (empty(host) && empty(url)) {
              throw new BuildException(ERROR_NO_HOSTNAME);
          }
          if (timeout < 0) {
              throw new BuildException(ERROR_BAD_TIMEOUT);
          }
          String target = host;
          if (!empty(url)) {
              if (!empty(host)) {
                  throw new BuildException(ERROR_BOTH_TARGETS);
              }
              try {
                  //get the host of a url
                  URL realURL = new URL(url);
                  target = realURL.getHost();
                  if (empty(target)) {
                      throw new BuildException(ERROR_NO_HOST_IN_URL + url);
                  }
              } catch (MalformedURLException e) {
                  throw new BuildException(ERROR_BAD_URL + url, e);
              }
          }
          log("Probing host " + target, Project.MSG_VERBOSE);
          InetAddress address;
          try {
              log(WARN_UNKNOWN_HOST + target);
              address = InetAddress.getByName(target);
          } catch (UnknownHostException e1) {
              return false;
  
          }
          log("Host address =" + address.getHostAddress(),
                  Project.MSG_VERBOSE);
          boolean reachable;
          //Java1.5: reachable = address.isReachable(timeout * 1000);
          Method reachableMethod = null;
          try {
              reachableMethod = InetAddress.class.getMethod("reachable",
                      parameterTypes);
              Object[] params = new Object[1];
              params[0] = new Integer(timeout * 1000);
              try {
                  reachable = ((Boolean) reachableMethod.invoke(address, 
params))
                          .booleanValue();
              } catch (IllegalAccessException e) {
                  //utterly implausible, but catered for anyway
                  throw new BuildException("When calling " + reachableMethod);
              } catch (InvocationTargetException e) {
                  //assume this is an IOexception about un readability
                  Throwable nested = e.getTargetException();
                  log(ERROR_ON_NETWORK + target + ": " + nested.toString());
                  //any kind of fault: not reachable.
                  reachable = false;
              }
          } catch (NoSuchMethodException e) {
              //java1.4 or earlier
              log(MSG_NO_REACHABLE_TEST);
              reachable = true;
  
          }
  
          log("host is " + (reachable ? "" : "not") + " reachable",
                  Project.MSG_VERBOSE);
          return reachable;
      }
  }
  
  
  
  1.1                  ant/src/etc/testcases/taskdefs/conditions/isreachable.xml
  
  Index: isreachable.xml
  ===================================================================
  <project name="isreachable">
    <!--
     * Copyright  2005 The Apache Software Foundation
     *
     *  Licensed under the Apache License, Version 2.0 (the "License");
     *  you may not use this file except in compliance with the License.
     *  You may obtain a copy of the License at
     *
     *      http://www.apache.org/licenses/LICENSE-2.0
     *
     *  Unless required by applicable law or agreed to in writing, software
     *  distributed under the License is distributed on an "AS IS" BASIS,
     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     *  See the License for the specific language governing permissions and
     *  limitations under the License.
     *
    -->
  
  
    <macrodef name="assertHostReachable">
      <attribute name="host"/>
      <sequential>
        <fail message="not reachable: @{host}">
          <condition>
            <not>
              <isreachable host="@{host}"/>
            </not>
          </condition>
        </fail>
      </sequential>
    </macrodef>
  
    <macrodef name="assertHostNotReachable">
      <attribute name="host"/>
      <sequential>
        <fail message="unexpectedly reachable: @{host}">
          <condition>
            <isreachable host="@{host}"/>
          </condition>
        </fail>
      </sequential>
    </macrodef>
  
    <macrodef name="assertUrlReachable">
      <attribute name="url"/>
      <sequential>
        <fail message="not reachable: @{url}">
          <condition>
            <not>
              <isreachable url="@{url}"/>
            </not>
          </condition>
        </fail>
      </sequential>
    </macrodef>
  
    <target name="testLocalhost">
      <assertHostReachable host="localhost"/>
    </target>
  
    <!-- bugs in XPSP2 mean this is the only IPv4 loopback addr allowed  -->
    <target name="testIpv4localhost">
      <assertHostReachable host="127.0.0.1"/>
    </target>
  
    <target name="testBoth">
      <condition property="both">
        <isreachable host="localhost" url="http://localhost"/>
      </condition>
      <fail>Expected failure before here</fail>
    </target>
  
    <target name="testLocalhostURL">
      <assertUrlReachable url="http://localhost"/>
    </target>
  
    <target name="testIpv4localhostURL">
      <assertUrlReachable url="http://127.0.0.1/"/>
    </target>
  
    <target name="testFTPURL">
      <assertUrlReachable url="ftp://localhost"/>
    </target>
  
    <target name="testFile">
      <assertUrlReachable url="file://build.xml"/>
    </target>
  
    <target name="testBadURL">
      <assertUrlReachable url="uuid:3349-4404-0ac0ddee"/>
    </target>
  
    <target name="testBadTimeout">
      <condition property="testBadTimeout">
        <isreachable host="localhost" timeout="-1"/>
      </condition>
    </target>
  
    <target name="testNoTargets">
      <condition property="none">
        <isreachable/>
      </condition>
    </target>
  </project>
  
  
  
  1.1                  
ant/src/testcases/org/apache/tools/ant/taskdefs/condition/IsReachableTest.java
  
  Index: IsReachableTest.java
  ===================================================================
  /*
   * Copyright  2005 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   *
   */
  package org.apache.tools.ant.taskdefs.condition;
  
  import org.apache.tools.ant.BuildFileTest;
  
  /**
   * test for reachable things
   */
  public class IsReachableTest extends BuildFileTest {
  
      public IsReachableTest(String name) {
          super(name);
      }
  
      public void setUp() {
          configureProject(
                  "src/etc/testcases/taskdefs/conditions/isreachable.xml");
      }
  
  
      public void testLocalhost() throws Exception {
          executeTarget("testLocalhost");
      }
  
      public void testLocalhostURL() throws Exception {
          executeTarget("testLocalhostURL");
      }
  
      public void testIpv4localhost() throws Exception {
          executeTarget("testIpv4localhost");
      }
  
      public void testFTPURL() throws Exception {
          executeTarget("testFTPURL");
      }
  
      public void testBoth() throws Exception {
          expectBuildExceptionContaining("testBoth",
                  "error on two targets",
                  IsReachable.ERROR_BOTH_TARGETS);
      }
  
      public void testNoTargets() throws Exception {
          expectBuildExceptionContaining("testNoTargets",
                  "no params",
                  IsReachable.ERROR_NO_HOSTNAME);
      }
  
      public void testBadTimeout() throws Exception {
          expectBuildExceptionContaining("testBadTimeout",
                  "error on -ve timeout",
                  IsReachable.ERROR_BAD_TIMEOUT);
      }
  
      public void NotestFile() throws Exception {
          expectBuildExceptionContaining("testFile",
                  "error on file URL",
                  IsReachable.ERROR_NO_HOST_IN_URL);
      }
  
      public void testBadURL() throws Exception {
          expectBuildExceptionContaining("testBadURL",
                  "error in URL",
                  IsReachable.ERROR_BAD_URL);
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to