使用antcontrib< if>通过maven-antrun-plugin完成任务 [英] Using antcontrib <if> task via maven-antrun-plugin

查看:254
本文介绍了使用antcontrib< if>通过maven-antrun-plugin完成任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

My maven java project uses the maven-antrun-plugin to execute a deploy.xml ant script that deploys my app. The deploy.xml uses the <if> task and this seems to be causing the problem;


[INFO]执行任务

[taskdef]无法从资源net / sf / antcontrib / antlib.xml加载定义。无法找到。

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

部署:

[INFO] ----------------- -------------------------------------------------- -----

[错误]构建错误

[INFO] ----------------------- ------------------------------------------------- < br>
[INFO]发生了Ant BuildException:执行此行时发生以下错误:

E:\ My_Workspace \ xxxxx \ xxxxxx \ xxxxxx \ devloy.xml :24:问题:无法创建任务或输入如果

原因:名称未定义。

操作:检查拼写。

操作:检查任何自定义任务/类型都已声明。

操作:检查是否有任何< presetdef> /< macrodef>声明已经发生。

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插件配置;

Here is the antrun plugin config from my pom;

<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中的相关部分;

.. and here is the relevant section from my deploy.xml;

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

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

Why I look in my maven repo I can see ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar and when I look inside the jar I can see net/sf/antcontrib/antcontrib.properties so no problem there.

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

When I check the values of maven.compile.classpath, maven.compile.classpath and maven.compile.classpath I can't see any reference to antcontrib, could this be the problem? Why don't they appear when antcontrib is defined as a dependancy?

推荐答案

好的,我已经解决了。

将依赖项移出< build>< plugin> 标记并将其与其他项目依赖项放在一起似乎已经成功了。

Moving the dependencies out of the <build><plugin> tag and putting them in with the other project dependencies seems to have done the trick.

这篇关于使用antcontrib&lt; if&gt;通过maven-antrun-plugin完成任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