scohen 2005/05/13 03:26:20
Modified: src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java
docs/manual install.html
Added: src/main/org/apache/tools/ant/taskdefs/optional/net
FTPConfigurator.java
Log:
Add FTPConfigurator class so as to avoid forcing users to upgrade to version
1.4.0 of commons-net.
As long as users use the ftp task as they have previously, they do not need
1.4.0.
Revision Changes Path
1.69 +48 -37
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.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- FTP.java 12 May 2005 04:04:59 -0000 1.68
+++ FTP.java 13 May 2005 10:26:20 -0000 1.69
@@ -17,7 +17,6 @@
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;
@@ -1323,11 +1322,47 @@
/**
+ * @return Returns the systemKeyConfig.
+ */
+ String getSystemKeyConfig() {
+ return systemKeyConfig;
+ }
+ /**
+ * @return Returns the defaultDateFormatConfig.
+ */
+ String getDefaultDateFormatConfig() {
+ return defaultDateFormatConfig;
+ }
+ /**
+ * @return Returns the recentDateFormatConfig.
+ */
+ String getRecentDateFormatConfig() {
+ return recentDateFormatConfig;
+ }
+ /**
+ * @return Returns the serverLanguageCodeConfig.
+ */
+ String getServerLanguageCodeConfig() {
+ return serverLanguageCodeConfig;
+ }
+ /**
+ * @return Returns the serverTimeZoneConfig.
+ */
+ String getServerTimeZoneConfig() {
+ return serverTimeZoneConfig;
+ }
+ /**
+ * @return Returns the shortMonthNamesConfig.
+ */
+ String getShortMonthNamesConfig() {
+ return shortMonthNamesConfig;
+ }
+ /**
* Checks to see that all required parameters are set.
*
* @throws BuildException if the configuration is not valid.
*/
- protected void checkConfiguration() throws BuildException {
+ protected void checkAttributes() throws BuildException {
if (server == null) {
throw new BuildException("server attribute must be set!");
}
@@ -1352,6 +1387,15 @@
throw new BuildException("chmod attribute must be set for chmod "
+ "action!");
}
+
+ if (this.isConfigurationSet) {
+ try {
+ Class.forName("org.apache.commons.net.ftp.FTPClientConfig");
+ } catch (ClassNotFoundException e) {
+ throw new BuildException(
+ "commons-net.jar >= 1.4.0 is required for at least one of
the attributes specified.");
+ }
+ }
}
@@ -2025,40 +2069,7 @@
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);
+ FTPConfigurator.configure(ftp, this);
}
}
@@ -2069,7 +2080,7 @@
* correctly.
*/
public void execute() throws BuildException {
- checkConfiguration();
+ checkAttributes();
FTPClient ftp = null;
1.1
ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java
Index: FTPConfigurator.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.optional.net;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPClientConfig;
import org.apache.tools.ant.Project;
/**
* The sole purpose of this class is (note that it is package-private
* is to serve as a separate, static compilation unit for importing
* FTPClientConfig, to enable users who wish to use the FTP task
* without using its new features to avoid the need to
* upgrade to jakarta-commons-net 1.4.0, where FTPClientConfig was
* introduced.
*/
class FTPConfigurator {
/**
* configures the supplied FTPClient with the various
* attributes set in the supplied FTP task.
* @param client the FTPClient to be configured
* @param task the FTP task whose attributes are used to
* configure the client
* @return the client as configured.
*/
static FTPClient configure(FTPClient client, FTP task) {
FTPClientConfig config;
String systemKeyConfig = task.getSystemKeyConfig();
if (systemKeyConfig != null) {
config = new FTPClientConfig(systemKeyConfig);
task.log("custom config: system key = "
+ systemKeyConfig, Project.MSG_VERBOSE);
} else {
config = new FTPClientConfig();
}
String defaultDateFormatConfig = task.getDefaultDateFormatConfig();
if (defaultDateFormatConfig != null) {
config.setDefaultDateFormatStr(defaultDateFormatConfig);
task.log("custom config: default date format = "
+ defaultDateFormatConfig, Project.MSG_VERBOSE);
}
String recentDateFormatConfig = task.getRecentDateFormatConfig();
if (recentDateFormatConfig != null) {
config.setRecentDateFormatStr(recentDateFormatConfig);
task.log("custom config: recent date format = "
+ recentDateFormatConfig, Project.MSG_VERBOSE);
}
String serverLanguageCodeConfig = task.getServerLanguageCodeConfig();
if (serverLanguageCodeConfig != null) {
config.setServerLanguageCode(serverLanguageCodeConfig);
task.log("custom config: server language code = "
+ serverLanguageCodeConfig, Project.MSG_VERBOSE);
}
String serverTimeZoneConfig = task.getServerTimeZoneConfig();
if (serverTimeZoneConfig != null) {
config.setServerTimeZoneId(serverTimeZoneConfig);
task.log("custom config: server time zone ID = "
+ serverTimeZoneConfig, Project.MSG_VERBOSE);
}
String shortMonthNamesConfig = task.getShortMonthNamesConfig();
if (shortMonthNamesConfig != null) {
config.setShortMonthNames(shortMonthNamesConfig);
task.log("custom config: short month names = "
+ shortMonthNamesConfig, Project.MSG_VERBOSE);
}
client.configure(config);
return client;
}
}
1.83 +3 -1 ant/docs/manual/install.html
Index: install.html
===================================================================
RCS file: /home/cvs/ant/docs/manual/install.html,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -r1.82 -r1.83
--- install.html 12 May 2005 04:04:59 -0000 1.82
+++ install.html 13 May 2005 10:26:20 -0000 1.83
@@ -425,7 +425,9 @@
<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.4.0 is now required.
+ For all users, a minimum version of commons-net of 1.4.0 is recommended.
Earlier
+ versions did not support the full range of configuration options, and
1.4.0 is needed
+ to compile Ant.
</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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]