gpt4 book ai didi

java - 通过 maven-antrun-plugin 使用 antcontrib 任务

转载 作者:太空狗 更新时间:2023-10-29 22:50:32 28 4
gpt4 key购买 nike

我的 maven java 项目使用 maven-antrun-plugin 来执行部署我的应用程序的 deploy.xml ant 脚本。 deploy.xml 使用 <if>任务,这似乎是导致问题的原因;

[INFO] Executing tasks
[taskdef] Could not load definitions from resource net/sf/antcontrib/antlib.xml. It could not be found.

deploy:
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] An Ant BuildException has occured: The following error occurred while executing this line:
E:\My_Workspace\xxxxxx\xxxxxx\xxxxxxx\deploy.xml:24: Problem: failed to create task or type if
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.

这是我的 pom 中的 antrun 插件配置;

<plugin>
<inherited>false</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>remote-deploy</id>
<phase>install</phase>
<configuration>
<tasks>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath"/>

<property name="compile_classpath" refid="maven.compile.classpath" />
<property name="runtime_classpath" refid="maven.runtime.classpath" />
<property name="plugin_classpath" refid="maven.plugin.classpath" />

<echo message="compile classpath: ${compile_classpath}"/>
<echo message="runtime classpath: ${runtime_classpath}"/>
<echo message="plugin classpath: ${plugin_classpath}"/>

<ant antfile="${basedir}/deploy.xml">
<target name="deploy" />
</ant>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.7.1</version>
</dependency>
</dependencies>
</plugin>

.. 这是我的 deploy.xml 中的相关部分;

<target name="deploy" if="deploy">
<if> <!-- line 24 -->
<and>

为什么我查看我的 maven 仓库我可以看到 ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar当我查看 jar 内部时,我可以看到 net/sf/antcontrib/antcontrib.properties所以没问题。

当我检查 maven.compile.classpath 的值时, maven.compile.classpathmaven.compile.classpath我看不到对 antcontrib 的任何引用,这可能是问题所在吗?为什么他们不出现 antcontrib被定义为依赖?

最佳答案

我认为将ant添加到编译类路径以运行maven插件不是一个好主意。

我使用 Maven 3.0.4,它通过为 ant-contrib 标签指定命名空间来工作,例如:

<configuration>
<target>
<echo message="The first five letters of the alphabet are:"/>
<ac:for list="a,b,c,d,e" param="letter" xmlns:ac="antlib:net.sf.antcontrib">
<sequential>
<echo>Letter @{letter}</echo>
</sequential>
</ac:for>
</target>
</configuration>

我的 maven-antrun-plugin 依赖项:

<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.8.1</version>
</dependency>
</dependencies>

关于java - 通过 maven-antrun-plugin 使用 antcontrib <if> 任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4724007/

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