mirror of https://github.com/sbt/sbt.git
Support cross-build for external project ref
This commit is contained in:
parent
397c7a634a
commit
c5fd4f2e6d
|
|
@ -118,12 +118,11 @@ object Cross {
|
|||
)(command: String): (Seq[ProjectRef], String) = {
|
||||
import extracted._
|
||||
import DefaultParsers._
|
||||
val parser = (OpOrID <~ charClass(_ == '/', "/")) ~ any.* map {
|
||||
case seg1 ~ cmd => (seg1, cmd.mkString)
|
||||
}
|
||||
val parser = ((('{' ~> URIClass <~ '}').? ~ OpOrID <~ '/') ~ any.*.string)
|
||||
.map { case uri ~ seg1 ~ cmd => (uri, seg1, cmd) }
|
||||
Parser.parse(command, parser) match {
|
||||
case Right((seg1, cmd)) =>
|
||||
structure.allProjectRefs.find(_.project == seg1) match {
|
||||
case Right((uri, seg1, cmd)) =>
|
||||
structure.allProjectRefs.find(p => uri.contains(p.build.toString) && seg1 == p.project) match {
|
||||
case Some(proj) => (Seq(proj), cmd)
|
||||
case _ => (resolveAggregates(extracted), command)
|
||||
}
|
||||
|
|
@ -187,9 +186,10 @@ object Cross {
|
|||
keys.toSeq.flatMap { k =>
|
||||
project(k).withFilter(projects.contains).flatMap { p =>
|
||||
if (p == extracted.currentRef || !projects.contains(extracted.currentRef)) {
|
||||
val parts = project(k).map(_.project) ++ k.scope.config.toOption.map {
|
||||
case ConfigKey(n) => n.head.toUpper + n.tail
|
||||
} ++ k.scope.task.toOption.map(_.label) ++ Some(k.key.label)
|
||||
val parts = project(k).map(p => s"{${p.build}}${p.project}") ++
|
||||
k.scope.config.toOption.map(c => c.name.capitalize) ++
|
||||
k.scope.task.toOption.map(_.label) ++
|
||||
Some(k.key.label)
|
||||
Some(v -> parts.mkString("", "/", fullArgs))
|
||||
} else None
|
||||
}
|
||||
|
|
@ -257,7 +257,7 @@ object Cross {
|
|||
val (aggs, aggCommand) = parseSlashCommand(Project.extract(state))(rawCmd)
|
||||
aggs
|
||||
.intersect(affectedRefs)
|
||||
.map({ case ProjectRef(_, proj) => s"$proj/$aggCommand" })
|
||||
.map(p => s"{${p.build}}${p.project}/$aggCommand")
|
||||
.mkString("all ", " ", "")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ ThisBuild / crossScalaVersions := Seq(scala212, scala213)
|
|||
ThisBuild / scalaVersion := scala212
|
||||
|
||||
lazy val rootProj = (project in file("."))
|
||||
.aggregate(libProj, fooPlugin)
|
||||
.aggregate(libProj, fooPlugin, externalProj)
|
||||
.settings(
|
||||
crossScalaVersions := Nil,
|
||||
addCommandAlias("build", "compile")
|
||||
|
|
@ -27,3 +27,5 @@ lazy val extrasProj = (project in file("extras"))
|
|||
.settings(
|
||||
name := "foo-extras",
|
||||
)
|
||||
|
||||
lazy val externalProj = ProjectRef(file("ref"), "external")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
lazy val external = (project in file("."))
|
||||
.settings(
|
||||
scalaVersion := "2.12.18"
|
||||
)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package ref.sbt
|
||||
|
||||
object Ref {
|
||||
|
||||
}
|
||||
|
|
@ -18,6 +18,8 @@ $ exists lib/target/scala-2.12
|
|||
-$ exists lib/target/scala-2.13
|
||||
$ exists sbt-foo/target/scala-2.12
|
||||
-$ exists sbt-foo/target/scala-2.13
|
||||
$ exists ref/target/scala-2.12
|
||||
-$ exists ref/target/scala-2.13
|
||||
|
||||
# Test legacy cross build with command support
|
||||
# > clean
|
||||
|
|
@ -39,8 +41,11 @@ $ exists extras/target/scala-2.12
|
|||
> ++ 2.13.12 -v compile
|
||||
$ exists lib/target/scala-2.13
|
||||
-$ exists lib/target/scala-2.12
|
||||
# -$ exists sbt-foo/target/scala-2.12
|
||||
# sbt-foo and ref do not cross-build 2.13
|
||||
-$ exists sbt-foo/target/scala-2.12
|
||||
-$ exists sbt-foo/target/scala-2.13
|
||||
-$ exists ref/target/scala-2.12
|
||||
-$ exists ref/target/scala-2.13
|
||||
|
||||
# test wildcard switching (2.12)
|
||||
> clean
|
||||
|
|
@ -49,14 +54,19 @@ $ exists lib/target/scala-2.12
|
|||
-$ exists lib/target/scala-2.13
|
||||
$ exists sbt-foo/target/scala-2.12
|
||||
-$ exists sbt-foo/target/scala-2.13
|
||||
$ exists ref/target/scala-2.12
|
||||
-$ exists ref/target/scala-2.13
|
||||
|
||||
# test wildcard switching (2.13)
|
||||
> clean
|
||||
> ++ 2.13.x -v compile
|
||||
$ exists lib/target/scala-2.13
|
||||
-$ exists lib/target/scala-2.12
|
||||
# -$ exists sbt-foo/target/scala-2.12
|
||||
# sbt-foo and ref do not cross-build 2.13
|
||||
-$ exists sbt-foo/target/scala-2.12
|
||||
-$ exists sbt-foo/target/scala-2.13
|
||||
-$ exists ref/target/scala-2.12
|
||||
-$ exists ref/target/scala-2.13
|
||||
|
||||
# test wildcard switching (no matches)
|
||||
-> ++ 3.*
|
||||
|
|
|
|||
Loading…
Reference in New Issue