jcdise
jcdise

Reputation: 3

How to fail Ant build when mvn task fails?

I have an Ant build which calls mvn tasks using "artifact:mvn ..." as described in http://maven.apache.org/ant-tasks/examples/mvn.html.

Problem is, even when one of these inner mvn builds ends in FAILURE, my overall Ant build will still report BUILD SUCCESSFUL at the end.

How can I make my Ant build report a build failure when at least one of the mvn tasks fails?

Upvotes: 0

Views: 720

Answers (1)

lifus
lifus

Reputation: 8512

The mvn task is a subclass of the Ant java task and supports all of its options

The task may fail right away with failonerror="true" or you might verify resultproperty later on.

By default the return code of a <java> is ignored. Alternatively, you can set resultproperty to the name of a property and have it assigned to the result code (barring immutability, of course). When you set failonerror="true", the only possible value for resultproperty is 0. Any non-zero response is treated as an error and would mean the build exits.

Upvotes: 3

Related Questions