gpt4 book ai didi

ant - 通过 Maven 中的 Ant FTP 任务上传文件

转载 作者:行者123 更新时间:2023-12-04 15:04:27 24 4
gpt4 key购买 nike

我正在尝试使用 Ant 任务上传文件。如果我直接使用 Ant 文件被上传,但如果我通过 Maven 调用 ant 任务(使用 maven-antrun-plugin )我收到以下错误:

发生 Ant BuildException:执行此行时发生以下错误:

/home/me/proj/build.xml:15: Problem: failed to create task or type ftp
Cause: the class org.apache.tools.ant.taskdefs.optional.net.FTP was not found.
This looks like one of Ant's optional components.
Action: Check that the appropriate optional JAR exists in
-ANT_HOME/lib

ant-commonsnet.jar 显然对 Ant 可用:
$ ls $ANT_HOME/lib | grep ant-commons-net
ant-commons-net.jar

Ant 类路径是为 maven-antrun-plugin 单独定义的,还是我遗漏了什么?

最佳答案

ant-commons-net.jar is clearly available to Ant



是的,但是 Maven 和 maven-antrun-plugin未使用本地 Ant 安装。

Is the Ant classpath defined separately for maven-antrun-plugin, or am I missing something?



使用未包含在 Ant 的默认 jar 中的 Ant 任务的方法记录在 Using tasks not included in Ant's default jar 中。 (这绝对有帮助):

To use Ant tasks not included in the Ant jar, like Ant optional or custom tasks you need to add the dependencies needed for the task to run to the plugin classpath and use the maven.plugin.classpath reference if needed.

<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>my-test-app</artifactId>
<groupId>my-test-group</groupId>
<version>1.0-SNAPSHOT</version>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>ftp</id>
<phase>deploy</phase>
<configuration>
<target>

<ftp action="send" server="myhost" remotedir="/home/test" userid="x" password="y" depends="yes" verbose="yes">
<fileset dir="${project.build.directory}">
<include name="*.jar" />
</fileset>
</ftp>

<taskdef name="myTask" classname="com.acme.MyTask" classpathref="maven.plugin.classpath"/>
<myTask a="b"/>

</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>ant</groupId>
<artifactId>ant-commons-net</artifactId>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.6.5</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>

关于ant - 通过 Maven 中的 Ant FTP 任务上传文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3935433/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com