Browse Source

Add a passive mode option to <ftp>

Submitted by:	Stuart Roebuck <sr@adolos.com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268189 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 24 years ago
parent
commit
b86a0a2830
2 changed files with 42 additions and 13 deletions
  1. +19
    -13
      docs/index.html
  2. +23
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java

+ 19
- 13
docs/index.html View File

@@ -106,7 +106,7 @@ build Ant from the source code.</p>
Once installed make sure the &quot;jaxp.jar&quot; and &quot;parser.jar&quot; files are in your classpath. Once installed make sure the &quot;jaxp.jar&quot; and &quot;parser.jar&quot; files are in your classpath.
<p> <p>
You will also need the JDK installed on your system, version 1.1 or later. You will also need the JDK installed on your system, version 1.1 or later.
</p>
<hr> <hr>
<h2><a name="buildingant">Building Ant</a></h2> <h2><a name="buildingant">Building Ant</a></h2>
<p>Go to the directory <code>jakarta-ant</code>.</p> <p>Go to the directory <code>jakarta-ant</code>.</p>
@@ -736,7 +736,7 @@ They are:
&quot;**/.cvsignore&quot; &quot;**/.cvsignore&quot;
</pre> </pre>
If you do not want these default excludes applied, you may disable them with the If you do not want these default excludes applied, you may disable them with the
<code>defaultexcludes=&quot;no&quot;</code> attribute.</p>
<code>defaultexcludes=&quot;no&quot;</code> attribute.
<h3><a name="patternset">PatternSets</a></h3> <h3><a name="patternset">PatternSets</a></h3>
<p>Patterns can be grouped to sets and later be referenced by their id <p>Patterns can be grouped to sets and later be referenced by their id
attribute. They are defined via a <code>patternset</code> element - attribute. They are defined via a <code>patternset</code> element -
@@ -1890,7 +1890,7 @@ BUILD FAILED


build.xml:4: No message build.xml:4: No message
</pre> </pre>
</p>
<pre> &lt;fail message=&quot;Something wrong here.&quot;/&gt;</pre> <pre> &lt;fail message=&quot;Something wrong here.&quot;/&gt;</pre>
<p>will exit the current build and print something like the following to whereever <p>will exit the current build and print something like the following to whereever
your output goes: your output goes:
@@ -1899,7 +1899,7 @@ BUILD FAILED


