Slackbot
05/31/2022, 9:35 AMVampire
05/31/2022, 9:41 AMsubprojects
block at allLilly
05/31/2022, 9:46 AMsubprojects
block? I have multiple android.application/android.library
modules and I would like to disable the lint task for only the debug variants in these modules.Vampire
05/31/2022, 9:53 AMsubprojects { ... }
, allprojects { ... }
, project(...) { ... }
, configure(listOfProjects) { ... }
, and similar should be avoided due to various reasons, reaching from being non-idiomatic in current Gradle, over hindering more advanced features like parallel execution or configuration cache by introducing coupling between projects, to decreasing build maintainability.
The way to go is to have convention plugins where you define the common logic and then apply these convention plugins in the concrete build script where you want it to be applied.Lilly
05/31/2022, 10:02 AMconfiguration avoidance
? I have read about it and there are some specific APIs that should be avoided. I hope gradle makes all the old APIs deprecated sometime, really confusing.
I guess convention plugins are precompiled script plugins right? Do I have to use buildSrc
folder to apply these plugins in my current project or is there another way? Would be great if I have the plugin code in my current project and not in a standalone project which I have to maintain separately.Thomas Broyer
05/31/2022, 10:35 AMI guess convention plugins are precompiled script plugins right?"convention plugins" are plugins that set up conventions (rather than "add functionalities"), "precompiled script plugins" are one way to write them.
Thomas Broyer
05/31/2022, 10:37 AMpluginManagement { includeBuild("…") }
) than buildSrc
, but yes, that's the idea: keep them in your project unless you have a good reason to do otherwise.Lilly
05/31/2022, 10:39 AMbuildSrc
but to clarify: when I want to write such plugins in my current project, buildSrc is my only option?Vampire
05/31/2022, 10:41 AMbuildSrc
Vampire
05/31/2022, 10:42 AMLilly
05/31/2022, 10:42 AMincludeBuild
always an external project?Vampire
05/31/2022, 10:43 AMexternal
Lilly
05/31/2022, 10:43 AMVampire
05/31/2022, 10:44 AMbuildSrc
, but there is nothing hindering you too keep it in the same VCS. I for example often use gradle/build-logic
as alternative to buildSrc
Vampire
05/31/2022, 10:45 AMLilly
05/31/2022, 10:47 AMVampire
05/31/2022, 10:48 AM..
Lilly
05/31/2022, 10:49 AMVampire
05/31/2022, 10:51 AMMyproject
gradle
build-logic
build-logic.gradle.kts
settings.gradle.kts
wrapper
gradle-wrapper.*
src
build.gradle.kts
settings.gradle.kts
Lilly
05/31/2022, 10:52 AMLilly
01/27/2023, 11:25 AMimport org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
tasks.withType<KotlinCompilationTask<*>>().configureEach {
// Material3 is stable but most of its components are still likely to change
compilerOptions.freeCompilerArgs.add("-opt-in=androidx.compose.material3.ExperimentalMaterial3Api")
// Belongs to DialogProperties class
compilerOptions.freeCompilerArgs.add("-opt-in=androidx.compose.ui.ExperimentalComposeUiApi")
}
I then apply this plugin to multiple other precompiled plugins to avoid redundant code instead of placing it within a subprojects
block in the root build.gradle.kts file. Following this practice might end up with a lot of precompiled script plugins with a few lines of shared logic code. Would you say this is encouraged/good practice or is it better to have fewer plugin files but with redundant code?Vampire
01/27/2023, 12:56 PMLilly
01/27/2023, 4:01 PMVampire
01/28/2023, 4:01 AM