2

I have a multi-module app which uses a plugin to handle common settings for modules. One of the things I configure are some lint options. So far this was my implementation:

class MyPlugin : Plugin<Project> {
    override fun apply(project: Project) {
        project.plugins.apply("kotlin-android")
        val androidExtension = project.extensions.getByName("android")
        if (androidExtension is BaseExtension) {
            androidExtension.apply {
                lintOptions {
                    isAbortOnError = false
                    //other settings
                }
            }
        }
}

I am getting warnings about deprecation such as:

'isAbortOnError: Boolean' is deprecated. Overrides deprecated member in 'com.android.build.api.dsl.LintOptions'. Moved to lint.abortOnError

I would like to move to Lint as suggested, but BaseExtension does not have lint, only lintOptions. How to do it?

suue
  • 295
  • 6
  • 17

1 Answers1

1

You can use this in

project.configure<com.android.build.api.dsl.ApplicationExtension> {
   lint {
        abortOnError = true
    }
}

I'm using it with AGP 8.1.0-alpha10, but it will be probably valid also in older AGP.

BaseExtension is now part of the internal API and just because of compatibility with older projects.

You should now depend only on com.android.tools.build:gradle-api artifact instead of com.android.tools.build:gradle

At least in an ideal situation.

ATom
  • 15,960
  • 6
  • 46
  • 50