Search code examples
androidgradleandroid-lint

Have different Android lintOptions for different gradle tasks


I want to run the Android Lint both locally (IDE) and on the CI.

I have a task like this, which I want the abortOnError as true when run on CI but false when ran locally.

task lintCI {

outputs.upToDateWhen { false }

subprojects.each { project ->
    dependsOn(project.tasks.matching { (it.name == 'lint') })
}}

I have tried

project.android {
    lintOptions {
      warningsAsErrors true
      abortOnError false
    }
}

but I am getting Android tasks have already been created.

Any Idea how to change these options per task ?


Solution

  • So for anyone searching for an answer to this, I failed to "override" this setting, but I was able to separate the behavior between the local machiene and the CI by adding a check of an environment variable (isCI), and based on this condition I was setting the abortOnError.