You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by sc...@apache.org on 2005/05/12 06:04:59 UTC

cvs commit: ant/docs/manual install.html

scohen      2005/05/11 21:04:59

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java
               docs/manual install.html
  Log:
  Adapt Ant to use the new functionalities of commons-net 1.4.0 to enable greater configurability of the server:
  Month names other than English, date formats other than the standard ones (such as all-numeric timestamps
  on unix), and different server time zones can now be supported in Ant.
  PR:30706, 33443
  Submitted by: Neeme Praks
  Reviewed by: Steve Cohen
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.68      +118 -0    ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  
  Index: FTP.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java,v
  retrieving revision 1.67
  retrieving revision 1.68
  diff -u -r1.67 -r1.68
  --- FTP.java	14 Mar 2005 19:24:58 -0000	1.67
  +++ FTP.java	12 May 2005 04:04:59 -0000	1.68
  @@ -17,6 +17,7 @@
   package org.apache.tools.ant.taskdefs.optional.net;
   
   import org.apache.commons.net.ftp.FTPClient;
  +import org.apache.commons.net.ftp.FTPClientConfig;
   import org.apache.commons.net.ftp.FTPFile;
   import org.apache.commons.net.ftp.FTPReply;
   import java.io.BufferedInputStream;
  @@ -109,6 +110,13 @@
       private boolean preserveLastModified = false;
       private String chmod = null;
       private String umask = null;
  +    private String systemKeyConfig = null;
  +    private String defaultDateFormatConfig = null;
  +    private String recentDateFormatConfig = null;
  +    private String serverLanguageCodeConfig = null;
  +    private String serverTimeZoneConfig = null;
  +    private String shortMonthNamesConfig = null;
  +    private boolean isConfigurationSet = false;
   
       protected static final String[] ACTION_STRS = {
           "sending",
  @@ -1243,6 +1251,76 @@
           this.ignoreNoncriticalErrors = ignoreNoncriticalErrors;
       }
   
  +    private void configurationHasBeenSet() {
  +        this.isConfigurationSet = true;
  +    }
  +
  +    /**
  +     * Method for setting <code>FTPClientConfig</code> remote system key.
  +     * 
  +     * @param systemKeyConfig
  +     * @see org.apache.commons.net.ftp.FTPClientConfig
  +     */
  +    public void setSystemKeyConfig(String systemKey) {
  +        this.systemKeyConfig = systemKey;
  +        configurationHasBeenSet();
  +    }
  +
  +    /**
  +     * Delegate method for <code>FTPClientConfig.setDefaultDateFormatStr(String)</code>.
  +     * 
  +     * @param defaultDateFormatConfig
  +     * @see org.apache.commons.net.ftp.FTPClientConfig
  +     */
  +    public void setDefaultDateFormatConfig(String defaultDateFormat) {
  +        this.defaultDateFormatConfig = defaultDateFormat;
  +        configurationHasBeenSet();
  +    }
  +
  +    /**
  +     * Delegate method for <code>FTPClientConfig.setRecentDateFormatStr(String)</code>.
  +     * 
  +     * @param recentDateFormatConfig
  +     * @see org.apache.commons.net.ftp.FTPClientConfig
  +     */
  +    public void setRecentDateFormatConfig(String recentDateFormat) {
  +        this.recentDateFormatConfig = recentDateFormat;
  +        configurationHasBeenSet();
  +    }
  +
  +    /**
  +     * Delegate method for <code>FTPClientConfig.setServerLanguageCode(String)</code>.
  +     * 
  +     * @param serverLanguageCodeConfig
  +     * @see org.apache.commons.net.ftp.FTPClientConfig
  +     */
  +    public void setServerLanguageCodeConfig(String serverLanguageCode) {
  +        this.serverLanguageCodeConfig = serverLanguageCode;
  +        configurationHasBeenSet();
  +    }
  +
  +    /**
  +     * Delegate method for <code>FTPClientConfig.setServerTimeZoneId(String)</code>.
  +     * 
  +     * @param serverTimeZoneConfig
  +     * @see org.apache.commons.net.ftp.FTPClientConfig
  +     */
  +    public void setServerTimeZoneConfig(String serverTimeZoneId) {
  +        this.serverTimeZoneConfig = serverTimeZoneId;
  +        configurationHasBeenSet();
  +    }
  +
  +    /**
  +     * Delegate method for <code>FTPClientConfig.setShortMonthNames(String)</code>.
  +     * 
  +     * @param shortMonthNamesConfig
  +     * @see org.apache.commons.net.ftp.FTPClientConfig
  +     */
  +    public void setShortMonthNamesConfig(String shortMonthNames) {
  +        this.shortMonthNamesConfig = shortMonthNames;
  +        configurationHasBeenSet();
  +    }
  +
   
       /**
        * Checks to see that all required parameters are set.
  @@ -1945,6 +2023,45 @@
           }
       }
   
  +    private void configure(FTPClient ftp) {
  +        if (this.isConfigurationSet) {
  +            FTPClientConfig config;
  +            if (this.systemKeyConfig != null) {
  +                config = new FTPClientConfig(this.systemKeyConfig);
  +                log("custom config: system key = " 
  +                        + this.systemKeyConfig, Project.MSG_VERBOSE);
  +            } else {
  +                config = new FTPClientConfig();
  +            }
  +            if (this.defaultDateFormatConfig != null) {
  +                config.setDefaultDateFormatStr(this.defaultDateFormatConfig);
  +                log("custom config: default date format = " 
  +                        + this.defaultDateFormatConfig, Project.MSG_VERBOSE);
  +            }
  +            if (this.recentDateFormatConfig != null) {
  +                config.setRecentDateFormatStr(this.recentDateFormatConfig);
  +                log("custom config: recent date format = " 
  +                        + this.recentDateFormatConfig, Project.MSG_VERBOSE);
  +            }
  +            if (this.serverLanguageCodeConfig != null) {
  +                config.setServerLanguageCode(this.serverLanguageCodeConfig);
  +                log("custom config: server language code = " 
  +                        + this.serverLanguageCodeConfig, Project.MSG_VERBOSE);
  +            }
  +            if (this.serverTimeZoneConfig != null) {
  +                config.setServerTimeZoneId(this.serverTimeZoneConfig);
  +                log("custom config: server time zone ID = " 
  +                        + this.serverTimeZoneConfig, Project.MSG_VERBOSE);
  +            }
  +            if (this.shortMonthNamesConfig != null) {
  +                config.setShortMonthNames(this.shortMonthNamesConfig);
  +                log("custom config: short month names = " 
  +                        + this.shortMonthNamesConfig, Project.MSG_VERBOSE);
  +            }
  +            ftp.configure(config);
  +        }
  +    }
  +
       /**
        * Runs the task.
        *
  @@ -1960,6 +2077,7 @@
               log("Opening FTP connection to " + server, Project.MSG_VERBOSE);
   
               ftp = new FTPClient();
  +            configure(ftp);
   
               ftp.connect(server, port);
               if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
  
  
  
  1.82      +1 -2      ant/docs/manual/install.html
  
  Index: install.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/install.html,v
  retrieving revision 1.81
  retrieving revision 1.82
  diff -u -r1.81 -r1.82
  --- install.html	2 May 2005 15:30:17 -0000	1.81
  +++ install.html	12 May 2005 04:04:59 -0000	1.82
  @@ -425,8 +425,7 @@
       <td><a name="commons-net">commons-net.jar</td>
       <td>ftp, rexec and telnet tasks<br>
       jakarta-oro 2.0.1 or later is required in any case together with commons-net.<br>
  -    For all users, a minimum version of commons-net of 1.2.2 is recommended.  Earlier 
  -    versions did not support autodetection of system type or had significant bugs.
  +    For all users, a minimum version of commons-net of 1.4.0 is now required.
       </td>
       <td><a href="http://jakarta.apache.org/commons/net/index.html"
              target="_top">http://jakarta.apache.org/commons/net/index.html</a></td>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: cvs commit: ant/docs/manual install.html

Posted by Steve Cohen <sc...@javactivity.org>.
Stefan Bodewig wrote:
> On Thu, 12 May 2005, Steve Cohen <sc...@javactivity.org> wrote:
> 
> 
>>I don't know, though, guys.  What do you think?  Is it really worth
>>it to avoid making the users upgrade?
> 
> 
> For me it depends on when you wanted to see the new task.
> 
> If you wanted to include it in 1.6.4 (which is unlikely to happen
> anyway, given Steve's and Matt's comments) then you wouldn't get a +1
> from me if it forced people to upgrade commons-net.  This is just too
> fresh IMHO.
> 
> If you are shooting for 1.7, having the code depend on commons-net
> 1.4.x is fine with me.
> 
> Stefan
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
> 
> 
> 
Well, I've done it.  1.4.0 is no longer required.  Have a look.  It 
isn't too ugly.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: cvs commit: ant/docs/manual install.html

Posted by Stefan Bodewig <bo...@apache.org>.
On Thu, 12 May 2005, Steve Cohen <sc...@javactivity.org> wrote:

> I don't know, though, guys.  What do you think?  Is it really worth
> it to avoid making the users upgrade?

For me it depends on when you wanted to see the new task.

If you wanted to include it in 1.6.4 (which is unlikely to happen
anyway, given Steve's and Matt's comments) then you wouldn't get a +1
from me if it forced people to upgrade commons-net.  This is just too
fresh IMHO.

If you are shooting for 1.7, having the code depend on commons-net
1.4.x is fine with me.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: cvs commit: ant/docs/manual install.html

Posted by Steve Cohen <sc...@javactivity.org>.
Steve Cohen wrote:
> Steve Cohen wrote:
> 
>> Stefan Bodewig wrote:
>>
>>> On 12 May 2005, <sc...@apache.org> wrote:
>>>
>>>
>>>>  +    For all users, a minimum version of commons-net of 1.4.0 is 
>>>> now required.
>>>
>>>
>>>
>>>
>>> Is this really true?
>>>
>>> I understand it is required to compile <ftp> or if you use one of
>>> the new features.  But if you use <ftp> the same way you did
>>> before and use a binary installation of Ant, 1.2.x should work as
>>> well, not?
>>>
>>> Stefan
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>>> For additional commands, e-mail: dev-help@ant.apache.org
>>>
>>>
>>>
>>
>> You are correct, sir.  It won't compile but it will run against the 
>> older jar, as long as the new functionalities are not called.  I 
>> forget that not everyone wants to build ant :-).
>>
>> The existing tests can be run successfully if you ignore the errors. 
>> You see, Antoine, your tests have already proven their value!
>>
>> I will revise this documentation, and also change the code to output a 
>> more meaningful error message if anyone tries to use the new features 
>> with an older jar.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>> For additional commands, e-mail: dev-help@ant.apache.org
>>
>>
>>
> Nope, spoke too soon.  I wasn't running against what I thought I was.
> With commons-net-1.2.2 jar, the bad import statement makes the test 
> constructor throw.
> 
> This is so ugly.
> 
> I wonder if I could do a Class.forName(), and if it doesn't throw, I 
> know I can use reflection to do the new stuff, and avoid importing the 
> new class.
> 
> This is so ugly.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
> 
> 
> 
OK.  I found a way that isn't quite so ugly.  I moved all the code that 
references the new class in commons-net off to a separate compilation 
unit, a new class in the org.apache.tools.ant.taskdefs.optional.net 
package.  Now there are no issues with bad import statements in the FTP 
class itself.

Since the new class is in the same package as FTP.java it doesn't need 
to be imported in order to compile.  The new class isn't referenced 
unless the right commons-net version is present.

As long as the new code isn't called, there is no problem when using 
older versions of commons-net.  Otherwise, a BuildException is thrown.

I don't know, though, guys.  What do you think?  Is it really worth it 
to avoid making the users upgrade?

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: cvs commit: ant/docs/manual install.html

Posted by Steve Cohen <sc...@javactivity.org>.
Steve Cohen wrote:
> Stefan Bodewig wrote:
> 
>> On 12 May 2005, <sc...@apache.org> wrote:
>>
>>
>>>  +    For all users, a minimum version of commons-net of 1.4.0 is now 
>>> required.
>>
>>
>>
>> Is this really true?
>>
>> I understand it is required to compile <ftp> or if you use one of
>> the new features.  But if you use <ftp> the same way you did
>> before and use a binary installation of Ant, 1.2.x should work as
>> well, not?
>>
>> Stefan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>> For additional commands, e-mail: dev-help@ant.apache.org
>>
>>
>>
> 
> You are correct, sir.  It won't compile but it will run against the 
> older jar, as long as the new functionalities are not called.  I forget 
> that not everyone wants to build ant :-).
> 
> The existing tests can be run successfully if you ignore the errors. You 
> see, Antoine, your tests have already proven their value!
> 
> I will revise this documentation, and also change the code to output a 
> more meaningful error message if anyone tries to use the new features 
> with an older jar.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
> 
> 
> 
Nope, spoke too soon.  I wasn't running against what I thought I was.
With commons-net-1.2.2 jar, the bad import statement makes the test 
constructor throw.

This is so ugly.

I wonder if I could do a Class.forName(), and if it doesn't throw, I 
know I can use reflection to do the new stuff, and avoid importing the 
new class.

This is so ugly.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: cvs commit: ant/docs/manual install.html

Posted by Steve Cohen <sc...@javactivity.org>.
Stefan Bodewig wrote:
> On 12 May 2005, <sc...@apache.org> wrote:
> 
> 
>>  +    For all users, a minimum version of commons-net of 1.4.0 is now required.
> 
> 
> Is this really true?
> 
> I understand it is required to compile <ftp> or if you use one of
> the new features.  But if you use <ftp> the same way you did
> before and use a binary installation of Ant, 1.2.x should work as
> well, not?
> 
> Stefan
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
> 
> 
> 

You are correct, sir.  It won't compile but it will run against the 
older jar, as long as the new functionalities are not called.  I forget 
that not everyone wants to build ant :-).

The existing tests can be run successfully if you ignore the errors. 
You see, Antoine, your tests have already proven their value!

I will revise this documentation, and also change the code to output a 
more meaningful error message if anyone tries to use the new features 
with an older jar.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: cvs commit: ant/docs/manual install.html

Posted by Stefan Bodewig <bo...@apache.org>.
On 12 May 2005, <sc...@apache.org> wrote:

>   +    For all users, a minimum version of commons-net of 1.4.0 is now required.

Is this really true?

I understand it is required to compile <ftp> or if you use one of
the new features.  But if you use <ftp> the same way you did
before and use a binary installation of Ant, 1.2.x should work as
well, not?

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org