How can I do that for debug builds only?
# gradle
p
How can I do that for debug builds only?
t
dirty way:
Copy code
tasks.withType(JavaCompile::class.java).filter { it.name.contains("debug", ignoreCase = true) }.all { ... }
better way imho maybe using android plugin info to get all debug variant tasks
p
And how do I do it the clean way? 😉
t
Copy code
fun getPluginConfigureAction(): (Plugin<Any>) -> Unit = { _ ->
                project.extensions.configure(BaseExtension::class.java) { ext ->
                    ext.buildTypes.filter { it.isDebuggable }.forEach {
                        it.javaCompileOptions.annotationProcessorOptions
                            .arguments["dagger.formatGeneratedSource"] = "disabled"
                    }
                }
            }

            project.plugins.withId("com.android.application", getPluginConfigureAction())
            project.plugins.withId("com.android.library", getPluginConfigureAction())
            project.plugins.withId("com.android.instantapp", getPluginConfigureAction())
            project.plugins.withId("com.android.feature", getPluginConfigureAction())
            project.plugins.withId("com.android.test", getPluginConfigureAction())
Theoretically should work, but it needs to be tested. 🤷‍♂️
p
Whatever I'm trying - it's still pretty printed