使用Ant Builder将文件复制到远程位置



请帮忙找出为什么我不能复制一个jar文件到ftp位置。它以C:作为远程位置根。请帮忙更正错误。

build . xml:

<?xml version="1.0" encoding="UTF-8"?>
<project>
    <target name="clean">
        <delete dir="D:/build"/>
    </target>
    <target name="compile">
        <mkdir dir="D:/build/classes"/>
        <javac srcdir="src" destdir="D:/build/classes"/>
    </target>
    <target name="jar">
        <mkdir dir="D:/build/jar"/>
        <jar destfile="D:/build/jar/ffjar.jar" basedir="D:/build/classes">
            <manifest>
                <attribute name="Main-Class" value="test.ant.Test"/>
            </manifest>
        </jar>
    </target>   
    <target name="run">
        <java jar="D:/build/jar/ffjar.jar" fork="true"/>
    </target>

    <target name="deploy">      
        <ftp server="ip"
           remotedir="/home/ecnet"
           userid="user"
           password="pass"
           depends="yes">
           <fileset dir="/home/ecnet/ffjar.jar"/>
        </ftp>
      </target>
</project>
输出:

Buildfile: C:UsersJoseph.MWorkPlace_Struts2CheckAntbuild.xml
clean:
   [delete] Deleting directory D:build
compile:
    [mkdir] Created dir: D:buildclasses
    [javac] C:UsersJoseph.MWorkPlace_Struts2CheckAntbuild.xml:11: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 1 source file to D:buildclasses
jar:
    [mkdir] Created dir: D:buildjar
      [jar] Building jar: D:buildjarffjar.jar
run:
     [java] Hello Ant World
deploy:
      [ftp] sending files
BUILD FAILED
C:UsersJoseph.MWorkPlace_Struts2CheckAntbuild.xml:34: C:homeecnetffjar.jar does not exist.
Total time: 7 seconds

这一行有问题

<fileset dir="/home/ecnet/ffjar.jar"/>

因为我相信你的Ant安装在C:驱动器,所以它正试图相应地解决这个路径。您需要将此路径更改为实际路径,例如:

<fileset dir="D:/build/jar/ffjar.jar"/>

我建议创建一个属性文件并在那里定义所有路径,并使用变量而不是硬编码build.xml中的所有路径

相关内容

  • 没有找到相关文章

最新更新