无法使用maven-antrun-plugin从ftp下载文件(检索到0个文件)

时间:2015-07-07 14:43:00

标签: maven ftp maven-antrun-plugin

我使用maven-antrun-plugin从FTP下载转储。

这是我的pom.xml:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.8</version>
            <executions>
                <execution>
                    <id>ftp</id>
                    <phase>package</phase>
                    <configuration>
                        <target>
                            <ftp action="get" 
                                 server="myserver" 
                                 remotedir="/remotedir/"
                                 userid="anonymous" 
                                 password="anonymous" 
                                 depends="yes" 
                                 verbose="yes">
                                <fileset dir="${project.build.directory}">
                                    <include name="**/*.*" />
                                </fileset>
                            </ftp>
                        </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>commons-net</groupId>
                    <artifactId>commons-net</artifactId>
                    <version>1.4.1</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.ant</groupId>
                    <artifactId>ant-commons-net</artifactId>
                    <version>1.8.1</version>
                </dependency>
            </dependencies>
        </plugin>

该插件似乎可以正常工作,但它不会下载我的转储(&#34; 0个文件检索&#34;)。

> main:
>       [ftp] Opening FTP connection to myserver
>       [ftp] connected
>       [ftp] logging in to FTP server
>       [ftp] login succeeded
>       [ftp] changing the remote directory to /remotedir/
>       [ftp] getting files fileset: Setup scanner in dir /myproject/target with patternSet{ includes: [**/*.*] excludes: [] }
>       [ftp] 0 files retrieved
>       [ftp] disconnecting

我可以在myserver / remotedir /上以匿名方式使用FileZilla下载此转储。当我故意尝试一个错误的遥控器时,它会正确警告我(&#34; 550无法更改目录。&#34;)所以我猜没有连接问题。

1 个答案:

答案 0 :(得分:0)

我找到了让它有效的方法!参考Ant manual,我在Ant FTP任务中使用被动属性。

  

如果您可以连接但不能上传或下载,请尝试将passive属性设置为true以使用现有(开放)通道,而不是让服务器尝试设置新连接。

这就是pom.xml中的内容:

<target>
    <ftp action="get" 
     server="myserver" 
     remotedir="/remotedir"
     userid="anonymous" 
     password="anonymous" 
     verbose="yes"
     passive="yes">

        <fileset dir="${project.build.directory}">
            <include name="**/*.*"/>
        </fileset>
    </ftp>
</target>
相关问题