Slackbot
01/01/2024, 4:34 PMThomas Broyer
01/01/2024, 5:08 PMSourceSetContainer is available as the sourceSets extension on the project, that should be available right away (type-safe accessor) in a precompiled script plugin (assuming you applied the jvm-cosystem-plugin in your plugins{} block).
In other words, "just" use sourceSets.create(…) .
https://github.com/gradle/gradle/blob/1501cc643d9723e053739128ac718145210e3185/pla[…]vm/src/main/java/org/gradle/api/plugins/JvmEcosystemPlugin.java
https://github.com/gradle/gradle/blob/1501cc643d9723e053739128ac718145210e3185/pla[…]a-base/src/main/java/org/gradle/api/plugins/JavaBasePlugin.javaPhilip W
01/01/2024, 5:23 PMclass CreateSourceSetContainerPlugin @Inject constructor(private val sourceSets: SourceSetContainer) : Plugin<Project> {
override fun apply(target: Project): Unit = with(target) {
if (extensions.findByType<SourceSetContainer>() == null) {
extensions.add("sourceSets", sourceSets)
}
}
}
But ideally, there should be a way to support service injection with precompiled scripts.Vampire
01/01/2024, 10:23 PMjvm-ecosystem plugin adds the source set container.
Actually the only things that plugin does, is creating the source set container, configuring the strategy how variants are derived from non GMM metadata, and configuring the attribute schema accordingly.
If you want to create a new language plugin that lives in the JVM ecosystem, why not simply applying the jvm-ecosystem plugin?Vampire
01/01/2024, 10:25 PMinterface SourceSetContainerProvider {
@get:Inject
val sourceSets: SourceSetContainer
}
val sourceSets = objects.newInstance(SourceSetContainerProvider::class.java).sourceSetsPhilip W
01/01/2024, 10:29 PM