开发者

How to correctly setup a conditional task with Maven-Ant?

New Ant user here. I've created a conditional task, which is run inside as a Maven Ant plugin. The issue I'm facing is the condition target: "ui-test-condition" is not being found during a build.

The error returned is:

[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开发者_如何学Python 1]

This would suggest a syntax error in the code below, however I'm unable to identify the issue. Any assistance is greatly appreciated.

<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>


I had the exact same problem and I found the answer is that the depends property of a target is not supported by maven-antrun-plugin.

Excerpt of 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.

That does not prevent the feature from working, at least not from experience; by just removing the depends property and ordering the targets properly, it works.

Moreover, only the last target is considered by maven-antrun-plugin. You therefore need to find a way to evaluate your condition directly in that target.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