Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala SBT和x27上的地图;在保持作用域的同时设置什么?_Scala_Sbt - Fatal编程技术网

Scala SBT和x27上的地图;在保持作用域的同时设置什么?

Scala SBT和x27上的地图;在保持作用域的同时设置什么?,scala,sbt,Scala,Sbt,在插件中,我有一个设置键,比如: val age = settingKey[Int]("An age") 用户可以在其build.sbt的不同范围内定义此age: age in Somewhere := 13 age in Whatever := 55 现在,在插件中,我想映射它们的所有定义,如下所示: someOtherKey in ___ := if ((age in ___).value <= 10) "young" else "old" SomeOther输入:=if((年

在插件中,我有一个
设置键
,比如:

val age = settingKey[Int]("An age")
用户可以在其
build.sbt
的不同范围内定义此
age

age in Somewhere := 13

age in Whatever := 55
现在,在插件中,我想映射它们的所有定义,如下所示:

someOtherKey in ___ := if ((age in ___).value <= 10) "young" else "old"

SomeOther输入:=if((年龄).value好的,您可以使用派生设置,这是一种高级且未记录的API。其思想是,如果存在底层键,则您的设置将自动推送到给定的配置中。我们在内部使用它来实现testOptions之类的功能,但在0.13系列中尚未完全充实。以下是一个示例:

inScope(Global)(Seq(
   Def.derive(someOtherKey := if(age.value <= 10) "young" else "old")
}
inScope(全球)(序号(

Def.derivate(someOtherKey:=if(age.value)真棒,正是我需要的。谢谢!
inScope(Global)(Seq(
   Def.derive(someOtherKey := if(age.value <= 10) "young" else "old", filter = _.project.isSelect)
}