Improve binary-compatible Task overriding (in future Mill versions) #5873
lefou
started this conversation in
Development
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When overriding tasks in derived traits, we often have the issue, that the change is not binary compatible when it also references the
super
-task.The most prominent case is, when an already overridden task needs to reference it's super-task, but previously didn't.
For example, let's assume, we have a task
ScalaModule.allSourceFiles
and instead of directly listing all source files, we instead just want to add all Scala files to the already evaluated source files (fromJavaModule
).The corresponding MiMa report might look like this:
This makes it really hard to evolve Mills
trait
-based modules in a binary compatible way.A way we could avoid this issue would be to have the
super
-call to begin with, even if we don't need thesuper
-result right now.override def allSourceFiles: T[Seq[PathRef]] = Task { + val _ = super.findSourceFiles Lib.findSourceFiles(allSources(), Seq("scala", "java")).map(PathRef(_)) }
Since we already use a macro to generate the effective definition, it should be easy to generate a reference to the super-class as part of the macro implementation.
While this would solve the issue of changing existing tasks, we still can't add new overrides to existing task with a reference to the
super
-task without breaking binary compatibility.It would be nice, if we could somehow generate
super
-references for all potential tasks in eachtrait
thatextends Module
. This is probably only possible with an compiler plugin.Beta Was this translation helpful? Give feedback.
All reactions