2011-10-05 178 views
1

这里是新的Ant用户。我创建了一个条件任务,它作为Maven Ant插件运行。我面临的问题是条件目标:在构建期间未找到“ui-test-condition”。如何用Maven-Ant正确设置条件任务?

返回的错误是:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (uitests) on project myProject: An Ant BuildException has occured: Target "ui-test-condition" does not exist in the project "maven-antrun-". It is used from target "ui-test-run". -> [Help 1] 

这表明在下面的代码语法错误,但我无法找出问题。任何援助非常感谢。

<target name="ui-test" depends="ui-test-run,ui-test-skip"/> 

<target name="ui-test-condition"> 
    <condition property="ui-test-condition-run"> 
    <and> 
     <istrue value="${ui.test}"/> 
    </and> 
    </condition> 
</target> 

<target name="ui-test-run" depends="ui-test-condition" if="ui-test-condition-run"> 
    <echo>Running tests</echo> 
    <exec dir="src/main/webapp/ui" executable="src/main/webapp/ui/${some.executable}" 
    resolveexecutable="true" failonerror="true"> 
    <arg value="-e" /> 
    <arg value="foo/run" /> 
    </exec> 
</target> 

<target name="ui-test-skip" depends="ui-test-condition" unless="ui-test-condition-run"> 
    <echo>Tests are skipped</echo> 
</target> 
+0

不一定是这个问题的答案,但我能够重构上述以匹配另一个用户的查询:http://stackoverflow.com/questions/2324392/run-a-ant-task-in-maven-only - 如果-A-财产被设定 –

回答

0

我有完全相同的问题,我找到了答案是,目标的depends财产不被行家-antrun-插件支持。

摘录的

http://maven.apache.org/plugins/maven-antrun-plugin/usage.html

Ultimately, you could specify some Ant <target/> attributes in the <target/> tag. Only depends attribute in Ant <target/> is not wrapped. 

这并不妨碍工作的特点,至少不是从经验;通过删除depends属性并正确定购目标,它就可以工作。

而且,maven-antrun-plugin只考虑最后的target。因此,您需要找到一种方法直接在该目标中评估自己的状况。