I might misunderstand what you are trying to do.
If I make your example more detailed, it will look like this:
val triggeredTaskKey = taskKey[Unit]("Triggered by compile") val anonymousTask = Def.task { println("TRIGGERED BY COMPILE") }.triggeredBy(compile in Compile) // I imagine the macro doing something like this triggeredTaskKey <<= anonymousTask map (identity)
It also does not call an anonymous compile task.
Note that <<= is a nice version of set that retrieves location information. And set is just an alias for Def.setting(key, value, position) , which in turn creates a new Setting instance. Note that the installation instance that is created internally has a constructor of these three parameters.
I do not think that there is a way in sbt to declare a parameter without a key (maybe I'm wrong here). However, it seems that you want to create a setting (which starts) without a key.
This may be caused by an error, I'm not sure that sbt should recursively track dependencies to search for tasks with the triggeredBy key in info . This is currently not the case (as shown in the trigger method.
Theoretically, you can do work around that creates settings with the right triggers associated with any arbitrary key. I'm not sure how this will work.
source share