Prepare for a library of SSH tasks compiled against 1.5.4


git-svn-id: https://svn.apache.org/repos/asf/ant/core/branches/ANT_15_BRANCH@275937 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/build.xml b/build.xml
index 4f3b899..746be5d 100644
--- a/build.xml
+++ b/build.xml
@@ -4,7 +4,7 @@
   =======================================================================
    Apache Ant own build file
 
-   Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
+   Copyright (c) 2000-2004 The Apache Software Foundation.  All rights
    reserved.
 
   =======================================================================
@@ -303,6 +303,22 @@
   <patternset id="teststhatfail">
   </patternset>
   
+  <patternset id="needs.jsch">
+    <exclude name="${optional.package}/ssh/*.java" unless="jsch.present"/>
+  </patternset>
+  <patternset id="ssh-lib">
+    <exclude name="${optional.package}/ssh/*"/>
+    <exclude name="${ant.package}/util/TeeOutputStream*"/>
+  </patternset>
+  <patternset id="ssh-lib-src">
+    <exclude name="main/${optional.package}/ssh/*"/>
+    <exclude name="main/${ant.package}/util/TeeOutputStream*"/>
+  </patternset>
+  <patternset id="ssh-lib-docs">
+    <exclude name="manual/OptionalTasks/sshexec.html"/>
+    <exclude name="manual/OptionalTasks/scp.html"/>
+  </patternset>
+
   <!--
        ===================================================================
          Set up a patternsets that matches the parts of our JUnit testsuite
@@ -539,6 +555,9 @@
     <available property="beanshell.present"
                classname="bsh.StringUtil"
                classpathref="classpath"/>
+    <available property="jsch.present"
+               classname="com.jcraft.jsch.Session"
+               classpathref="classpath"/>
   </target>
 
 
@@ -612,6 +631,7 @@
       <patternset refid="needs.sun.b64"/>
       <patternset refid="needs.jakarta.bcel"/>
       <patternset refid="needs.swing"/>
+      <patternset refid="needs.jsch"/>
     </javac>
 
     <copy todir="${build.classes}">
@@ -661,6 +681,7 @@
     <jar destfile="${build.lib}/${name}.jar"
          basedir="${build.classes}"
          manifest="${manifest}">
+      <patternset refid="ssh-lib"/>
       <exclude name="${optional.package}/**"/>
       <exclude name="${optional.type.package}/**"/>
       <exclude name="${util.package}/depend/**"/>
@@ -700,6 +721,7 @@
     <jar destfile="${build.lib}/optional.jar"
          basedir="${build.classes}"
          manifest="${manifest}">
+      <patternset refid="ssh-lib"/>
       <include name="${optional.package}/**"/>
       <include name="${optional.type.package}/**"/>
       <include name="${util.package}/depend/**"/>
@@ -911,13 +933,16 @@
     </copy>
 
     <copy todir="${src.dist.src}">
-      <fileset dir="${src.dir}"/>
+      <fileset dir="${src.dir}">
+        <patternset refid="ssh-lib-src"/>
+      </fileset>
     </copy>
 
     <copy todir="${src.dist.docs}">
       <fileset dir="${docs.dir}">
         <exclude name="manual/api/**"/>
         <patternset refid="site.excludes"/>
+        <patternset refid="ssh-lib-docs"/>
       </fileset>
     </copy>
 
@@ -1150,7 +1175,8 @@
              windowtitle="${Name} API"
              doctitle="${Name}">
 
-      <packageset dir="${java.dir}"/>
+      <packageset dir="${java.dir}" 
+        excludes="org/apache/tools/ant/taskdefs/optional/ssh"/>
 
       <tag name="todo" description="To do:" scope="all"/>
       <tag name="ant.task" enabled="false" description="Task:" scope="types"/>
@@ -1448,4 +1474,104 @@
           description="--> creates a minimum distribution in ./dist"
           depends="dist-lite"/>
 
