0

When I have the following build.gant

target(example: 'example target') {
  echo(message: "name : ${it.name}, description: ${it.description}")
}

target(alwaysFails: 'never succeed') {
  27
}

If I run gant alwaysFails, the build failed. But if I run gant alwaysFails example, the build succeeded.

Actually I expected build failed and 'example' target did not run.

How can I make gant stop on target failure?

KwonNam
  • 686
  • 1
  • 8
  • 19

2 Answers2

1

I believe you have to make the targets depend on each other, so

target(alwaysFails: 'never succeed') {
  27
}

target(example: 'example target') {
  depends( alwaysFails )
  echo( message: "name : ${it.name}, description: ${it.description}" )
}

Then running:

gant example

Will run alwaysFails and then run example if it succeeds (which it never does). This way I believe you get the functionality you wanted.

tim_yates
  • 167,322
  • 27
  • 342
  • 338
  • Thanks, but the problem is that `alwaysFailes` is an optional target. I must not make `example` depend on `alwaysFails`. It's something like `clean` and `compile` targets. Sometimes we need to call `gant clean compile` but, `compile` should not depend on `clean` – KwonNam Oct 17 '12 at 13:51
0

I make the target throws an exception when it has to fail always. It works.

throw new RuntimeException('error message..')
KwonNam
  • 686
  • 1
  • 8
  • 19