spierce7
spierce7

Reputation: 15746

Ignore Gradle Build Failure and continue build script?

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.

Upvotes: 21

Views: 28130

Answers (3)

Linh Pham
Linh Pham

Reputation: 266

You can use ignoreExitValue

task ktlint(type: JavaExec, group: "verification") {
    description = "Check Kotlin code style."
    ignoreExitValue = true
}

Upvotes: 2

mourad m
mourad m

Reputation: 987

add this in the build.gradle file :

tasks.withType(JavaCompile) {
    options.failOnError(false)
}

Upvotes: 5

rciovati
rciovati

Reputation: 28063

The flag to use is --continue.

From the documentation:

Continues task execution after a task failure.

Upvotes: 43

Related Questions