Ignore Gradle Build Failure and continue build script?
Asked Answered
S

3

19

Managing Android's dependencies with Gradle is done in a weird way. They have to be downloaded differently into a local repo. This is a pain when setting up CI build as there are multiple nodes this could run on. As such I'm using the sdk-manager-plugin to have the Android dependencies downloaded at build time. There seems to be an old bug that I'm experiencing with the sdk-manager-plugin though in that it will download the dependencies at build time, but they won't be available on that command.

The next time the command is run everything works fine (as everything is already downloaded), but I need to find a way to ignore the build failure of the first gradle command so that everything is downloaded and good to go for the second. I realize this is hacky, but I'm done messing with this.

Ideally something like this would work:

./gradlew clean --ignoreBuildFailures
./gradlew distributeCIBuild

The closest thing I could find in the Gradle documentation is --quite but that doesn't look like it'd work.

Any creative solutions welcome.

Snavely answered 11/3, 2015 at 22:11 Comment(5)
What about --continue?Telesis
I can't find any documentation on --continue.Snavely
Try running ./gradlew --help or looking at [1]. The description is "Continues task execution after a task failure". [1]: gradle.org/docs/current/userguide/gradle_command_line.htmlTelesis
In the example I post above with the fake --ignoreBuildFailures, do you think it'd work if I replace that with --continue? It sounds like it'd still fail the build after the clean was run. It just saves it till the end.Snavely
That appears to have worked (although it's difficult to reproduce sometimes). Would you mind creating an answer, and I'll mark it correct in a day or so?Snavely
T
40

The flag to use is --continue.

From the documentation:

Continues task execution after a task failure.

Telesis answered 11/3, 2015 at 22:38 Comment(4)
thanks for the very very valuable answer. I was able to solve a client deployment issue because of this. :)Bacteriology
@UtkarshMankad you cannot be serious :oBuonaparte
Our way of enabling "Warnings as Errors" but keeping things easy for "trying things out".Indoeuropean
in which file do i need to add this lineCommorancy
O
5

add this in the build.gradle file :

tasks.withType(JavaCompile) {
    options.failOnError(false)
}
Olcott answered 29/9, 2020 at 11:47 Comment(0)
K
2

You can use ignoreExitValue

task ktlint(type: JavaExec, group: "verification") {
    description = "Check Kotlin code style."
    ignoreExitValue = true
}
Kinin answered 10/12, 2022 at 10:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.