Loïc Lamarque
12/13/2023, 9:37 PM// In file 'Subproject.kt'
fun Settings.include(subproject: Subproject): Unit = include("$subproject")
fun DependencyHandler.project(subproject: Subproject): ProjectDependency = project(":$subproject")
enum class Subproject {
First,
Second;
override fun toString(): String = name.lowercase()
}
// In file 'settings.gradle.kts'
include(Subproject.First)
include(Subproject.Second)
// In file 'second/build.gradle.kts'
dependencies { implementation(project(Subproject.First)) }
Javier
12/13/2023, 10:44 PMbuildSrc
for thatJavier
12/13/2023, 10:45 PMenableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
so you can just do
implementation(projects.subproject.first)
Vampire
12/14/2023, 2:05 AMbuildSrc
is not build before the settings script execution, but after.
You can though have code in a project you add to the settings classpath either in the buildscript
block or via a (possibly no-action) settings plugin that you apply, that can also come from an included build. Then those classes would also be available in the build scripts.
But I agree with Javier that it might make much more sense to enable the project accessors instead.Loïc Lamarque
12/14/2023, 10:58 AMVampire
12/14/2023, 11:20 AMbuildSrc
in settings script. 🙂Vampire
12/14/2023, 11:20 AMLoïc Lamarque
12/14/2023, 6:14 PMbuildSrc
in the settings script, but Gradle couldn't resolve it...Vampire
12/14/2023, 6:50 PMbuildSrc
I said you cannot use anything from there in the settings script unless you are on an ancient Gradle version.Loïc Lamarque
12/15/2023, 7:41 AMVampire
12/15/2023, 7:52 AMLoïc Lamarque
12/15/2023, 8:16 AMJavier
12/15/2023, 8:17 AMapply
function does nothingLoïc Lamarque
12/15/2023, 8:18 AMVampire
12/15/2023, 8:28 AMLoïc Lamarque
12/15/2023, 8:30 AM