def % support

This commit is contained in:
Eugene Yokota 2023-01-20 16:14:26 -05:00
parent 9219ed6bd4
commit 9821f5e1b4
1 changed files with 7 additions and 11 deletions

View File

@ -53,6 +53,7 @@ import sbt.internal.server.ServerHandler
import sbt.librarymanagement.Configuration
import sbt.util.{ Show, Level }
import sjsonnew.JsonFormat
import scala.annotation.targetName
import scala.concurrent.{ Await, TimeoutException }
import scala.concurrent.duration.*
@ -222,17 +223,6 @@ trait ProjectExtra extends Scoped.Syntax:
keyNameColor
)
/*
final class Constructor(p: ProjectReference) {
def %(conf: Configuration): ClasspathDependency = %(conf.name)
def %(conf: String): ClasspathDependency = ClasspathDependency(p, Some(conf))
}
*/
def getOrError[T](state: State, key: AttributeKey[T], msg: String): T =
state.get(key).getOrElse(sys.error(msg))
@ -670,6 +660,12 @@ trait ProjectExtra extends Scoped.Syntax:
): Conversion[A, ClasspathDep[ProjectReference]] =
(a: A) => ClasspathDep.ClasspathDependency(a, None)
extension (p: ProjectReference)
def %(conf: Configuration): ClasspathDep.ClasspathDependency = %(conf.name)
@targetName("percentString")
def %(conf: String): ClasspathDep.ClasspathDependency =
ClasspathDep.ClasspathDependency(p, Some(conf))
extension [A1](in: Def.Initialize[Task[A1]])
def updateState(f: (State, A1) => State): Def.Initialize[Task[A1]] =
in(t => SessionVar.transform(t, f))