Some DCL questions: - In a single project are `b...
# declarative-gradle
y
Some DCL questions: • In a single project are
build.gradle(.kts)
+
settings.gradle.dcl
OR
build.gradle.dcl
+
settings.gradle(.kts)
valid combinations? • In a multi-project, can some subprojects use the declarative syntax, but the other can be normal Groovy or Kotlin DSL?
p
Yes. You can totally mix them, except you cannot use the DCL features with Groovy DSL, but you can use normal plugins/extensions in Groovy. To use DCL in Kotlin, you need to enable it via a property: org.gradle.kotlin.dsl.dcl=true
y
That is really helpful info.
v
Why should you want to use DCL in Kotlin DSL? For a block-by-block migration, or any other valid use-case?
p
Mostly because DCL is very limited
v
Ah, to try DCL where possible while still using Kotlin DSL where it is not yet usable, I see.
p
Yes. And you might might not want to create a local feature only for eg wiring a Property via a Gradle Property. Creating a local feature still requires too much boilerplate.
Or Version catalogs or typed projects accessors, the list is long
👌 1
y
Are there any other (non-IDE) Gradle/system properties that need to be defined to activate the DCL feature?
p
To use DCL either name your file .dcl or use the property to use DCL in .kts
👍 1
What IDE feature?
You need to enable it via a Gradle Property, ideally by storing it in gradle.properties: https://github.com/hfhbd/adventOfCode/blob/main/gradle.properties#L13
y
I don't care about IDE support for my case. (ANd I just wanted to avoid references to
gradle.declarative.studio.support
etc.)
Thanks for the info @Philip W. I should be able to finally add DCL support into GradleTest.
p
Keep in mind, there is no Gradle provided ecosystem yet, and the Kotlin ecosystem focuses on Kotlin JVM applications, other types do not have a (good) BuildModel.
y
That's fine. I just want to get an experimental feature out for GradleTest.
p
Yeah, but your feature should extend an existing project type, like Java library.
Ideally, it should extend the Gradle Development feature that adds the gradle plugin feature (to write plugins).
Main reason: a user can only apply 1 project type per project. You cannot “wildly” apply multiple plugins in DCL (you can with DCL in kts).
y
Understood.