using SelfType to mixin compiler options #5779
-
In my evaluation project it would be great to define a SelfType in order to mixin compiler-options. trait KotlinCompilerOptions {
this: KotlinModule =>
override def kotlinVersion: T[String] = Versions.kotlin
override def kotlincPluginMvnDeps: T[Seq[Dep]] = Seq(
mvn"org.jetbrains.kotlin:kotlin-allopen-compiler-plugin:${kotlinVersion()}",
mvn"org.jetbrains.kotlin:kotlin-noarg-compiler-plugin:${kotlinVersion()}"
)
override def kotlincOptions = Seq(
"-jvm-target=21",
"-P",
"plugin:org.jetbrains.kotlin.allopen:preset=spring",
"-P",
"plugin:org.jetbrains.kotlin.noarg:preset=jpa",
)
}
object app extends KotlinMavenModule with KotlinCompilerOptions{
object test extends KotlinMavenTests with KotlinCompilerOptions
}
// another use-case would be for JavacCompilerOptions which are needed by multiple modules but not all Unfortunately this seem not possible because the Task.Simple macro is not able to work with this. Removing the type annotations fixes the self-type definition but breaks when doing the actual mixin because now the types differ (String != T[String]) Since the macro seems not to be able to wrap the parameters I tried creating a Task.Anon, but this is not the proper type I am not sure if this is a bug (should KotlinMavenTests not inherit the settings I've made on KotlinMavenModule), a missing feature, or if I am completely wrong here. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@lostiniceland can you do trait KotlinCompilerOptions extends mill.Module{
this: KotlinModule => That might make the |
Beta Was this translation helpful? Give feedback.
-
Beside the |
Beta Was this translation helpful? Give feedback.
@lostiniceland can you do
That might make the
members must be defs defined in a Module
error go away