Adjust to the code changes

This commit is contained in:
Eugene Yokota 2022-09-27 01:18:24 -04:00
parent 9a2ca3c4da
commit 54c12819df
10 changed files with 78 additions and 70 deletions

View File

@ -312,9 +312,9 @@ trait Parsers {
*/ */
lazy val NotQuoted = (NotDQuoteSpaceClass ~ OptNotSpace) map { case (c, s) => c.toString + s } lazy val NotQuoted = (NotDQuoteSpaceClass ~ OptNotSpace) map { case (c, s) => c.toString + s }
/** Parses a non-empty String value that cannot start with a double quote, but includes double quotes.*/ /** Parses a non-empty String value that cannot start with a double quote, but includes double quotes. */
lazy val NotQuotedThenQuoted = (NotQuoted ~ StringEscapable) map { lazy val NotQuotedThenQuoted = (NotQuoted ~ StringEscapable) map { case (s1, s2) =>
case (s1, s2) => s"""$s1\"$s2\"""" s"""$s1\"$s2\""""
} }
/** /**

View File

@ -296,11 +296,10 @@ object Cross {
} else { } else {
included included
.groupBy(_._2) .groupBy(_._2)
.foreach { .foreach { case (selectedVersion, projects) =>
case (selectedVersion, projects) => state.log.info(
state.log.info( s"Setting Scala version to $selectedVersion on ${projects.size} projects."
s"Setting Scala version to $selectedVersion on ${projects.size} projects." )
)
} }
} }
if (excluded.nonEmpty && !switch.verbose) { if (excluded.nonEmpty && !switch.verbose) {
@ -328,32 +327,31 @@ object Cross {
val projectScalaVersions = val projectScalaVersions =
structure.allProjectRefs.map(proj => proj -> crossVersions(extracted, proj)) structure.allProjectRefs.map(proj => proj -> crossVersions(extracted, proj))
if (switch.version.force) { if (switch.version.force) {
projectScalaVersions.map { projectScalaVersions.map { case (ref, options) =>
case (ref, options) => (ref, Some(version), options) (ref, Some(version), options)
} ++ structure.units.keys } ++ structure.units.keys
.map(BuildRef.apply) .map(BuildRef.apply)
.map(proj => (proj, Some(version), crossVersions(extracted, proj))) .map(proj => (proj, Some(version), crossVersions(extracted, proj)))
} else { } else {
projectScalaVersions.map { projectScalaVersions.map { case (project, scalaVersions) =>
case (project, scalaVersions) => val selector = SemanticSelector(version)
val selector = SemanticSelector(version) scalaVersions.filter(v => selector.matches(VersionNumber(v))) match {
scalaVersions.filter(v => selector.matches(VersionNumber(v))) match { case Nil => (project, None, scalaVersions)
case Nil => (project, None, scalaVersions) case Seq(version) => (project, Some(version), scalaVersions)
case Seq(version) => (project, Some(version), scalaVersions) case multiple =>
case multiple => sys.error(
sys.error( s"Multiple crossScalaVersions matched query '$version': ${multiple.mkString(", ")}"
s"Multiple crossScalaVersions matched query '$version': ${multiple.mkString(", ")}" )
) }
}
} }
} }
} }
val included = projects.collect { val included = projects.collect { case (project, Some(version), scalaVersions) =>
case (project, Some(version), scalaVersions) => (project, version, scalaVersions) (project, version, scalaVersions)
} }
val excluded = projects.collect { val excluded = projects.collect { case (project, None, scalaVersions) =>
case (project, None, scalaVersions) => (project, scalaVersions) (project, scalaVersions)
} }
if (included.isEmpty) { if (included.isEmpty) {
@ -376,10 +374,12 @@ object Cross {
// determine whether this is a 'specific' version or a selector // determine whether this is a 'specific' version or a selector
// to be passed to SemanticSelector // to be passed to SemanticSelector
private def isSelector(version: String): Boolean = private def isSelector(version: String): Boolean =
version.contains('*') || version.contains('x') || version.contains('X') || version.contains(' ') || version.contains('*') || version.contains('x') || version.contains('X') || version.contains(
' '
) ||
version.contains('<') || version.contains('>') || version.contains('|') || version.contains( version.contains('<') || version.contains('>') || version.contains('|') || version.contains(
'=' '='
) )
private def setScalaVersionsForProjects( private def setScalaVersionsForProjects(
instance: Option[(File, ScalaInstance)], instance: Option[(File, ScalaInstance)],
@ -389,25 +389,24 @@ object Cross {
): State = { ): State = {
import extracted._ import extracted._
val newSettings = projects.flatMap { val newSettings = projects.flatMap { case (project, version, scalaVersions) =>
case (project, version, scalaVersions) => val scope = Scope(Select(project), Zero, Zero, Zero)
val scope = Scope(Select(project), Zero, Zero, Zero)
instance match { instance match {
case Some((home, inst)) => case Some((home, inst)) =>
Seq( Seq(
scope / scalaVersion := version, scope / scalaVersion := version,
scope / crossScalaVersions := scalaVersions, scope / crossScalaVersions := scalaVersions,
scope / scalaHome := Some(home), scope / scalaHome := Some(home),
scope / scalaInstance := inst scope / scalaInstance := inst
) )
case None => case None =>
Seq( Seq(
scope / scalaVersion := version, scope / scalaVersion := version,
scope / crossScalaVersions := scalaVersions, scope / crossScalaVersions := scalaVersions,
scope / scalaHome := None scope / scalaHome := None
) )
} }
} }
val filterKeys: Set[AttributeKey[_]] = Set(scalaVersion, scalaHome, scalaInstance).map(_.key) val filterKeys: Set[AttributeKey[_]] = Set(scalaVersion, scalaHome, scalaInstance).map(_.key)

View File

@ -43,11 +43,14 @@ object Opts {
import sbt.io.syntax._ import sbt.io.syntax._
@deprecated("Use sonatypeOssReleases instead", "1.7.0") @deprecated("Use sonatypeOssReleases instead", "1.7.0")
val sonatypeReleases = Resolver.sonatypeRepo("releases") val sonatypeReleases = Resolver.sonatypeRepo("releases")
val sonatypeOssReleases = Resolver.sonatypeOssRepos("releases") // todo: fix
// val sonatypeOssReleases = Resolver.sonatypeOssRepos("releases")
@deprecated("Use sonatypeOssSnapshots instead", "1.7.0") @deprecated("Use sonatypeOssSnapshots instead", "1.7.0")
val sonatypeSnapshots = Resolver.sonatypeRepo("snapshots") val sonatypeSnapshots = Resolver.sonatypeRepo("snapshots")
val sonatypeOssSnapshots = Resolver.sonatypeOssRepos("snapshots")
// todo: fix
// val sonatypeOssSnapshots = Resolver.sonatypeOssRepos("snapshots")
val sonatypeStaging = MavenRepository( val sonatypeStaging = MavenRepository(
"sonatype-staging", "sonatype-staging",

View File

@ -275,8 +275,11 @@ object BuildServerProtocol {
val filter = ScopeFilter.in(workspace.scopes.values.toList) val filter = ScopeFilter.in(workspace.scopes.values.toList)
Def.task { Def.task {
val items = bspScalaTestClassesItem.result.all(filter).value val items = bspScalaTestClassesItem.result.all(filter).value
val successfulItems = anyOrThrow(items) val successfulItems = anyOrThrow[Seq[ScalaTestClassesItem]](items).flatten
val result = ScalaTestClassesResult(successfulItems.toVector, None) val result = ScalaTestClassesResult(
items = successfulItems.toVector,
originId = None: Option[String]
)
s.respondEvent(result) s.respondEvent(result)
} }
}) })
@ -753,13 +756,14 @@ object BuildServerProtocol {
ScopeFilter ScopeFilter
) => Def.Initialize[Task[T]] ) => Def.Initialize[Task[T]]
): Def.Initialize[InputTask[T]] = ): Def.Initialize[InputTask[T]] =
Def.inputTaskDyn { Def
val s = state.value .input((s: State) => targetIdentifierParser)
val targets = spaceDelimited().parsed.map(uri => BuildTargetIdentifier(URI.create(uri))) .flatMapTask { targets =>
val workspace: BspFullWorkspace = bspFullWorkspace.value.filter(targets) val s = state.value
val filter = ScopeFilter.in(workspace.scopes.values.toList) val workspace: BspFullWorkspace = bspFullWorkspace.value.filter(targets)
taskImpl(s, targets, workspace, filter) val filter = ScopeFilter.in(workspace.scopes.values.toList)
} taskImpl(s, targets, workspace, filter)
}
private def jvmEnvironmentItem(): Initialize[Task[JvmEnvironmentItem]] = Def.task { private def jvmEnvironmentItem(): Initialize[Task[JvmEnvironmentItem]] = Def.task {
val target = Keys.bspTargetIdentifier.value val target = Keys.bspTargetIdentifier.value
@ -1009,13 +1013,12 @@ object BuildServerProtocol {
val grouped = TestFramework.testMap(frameworks, definitions) val grouped = TestFramework.testMap(frameworks, definitions)
grouped.map { grouped.map { case (framework, definitions) =>
case (framework, definitions) => ScalaTestClassesItem(
ScalaTestClassesItem( bspTargetIdentifier.value,
bspTargetIdentifier.value, definitions.map(_.name).toVector,
definitions.map(_.name).toVector, framework.name()
framework.name() )
)
}.toSeq }.toSeq
} }
} }

View File

@ -5,7 +5,7 @@
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY
package sbt.internal.bsp.codec package sbt.internal.bsp.codec
import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError } import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError }
trait JvmRunEnvironmentResultFormats { self: sbt.internal.bsp.codec.JvmEnvironmentItemFormats with sjsonnew.BasicJsonProtocol => trait JvmRunEnvironmentResultFormats { self: sbt.internal.bsp.codec.JvmEnvironmentItemFormats with sbt.internal.bsp.codec.BuildTargetIdentifierFormats with sjsonnew.BasicJsonProtocol =>
implicit lazy val JvmRunEnvironmentResultFormat: JsonFormat[sbt.internal.bsp.JvmRunEnvironmentResult] = new JsonFormat[sbt.internal.bsp.JvmRunEnvironmentResult] { implicit lazy val JvmRunEnvironmentResultFormat: JsonFormat[sbt.internal.bsp.JvmRunEnvironmentResult] = new JsonFormat[sbt.internal.bsp.JvmRunEnvironmentResult] {
override def read[J](__jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.internal.bsp.JvmRunEnvironmentResult = { override def read[J](__jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.internal.bsp.JvmRunEnvironmentResult = {
__jsOpt match { __jsOpt match {

View File

@ -5,7 +5,7 @@
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY
package sbt.internal.bsp.codec package sbt.internal.bsp.codec
import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError } import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError }
trait JvmTestEnvironmentResultFormats { self: sbt.internal.bsp.codec.JvmEnvironmentItemFormats with sjsonnew.BasicJsonProtocol => trait JvmTestEnvironmentResultFormats { self: sbt.internal.bsp.codec.JvmEnvironmentItemFormats with sbt.internal.bsp.codec.BuildTargetIdentifierFormats with sjsonnew.BasicJsonProtocol =>
implicit lazy val JvmTestEnvironmentResultFormat: JsonFormat[sbt.internal.bsp.JvmTestEnvironmentResult] = new JsonFormat[sbt.internal.bsp.JvmTestEnvironmentResult] { implicit lazy val JvmTestEnvironmentResultFormat: JsonFormat[sbt.internal.bsp.JvmTestEnvironmentResult] = new JsonFormat[sbt.internal.bsp.JvmTestEnvironmentResult] {
override def read[J](__jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.internal.bsp.JvmTestEnvironmentResult = { override def read[J](__jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.internal.bsp.JvmTestEnvironmentResult = {
__jsOpt match { __jsOpt match {

View File

@ -5,7 +5,7 @@
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY
package sbt.internal.bsp.codec package sbt.internal.bsp.codec
import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError } import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError }
trait OutputPathsItemFormats { self: sbt.internal.bsp.codec.BuildTargetIdentifierFormats with sbt.internal.bsp.codec.OutputPathItemFormats with sjsonnew.BasicJsonProtocol => trait OutputPathsItemFormats { self: sbt.internal.bsp.codec.BuildTargetIdentifierFormats with sjsonnew.BasicJsonProtocol with sbt.internal.bsp.codec.OutputPathItemFormats =>
implicit lazy val OutputPathsItemFormat: JsonFormat[sbt.internal.bsp.OutputPathsItem] = new JsonFormat[sbt.internal.bsp.OutputPathsItem] { implicit lazy val OutputPathsItemFormat: JsonFormat[sbt.internal.bsp.OutputPathsItem] = new JsonFormat[sbt.internal.bsp.OutputPathsItem] {
override def read[J](__jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.internal.bsp.OutputPathsItem = { override def read[J](__jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.internal.bsp.OutputPathsItem = {
__jsOpt match { __jsOpt match {

View File

@ -5,7 +5,7 @@
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY
package sbt.internal.bsp.codec package sbt.internal.bsp.codec
import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError } import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError }
trait OutputPathsResultFormats { self: sbt.internal.bsp.codec.OutputPathsItemFormats with sjsonnew.BasicJsonProtocol => trait OutputPathsResultFormats { self: sbt.internal.bsp.codec.OutputPathsItemFormats with sbt.internal.bsp.codec.BuildTargetIdentifierFormats with sjsonnew.BasicJsonProtocol with sbt.internal.bsp.codec.OutputPathItemFormats =>
implicit lazy val OutputPathsResultFormat: JsonFormat[sbt.internal.bsp.OutputPathsResult] = new JsonFormat[sbt.internal.bsp.OutputPathsResult] { implicit lazy val OutputPathsResultFormat: JsonFormat[sbt.internal.bsp.OutputPathsResult] = new JsonFormat[sbt.internal.bsp.OutputPathsResult] {
override def read[J](__jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.internal.bsp.OutputPathsResult = { override def read[J](__jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.internal.bsp.OutputPathsResult = {
__jsOpt match { __jsOpt match {

View File

@ -9,7 +9,7 @@ package sbt.internal.bsp
object OutputPathItemKind { object OutputPathItemKind {
/** The output path item references a normal file. */ /** The output path item references a normal file. */
val File: Int = 1 val File: Int = 1
/** The output path item references a directory. */ /** The output path item references a directory. */

View File

@ -297,7 +297,10 @@ trait Import {
type IvyScala = sbt.librarymanagement.ScalaModuleInfo type IvyScala = sbt.librarymanagement.ScalaModuleInfo
val JCenterRepository = sbt.librarymanagement.Resolver.JCenterRepository val JCenterRepository = sbt.librarymanagement.Resolver.JCenterRepository
val JavaNet2Repository = sbt.librarymanagement.Resolver.JavaNet2Repository val JavaNet2Repository = sbt.librarymanagement.Resolver.JavaNet2Repository
val License = sbt.librarymanagement.License
// todo: fix
// val License = sbt.librarymanagement.License
type LogicalClock = sbt.librarymanagement.LogicalClock type LogicalClock = sbt.librarymanagement.LogicalClock
val LogicalClock = sbt.librarymanagement.LogicalClock val LogicalClock = sbt.librarymanagement.LogicalClock
type MakePomConfiguration = sbt.librarymanagement.MakePomConfiguration type MakePomConfiguration = sbt.librarymanagement.MakePomConfiguration