Apache Ant 的 FTP Task 需要依赖 apache common-net 包。如果需要使用 FTP 任务, 需要将 common-net 包放到 $ANT_HOME/lib 下。
如果是 Ubuntu 用户,并且用 apt-get 安装的 Ant, 可以使用如下脚本:
wget http://www.fayea.com/apache-mirror//commons/net/binaries/commons-net-3.1-bin.zip
unzip commons-net-3.1-bin.zip
sudo cp commons-net-3.1/commons-net-3.1.jar /usr/share/ant/lib/
rm -rf commons-net-3.1
rm -rf commons-net-3.1-bin.zip
Gist: https://gist.github.com/4030368
如果是 Windows 用户, 需要自行下载 apache common-net 3.1 包, 并且将 commons-net-3.1.jar 放到 %ANT_HOME%/lib 下
安装好后,便可以使用FTP指令:
这个是远程发布项目的脚本
<?xml version="1.0" encoding="utf-8" ?>
<project name="cas" default="rupload">
<description>The cas project ant script tools</description>
<property environment="env"/>
<property name="basedir" value="." />
<property name="tools.ruby" value="${basedir}/tools/ruby"/>
<property name="ftp.host" value="192.168.1.42"/>
<property name="ftp.username" value="tomcat"/>
<property name="ftp.password" value="tomcat"/>
<property name="ftp.remotedir" value="webapps"/>
<property name="r.cmd.start" value="startup" />
<property name="r.cmd.stop" value="shutdown" />
<target name="rstart" description="start remote tomcat" >
<exec executable="ruby">
<arg value="${tools.ruby}/rtomcat.rb"/>
<arg value="${r.cmd.start}"/>
</exec>
</target>
<target name="rstop" description="start remote tomcat" >
<exec executable="ruby">
<arg value="${tools.ruby}/rtomcat.rb"/>
<arg value="${r.cmd.stop}"/>
</exec>
</target>
<target name="rrmfiles">
<ftp action="del" userid="${ftp.username}" password="${ftp.password}" server="${ftp.host}">
<fileset>
<include name="${ftp.remotedir}/${ant.project.name}/**"/>
<include name="${ftp.remotedir}/${ant.project.name}/**/*"/>
</fileset>
</ftp>
</target>
<target name="rrm" depends="rrmfiles" description="rm project folder from remote">
<ftp action="rmdir" userid="${ftp.username}" password="${ftp.password}" server="${ftp.host}"
remotedir="${ftp.remotedir}">
<fileset>
<include name="${ant.project.name}"/>
<include name="${ant.project.name}/**"/>
</fileset>
</ftp>
</target>
<target name="rcas" depends="rrm" description="create a cas folder on server" >
<ftp action="mkdir" userid="${ftp.username}" password="${ftp.password}" server="${ftp.host}"
remotedir="${ftp.remotedir}/${ant.project.name}">
</ftp>
</target>
<target name="rupload" depends="rcas" description="upload vas file to remote ftp" >
<ftp userid="${ftp.username}" password="${ftp.password}" server="${ftp.host}"
remotedir="${ftp.remotedir}/${ant.project.name}">
<fileset dir="${basedir}">
<excludesfile name=".project"/>
</fileset>
</ftp>
</target>
</project>
分享到:
相关推荐
apache ant安装包 apache ant安装包 apache ant安装包
apache ant使用例子, 一个可以运行的hello ant的myelipse工程实例。
apache-ant-1.6.5-bin 具体详细信息察看readme.txt
Ant 是一个 Apache 基金会下的跨平台的基于 Java 语言开发的构件工具。在我们详细了解 Apache Ant 之前, 让我们来讲解为什么构建工具是需要最先了解的。
Apache_Ant_中文手册.doc apache ant 讲解。。。
Apache Ant 1.6.2.jar
apache ant 1.10.13 版本apache ant 1.10.13 版本apache ant 1.10.13 版本apache ant 1.10.13 版本apache ant 1.10.13 版本apache ant 1.10.13 版本apache ant 1.10.13 版本apache ant 1.10.13 版本apache ant ...
Imagine that you are working on a large project. The project is a Java project and consists of many .java files. It consists of classes that are dependent on other ...see http://jakarta.apache.org/ant/.
Apache Ant,是一个将软件编译、测试、部署等步骤联系在一起加以自动化的一个工具,大多用于Java环境中的软件开发。 j2sdk1.5.0_03就是老版本的jdk.现在已经出到最新的7.0了。 本书为PDF格式 谢谢支持
在系统环境变量中新建一个ANT_HOME 的变量,值为D:\apache-ant-1.10.1。在path 变量中添加 %ANT_HOME%\bin; 如果没有path变量,则新建一个。 3、验证ant环境配置。开始-->运行-->输入cmd,打开dos命令窗口。...
Apache ANT的使用手册,即Apache官方Ant的Manual做成了CHM格式的文档,以备速查
apache-ant-1.9.16-bin.zip
apache ant 1.9.4 三个版本
Apache-ANT完美详解 Apache-ANT完美详解 Apache-ANT完美详解
专业的 Apache Ant 使用指南(精装本)
Apache Ant 与Junit 对Java工程联合测试DEMO
apache-ant-1.10.12-bin.tar.gz
apache-ant-1.7.1apache-ant-1.7.1apache-ant-1.7.1apache-ant-1.7.1apache-ant-1.7.1apache-ant-1.7.1apache-ant-1.7.1apache-ant-1.7.1apache-ant-1.7.1apache-ant-1.7.1apache-ant-1.7.1apache-ant-1.7.1apache-...
Apache-ant-1.9.2
NULL 博文链接:https://cuics-100.iteye.com/blog/909448