I'm using Gradle 8.12, and when I try to use `HexF...
# gradle
e
I'm using Gradle 8.12, and when I try to use
HexFormat
inside
buildSrc
, I get the following error. Not sure how to actually fix it.
m
Something is setting
apiLevel = 1.8
, are you using
kotlin-dsl
maybe?
e
Yup!
m
This is my usual suspect
I would just use the regular
org.jetbrains.kotlin.jvm
plugin with sam-with-receiver plugin if you really need it
e
I think
kotlin-dsl
is what I use to declare plugins. For example, without it I cannot specify
Copy code
gradlePlugin {
  plugins {
    register("projectModule") {
      ...
    }

    register("projectDocs") {
      ...
    }
  }
}
For declaring plugins, you just need
java-gradle-plugin
e
Damn, why such a low version. But thanks for finding out!
m
kotlin-dsl
is doing wayyyy too many things
No idea why they set a language version that is not the same as the embedded version
Maybe it's for compatibility reasons but it's not Gradle's decision to make
Especially in
buildSrc
you control the build classpath so 🤷
e
After removing kotlin-dsl, I discovered its functions ended up EVERYWHERE in my Gradle files
m
If you want the syntaxic sugar for Kotlin (
tasks.findByType<Foo>(), val task by registering
, etc...), you can add
gradleKotlinDsl()
as a dependency
e
Thank you! Btw, I found this
While it is supported to override the target language version when using the
kotlin-dsl
plugin to write build logic
Here https://github.com/gradle/gradle/pull/33041
However, it's not entirely clear what that means.
m
You can do some magic to override the
kotlin-dsl
defaults
This is a bit old now but I believe the concepts are similar
But really I would just use
org.jetbrains.kotlin.jvm
e
I'm trying that route, but jvm + sam-with-receiver results in a gazillion errors
😭 1
YESSS I DID IT! I basically had to reproduce EXACTLY the kotlin-dsl setup, minus the Kotlin version obviously. Lesson learnt, never blindly trust what is too easy to import and use, especially if for Gradle.
💪 1
Thank you again!
❤️ 1
m
That was one of the fastest solved
buildSrc
issues 😄
😂 3