https://kotlinlang.org logo
Title
u

ursus

10/09/2019, 5:17 AM
I somehow bashed at it and found this working
allprojects {
    ..

    afterEvaluate {
        // Apply lintOptions to every android module
        def android = it.extensions.findByName("android")
        if (android != null) {
            android.lintOptions {
                lintConfig rootProject.file("lint.xml")
            }
        }
    }

    ..
}
is there obviously something wrong with it? thanks
t

tapchicoma

10/09/2019, 7:46 AM
using
afterEvaluate
🙂
You could use something like this:
allprojects { subProject ->
    def lintConfigureAction = {
        subProject.extenstions.configure(BaseExtension.class) { ext ->
    ext.lintOptions { ... }
}
    subProject.plugins.withId("com.android.application", lintConfigureAction)
    subProject.plugins.withId("com.android.library, lintConfigureAction)
}
u

ursus

10/09/2019, 5:07 PM
Could not get unknown property 'BaseExtension' for root project '...' of type org.gradle.api.Project.
t

tapchicoma

10/09/2019, 5:09 PM
com.android.build.gradle.BaseExtension
u

ursus

10/09/2019, 5:10 PM
Extension of type 'BaseExtension' does not exist. Currently registered extension types: [ExtraPropertiesExtension, KtlintExtension]
Btw may I ask whats wrong with my one? I'm lost in gradle if it doesn't work
t

tapchicoma

10/09/2019, 6:07 PM
it should work, but discouraged to use with new lazy task creation and configuration API: https://docs.gradle.org/4.10.1/release-notes.html#restricting-cross-configuration-and-lifecycle-hooks-from-lazy-configuration-apis Also from my experience bad plugins could do additional configuration in this hook leading to undesired build behavior.
p

Paul Woitaschek

10/12/2019, 8:48 AM
@tapchicoma did you find a way to not call .ext but have the block as a receiver?
t

tapchicoma

10/12/2019, 9:11 AM
Doubt that this will work, as
configure
has
Action<Class>
as a second parameter. Maybe there is something in kotlin-dsl to solve it