+  <!--
+       ===================================================================
+         Creates the SSH tasks distribution, requires JSch on the CLASSPATH
+       ===================================================================
+  -->
+  <target name="ssh-lib" depends="build" if="jsch.present">
+    <property name="ssh.version" value="1.5-1.0"/>
+    <property name="ssh.dist" 
+      value="${dist.base}/ant-ssh-tasks-${ssh.version}"/>
+    <mkdir dir="${ssh.dist}/tmp"/>
+    <echo file="${ssh.dist}/tmp/sshtasks.properties">
+scp=org.apache.tools.ant.taskdefs.optional.ssh.Scp
+sshexec=org.apache.tools.ant.taskdefs.optional.ssh.SSHExec
+    </echo>
+
+    <patternset id="ssh-lib-includes">
+      <include name="${ant.package}/taskdefs/optional/ssh/*"/>
+      <include name="${ant.package}/util/TeeOutputStream*"/>
+    </patternset>
+
+    <mkdir dir="${ssh.dist}/lib"/>
+    <jar destfile="${ssh.dist}/lib/ant-ssh.jar">
+      <manifest>
+        <section name="${ant.package}/taskdefs/optional/ssh">
+          <attribute name="Extension-name"
+                     value="org.apache.tools.ant.taskdefs.optional.ssh"/>
+          <attribute name="Specification-Title"
+                     value="Apache Ant SSH Tasks"/>
+          <attribute name="Specification-Version"
+                     value="${manifest-version}"/>
+          <attribute name="Specification-Vendor"
+                     value="Apache Software Foundation"/>
+          <attribute name="Implementation-Title"
+                     value="org.apache.tools.ant.taskdefs.optional.ssh"/>
+          <attribute name="Implementation-Version"
+                     value="${manifest-version}"/>
+          <attribute name="Implementation-Vendor"
+                     value="Apache Software Foundation"/>
+        </section>
+      </manifest>
+      <fileset dir="${build.classes}">
+        <patternset refid="ssh-lib-includes"/>
+      </fileset>
+      <zipfileset dir="${ssh.dist}/tmp" 
+        prefix="${ant.package}/taskdefs/optional/ssh"/>
+    </jar>
+    <delete dir="${ssh.dist}/tmp"/>
+
+    <mkdir dir="${ssh.dist}/docs"/>
+    <copy todir="${ssh.dist}/docs" flatten="true">
+      <fileset dir="${docs.dir}">
+        <include name="manual/OptionalTasks/sshexec.html"/>
+        <include name="manual/OptionalTasks/scp.html"/>
+      </fileset>
+    </copy>
+    <copy tofile="${ssh.dist}/docs/index.html"
+        file="${docs.dir}/manual/OptionalTasks/sshlib.html"/>
+
+    <echo file="${ssh.dist}/README">
+This distribution contains the &lt;sshexec&gt; and &lt;scp&gt; tasks
+introduced in Ant 1.6.0 compiled against Ant 1.5.4.
+
+If you use Ant 1.6.0 or later, you don't need this file.
+If you are using Ant 1.5.x, you should consider upgrading Ant.
+
+This distribution has only been tested against Ant 1.5.4 but should
+work with Ant 1.5.2 or higher.
+
+The tasks in this library require additional software.  For details,
+installation instructions and the task documentation see the docs
+subdirectory.
+
+This software is licensed under the terms you may find in the file
+named "LICENSE" in this directory.
+
+                                          The Apache Ant Project
+                                         &lt;http://ant.apache.org/&gt;
+    </echo>
+    <copy todir="${ssh.dist}">
+      <fileset dir=".">
+        <include name="LICENSE"/>
+      </fileset>
+    </copy>
+
+    <mkdir dir="${ssh.dist}/src"/>
+    <copy todir="${ssh.dist}/src">
+      <fileset dir="${java.dir}">
+        <patternset refid="ssh-lib-includes"/>
+      </fileset>
+    </copy>
+    <zip destfile="${ssh.dist}.zip" basedir="${dist.base}"
+	includes="ant-ssh-tasks-${ssh.version}/**"/>
+    <tar destfile="${ssh.dist}.tar.gz" basedir="${dist.base}"
+      compression="gzip" includes="ant-ssh-tasks-${ssh.version}/**"/>
+    <delete dir="${ssh.dist}"/>
+    <checksum fileext=".md5">
+      <fileset dir="${dist.base}"
+        includes="ant-ssh-tasks-${ssh.version}.*"/>
+    </checksum>
+  </target>
 </project>
diff --git a/docs/manual/OptionalTasks/scp.html b/docs/manual/OptionalTasks/scp.html
index 943d5f4..41e678a 100644
--- a/docs/manual/OptionalTasks/scp.html
+++ b/docs/manual/OptionalTasks/scp.html
@@ -10,17 +10,15 @@
 <h2><a name="scp">SCP</a></h2>
 <h3>Description</h3>
 
-<p><em>since Ant 1.6</em></p>
-
 <p>Copies a file or FileSet to or from a remote machine running SSH daemon.
 FileSet <i>only</i> works for copying files from the local machine to a
 remote machine.</p>
 
 <p><b>Note:</b> This task depends on external libraries not included
 in the Ant distribution.  See <a
-href="../install.html#librarydependencies">Library Dependencies</a>
+href="index.html#librarydependencies">Library Dependencies</a>
 for more information.  This task has been tested with jsch-0.1.2 to
-jsch-0.1.9.</p>
+jsch-0.1.12.</p>
 
 <h3>Parameters</h3>
 <table border="1" cellpadding="2" cellspacing="0">