build.xml:4: Something wrong here. build.xml:4: Something wrong here.
</pre> </pre>
</p>
<hr> <hr>
<h2><a name="filter">Filter</a></h2> <h2><a name="filter">Filter</a></h2>
<h3>Description</h3> <h3>Description</h3>
@@ -2351,6 +2351,7 @@ You should not include <samp>META-INF/MANIFEST.MF</samp> in your set of files.
If <code>create</code> (the default), the JAR is created anyway with only a manifest. If <code>create</code> (the default), the JAR is created anyway with only a manifest.
If <code>skip</code>, the JAR is not created and a warning is issued. If <code>skip</code>, the JAR is not created and a warning is issued.
If <code>fail</code>, the JAR is not created and the build is halted with an error. If <code>fail</code>, the JAR is not created and the build is halted with an error.
</p>
<h3>Parameters</h3> <h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0"> <table border="1" cellpadding="2" cellspacing="0">
<tr> <tr>
@@ -3384,7 +3385,7 @@ to move to the <var>todir</var> directory.</p>
<hr> <hr>
<h2><a name="patch">Patch</a></h2> <h2><a name="patch">Patch</a></h2>
<h3>Description</h3> <h3>Description</h3>
<p>Applies a diff file to originals.
<p>Applies a diff file to originals.</p>
<h3>Parameters</h3> <h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0"> <table border="1" cellpadding="2" cellspacing="0">
<tr> <tr>
@@ -3524,7 +3525,7 @@ builds using the following:
to be your home directory. This technique is more appropriate for Unix than to be your home directory. This technique is more appropriate for Unix than
Windows since the notion of a home directory doesn't exist on Windows. On the Windows since the notion of a home directory doesn't exist on Windows. On the
JVM that I tested, the home directory on Windows is &quot;C:\&quot;. Different JVM JVM that I tested, the home directory on Windows is &quot;C:\&quot;. Different JVM
implementations may use other values for the home directory on Windows.
implementations may use other values for the home directory on Windows.</p>
<hr> <hr>
<h2><a name="rename">Rename</a></h2> <h2><a name="rename">Rename</a></h2>
<h3><i>Deprecated</i></h3> <h3><i>Deprecated</i></h3>
@@ -3945,7 +3946,7 @@ class path</td>
<p><pre> <p><pre>
&lt;style basedir=&quot;doc&quot; destdir=&quot;build/doc&quot; &lt;style basedir=&quot;doc&quot; destdir=&quot;build/doc&quot;
extension=&quot;html&quot; style=&quot;style/apache.xml&quot;/&gt; extension=&quot;html&quot; style=&quot;style/apache.xml&quot;/&gt;
</pre></p>
</pre>
</blockquote> </blockquote>
<hr> <hr>
<h2><a name="tar">Tar</a></h2> <h2><a name="tar">Tar</a></h2>
@@ -4413,7 +4414,7 @@ images/large/logo.gif
</pre> </pre>
using Ant's default manifest file. The content of using Ant's default manifest file. The content of
<code>WEB-INF/web.xml</code> is identical to <code>WEB-INF/web.xml</code> is identical to
<code>src/metadata/myapp.xml</code>.</p>
<code>src/metadata/myapp.xml</code>.
<hr> <hr>
<h2><a name="zip">Zip</a></h2> <h2><a name="zip">Zip</a></h2>
<h3>Description</h3> <h3>Description</h3>
@@ -4729,6 +4730,12 @@ write patterns.</p>
Defaults to &quot;yes&quot;</td> Defaults to &quot;yes&quot;</td>
<td valign="top" align="center">No</td> <td valign="top" align="center">No</td>
</tr> </tr>
<tr>
<td valign="top">passive</td>
<td valign="top">selects passive-mode (&quot;yes&quot;) transfers.
Defaults to &quot;no&quot;</td>
<td valign="top" align="center">No</td>
</tr>
<tr> <tr>
<td valign="top">verbose</td> <td valign="top">verbose</td>
<td valign="top">displays information on each file transferred if set <td valign="top">displays information on each file transferred if set
@@ -4798,20 +4805,19 @@ for <code>anonymous</code>.</p>
<p>Logs in to <code>ftp.apache.org</code> at port <code>2121</code> as <p>Logs in to <code>ftp.apache.org</code> at port <code>2121</code> as
<code>coder</code> with password <code>java1</code> and uploads all new or <code>coder</code> with password <code>java1</code> and uploads all new or
changed HTML files in the <code>htdocs/manual</code> directory to the changed HTML files in the <code>htdocs/manual</code> directory to the
<code>/pub/incoming</code> directory. The files are transferred in text
mode.</p>
<code>/pub/incoming</code> directory. The files are transferred in text mode. Passive mode has been switched on to send files from behind a firewall.</p>
<pre> &lt;ftp server=&quot;ftp.nt.org&quot; <pre> &lt;ftp server=&quot;ftp.nt.org&quot;
remotedir=&quot;c:\uploads&quot; remotedir=&quot;c:\uploads&quot;
userid=&quot;coder&quot; userid=&quot;coder&quot;
password=&quot;java1&quot; password=&quot;java1&quot;
separator=&quot;\&quot; separator=&quot;\&quot;
verbose=&quot;yes&quot;
verbose=&quot;yes&quot;</pre>
<PRE>
&gt; &gt;
&lt;fileset dir=&quot;htdocs/manual&quot;&gt; &lt;fileset dir=&quot;htdocs/manual&quot;&gt;
&lt;include name=&quot;**/*.html&quot; /&gt; &lt;include name=&quot;**/*.html&quot; /&gt;
&lt;/fileset&gt; &lt;/fileset&gt;
&lt;/ftp&gt;</pre>
<p>Logs in to the Windows-based <code>ftp.nt.org</code> as
&lt;/ftp&gt;</PRE><p>Logs in to the Windows-based <code>ftp.nt.org</code> as
<code>coder</code> with password <code>java1</code> and uploads all <code>coder</code> with password <code>java1</code> and uploads all
HTML files in the <code>htdocs/manual</code> directory to the HTML files in the <code>htdocs/manual</code> directory to the
<code>c:\uploads</code> directory. Progress messages are displayed as each <code>c:\uploads</code> directory. Progress messages are displayed as each


+ 23
- 0
src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java View File

@@ -88,6 +88,7 @@ public class FTP
private String password; private String password;
private File listing; private File listing;
private boolean binary = true; private boolean binary = true;
private boolean passive = false;
private boolean verbose = false; private boolean verbose = false;
private boolean newerOnly = false; private boolean newerOnly = false;
private int action = SEND_FILES; private int action = SEND_FILES;
@@ -250,6 +251,16 @@ public class FTP
this.binary = binary; this.binary = binary;
} }


/**
* Specifies whether to use passive mode. Set to true if you
* are behind a firewall and cannot connect without it. Passive mode
* is disabled by default.
*/
public void setPassive(boolean passive)
{
this.passive = passive;
}

/** /**
* Set to true to receive notification about each file as it is * Set to true to receive notification about each file as it is
* transferred. * transferred.
@@ -746,6 +757,18 @@ public class FTP
ftp.getReplyString()); ftp.getReplyString());
} }
} }
if (passive)
{
log("entering passive mode", Project.MSG_VERBOSE);
ftp.enterLocalPassiveMode();
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode()))
{
throw new BuildException(
"could not enter into passive mode: " +
ftp.getReplyString());
}
}


if (remotedir != null) if (remotedir != null)
{ {


Loading…
Cancel
Save