I somehow bashed at it and found this working ```...
# gradle
u
I somehow bashed at it and found this working
Copy code
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
using
afterEvaluate
🙂
You could use something like this:
Copy code
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
Copy code
Could not get unknown property 'BaseExtension' for root project '...' of type org.gradle.api.Project.
t
com.android.build.gradle.BaseExtension
u
Copy code
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
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
@tapchicoma did you find a way to not call .ext but have the block as a receiver?
t
Doubt that this will work, as
configure
has
Action<Class>
as a second parameter. Maybe there is something in kotlin-dsl to solve it