4

I have a pom.xml file with some groovy code that is run by gmaven-plugin. I would like to detect if a setting is missing and then have maven exit with 'BUILD FAILURE'. I would prefer to be able to display an error message as well, but I can manually do that so no big deal. This works but is very ugly (since it makes maven say "Exception: / by zero")

testResult = true
if (testResult) {
    println "good keep going"
} else {
    println "bad make maven fail"
    someVal = 1.0 / 0.0
}
Solx
  • 4,611
  • 5
  • 26
  • 29

1 Answers1

1

You can always explicitly throw an exception, e.g.:

throw new RuntimeException('build is failing! call the fire brigade!');
Eliran Malka
  • 15,821
  • 6
  • 77
  • 100
  • 1
    Seems better than my idea, assuming that the error actually shows up in the console. – Solx Mar 01 '17 at 21:02