@@ -171,7 +169,7 @@
 instead.
 </p>
 
-<hr><p align="center">Copyright &copy; 2003 Apache Software Foundation.
+<hr><p align="center">Copyright &copy; 2003-2004 Apache Software Foundation.
 All rights Reserved.</p>
 
 </body>
diff --git a/docs/manual/OptionalTasks/sshexec.html b/docs/manual/OptionalTasks/sshexec.html
index 855c401..5b142d2 100644
--- a/docs/manual/OptionalTasks/sshexec.html
+++ b/docs/manual/OptionalTasks/sshexec.html
@@ -10,16 +10,14 @@
 <h2><a name="sshexec">SSHEXEC</a></h2>
 <h3>Description</h3>
 
-<p><em>since Ant 1.6</em></p>
-
 <p>Runs a command on a remote machine running SSH daemon.
 </p>
 
 <p><b>Note:</b> This task depends on external libraries not included
 in the Ant distribution.  See <a
-href="../install.html#librarydependencies">Library Dependencies</a>
+href="index.html#librarydependencies">Library Dependencies</a>
 for more information.  This task has been tested with jsch-0.1.7 to
-jsch-0.1.9 and won't work with versions of jsch earlier than
+jsch-0.1.12 and won't work with versions of jsch earlier than
 0.1.7.</p>
 
 <h3>Parameters</h3>
@@ -150,7 +148,7 @@
 </pre>
 </p>
 
-<hr><p align="center">Copyright &copy; 2003 Apache Software Foundation.
+<hr><p align="center">Copyright &copy; 2003-2004 Apache Software Foundation.
 All rights Reserved.</p>
 
 </body>
diff --git a/docs/manual/OptionalTasks/sshlib.html b/docs/manual/OptionalTasks/sshlib.html
new file mode 100644
index 0000000..115247b
--- /dev/null
+++ b/docs/manual/OptionalTasks/sshlib.html
@@ -0,0 +1,71 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+  <head>
+    <title>SSH Tasks for Ant 1.5.x</title>
+  </head>
+
+  <body>
+    <h1>SSH Tasks for Ant 1.5.x</h1>
+
+    <p>With Ant 1.6.0 two new tasks have been added that allow users
+      to execute commands via SSH or use scp to transfer files to a
+      remote server securly.</p>
+
+    <p>These new tasks are mostly independent of changes in Ant 1.6,
+      so we decided to make the tasks available to users who can't
+      upgrade Ant easily as a separate library.  We encourage all our
+      users to upgrade to the latest version of Ant.</p>
+
+    <p>This distribution contains the Ant tasks &lt;sshexec&gt; and
+    &lt;scp&gt; compiled against Ant 1.5.4.  They may work with older
+    distributions of Ant as well but haven't been tested with any
+    other version.  These tasks <a
+    href="#librarydependencies">require</a> additional software that
+    is not part of this distribution.</p>
+
+    <h2>Installation</h2>
+
+    <p>The easiest way to use the tasks is to use</p>
+
+    <pre>
+      &lt;taskdef resource="org/apache/tools/ant/taskdefs/optional/ssh/sshtasks.properties"&gt;
+        &lt;classpath&gt;
+          &lt;pathelement location="your/path/to/ant-ssh.jar"/&gt;
+          &lt;pathelement location="your/path/to/jsch.jar"/&gt;
+        &lt;/classpath&gt;
+      &lt;/taskdef&gt;
+    </pre>
+
+    <p>in your build file.  If ant-ssh.jar is on your CLASSPATH or in
+      ANT_HOME/lib you can even simplify this to read</p>
+
+    <pre>
+      &lt;taskdef resource="org/apache/tools/ant/taskdefs/optional/ssh/sshtasks.properties"/&gt;
+    </pre>
+
+    <p><strong>Note</strong> that JSch has to be on your CLASSPATH or
+    ANT_HOME/lib as well, if you use the last approach.</p>
+
+    <h2>Usage</h2>
+
+    <p>The manual pages for the tasks:</p>
+    <ul>
+      <li><a href="scp.html">scp</a></li>
+      <li><a href="sshexec.html">sshexec</a></li>
+    </ul>
+
+    <h2><a name="librarydependencies">Library Dependencies</a></h2>
+
+    <p>The tasks are based on the BSD licensed SSH library <a
+    href="http://www.jcraft.com/jsch/index.html"
+    target="_top">JSch</a> that is not part of this distribution.
+    Please note that JSch requires JCE, which is part of JRE 1.4.0 and
+    later, but you may need to install additional software for JRE
+    1.2.2 or 1.3.x - please consult the JSch documentation for more
+    details.</p>
+
+    <hr>
+    <p align="center">Copyright &copy; 2004 Apache Software Foundation.
+All rights Reserved.</p>
+  </body>
+</html>