trevjonez / composer-gradle-plugin

Gradle task type and plugin for interacting with https://github.com/gojuno/composer
Apache License 2.0
54 stars 18 forks source link

Graceful Exit 1 handling #53

Closed dannybduval closed 4 years ago

dannybduval commented 4 years ago

Logged https://github.com/gojuno/composer/issues/176 against composer, but seeing if it is felt to go here.

As mentioned in the above issue, any failure in the chain of observers fails, it results in an exit one.

In our case we have custom tasks created to handle this. e.g.:


project.task(testDebugCustomIntegrationTest, type: DefaultTask, dependsOn: [testDebugComposer, clearConnectedDevices])

project.task(clearConnectedDevices, type: ClearDevicesTask, dependsOn: testDebugComposer) {
  mustRunAfter testDebugComposer
}

Where this task is a custom task that goes to each connected emulator and wipes them after a run finishes.

Even if we run with --continue, the process will error and not go to the task that mustRunAfter testDebugComposer.

trevjonez commented 4 years ago

you can use the finalizedBy relationship between the tasks so the clear task will always be ran.

tasks.named("testDebugComposer").configure {
  finalizedBy tasks.named("clearConnectedDevices")
}

IIRC you need to remove the dependsOn: testDebugComposer because the bidirectional relation of depends and finalized by messes with things so they don't behave as expected.

but it will then allow you to run the clear task with or without the composer task

https://docs.gradle.org/current/dsl/org.gradle.api.Task.html#org.gradle.api.Task:finalizedBy https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:finalizer_tasks "Finalizer tasks will be executed even if the finalized task fails."

otherwise you might be able to subclass the composer task