-->

What does `<<=` mean in SBT?

2020-08-17 12:48发布

问题:

I see this <<= symbol in lot of SBT code, but I don't what it does.

I tried googling for this symbol as well but I did not get any answers.

Can you please point me to some documentation or an example which clearly explains what does this symbol mean and what does it do?

回答1:

Oh, the deep explanation is quite complicated.

Basically, the signature is:

def <<= (app: Initialize[Task[S]]): Setting[Task[S]]  =  macro std.TaskMacro.itaskAssignPosition[S] 

So it involves this macro:

/* Implementations of <<= macro variations for tasks and settings. These just get the source position of the call site.*/

    def itaskAssignPosition[T: c.WeakTypeTag](c: Context)(app: c.Expr[Initialize[Task[T]]]): c.Expr[Setting[Task[T]]] =
        settingAssignPosition(c)(app)

I already used this kind of operator when dealing with AspectJ compilation:

products in Compile <<= products in Aspectj

Basically, it means: base the code source on the AspectJ source files (generated with a plugin), not the classical ones.

I interpret it as a kind of "replaceAll/erase":
Replace bunch of files to compile by the files involving AspectJ annotations.



回答2:

Further to pfn's comment, this is described in the 0.12 docs under More Kinds of Settings. I guess it was dropped from the 0.13 docs because the same behaviour can now be defined in terms of :=.



标签: scala sbt