One can write something like
(managedClasspath in Compile).value
to obtain the value of managedClasspath
in the Compile
configuration.
The type of (managedClasspath in Compile)
is yet again a sbt.TaskKey (because we call the in
method with a ConfigKey
).
There is however no value
method on SettingKey
or TaskKey
, and I can't find any implicit class that provides such a method. So how come it exists? Is this some magical macro voodoo?
It's both, there are a few things at work components:
*XYZKey[_]
can be converted into an appropriate Initialize[_]
instance via an implicit. This, by default, is an initializer that reads the existing value at the key and returns it.sbt.std.MacroValue[T]
type is a compile-time only class which holds something that can have .value called on it: http://www.scala-sbt.org/0.13.5/api/index.html#sbt.std.MacroValue. We use this to track the underlying instances in the macro and denote that they have special significance (i.e. we have to rework the code such that we wait for the value to exist before using it).sbt.Def
object has a set of implicits called macroValueXYZ
which lift Initialize[_]
instances into the macro API.So, as you can see, it's a bit of black magic through our internals to get there. We'll have to look into a way to better document the API in a scaladoc tool.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With