mirror of https://github.com/sbt/sbt.git
Merge pull request #7694 from eed3si9n/wip/cross-building
[2.x] feat: plugin cross building as Scala cross building
This commit is contained in:
commit
5ffd2f20c3
|
|
@ -332,9 +332,6 @@ object Defaults extends BuildCommon {
|
|||
envVars :== Map.empty,
|
||||
sbtVersion := appConfiguration.value.provider.id.version,
|
||||
sbtBinaryVersion := binarySbtVersion(sbtVersion.value),
|
||||
// `pluginCrossBuild` scoping is based on sbt-cross-building plugin.
|
||||
// The idea here is to be able to define a `sbtVersion in pluginCrossBuild`, which
|
||||
// directs the dependencies of the plugin to build to the specified sbt plugin version.
|
||||
pluginCrossBuild / sbtVersion := sbtVersion.value,
|
||||
onLoad := idFun[State],
|
||||
onUnload := idFun[State],
|
||||
|
|
@ -3105,7 +3102,7 @@ object Classpaths {
|
|||
Defaults.globalDefaults(
|
||||
Seq(
|
||||
publishMavenStyle :== true,
|
||||
sbtPluginPublishLegacyMavenStyle :== true,
|
||||
sbtPluginPublishLegacyMavenStyle :== false,
|
||||
publishArtifact :== true,
|
||||
(Test / publishArtifact) :== false
|
||||
)
|
||||
|
|
|
|||
|
|
@ -10,12 +10,19 @@ package sbt
|
|||
package plugins
|
||||
|
||||
import sbt.Def.Setting
|
||||
import sbt.Keys._
|
||||
import sbt.Keys.*
|
||||
import sbt.SlashSyntax0.*
|
||||
|
||||
object SbtPlugin extends AutoPlugin {
|
||||
object SbtPlugin extends AutoPlugin:
|
||||
override def requires = ScriptedPlugin
|
||||
|
||||
override lazy val projectSettings: Seq[Setting[_]] = Seq(
|
||||
sbtPlugin := true
|
||||
sbtPlugin := true,
|
||||
pluginCrossBuild / sbtVersion := {
|
||||
scalaBinaryVersion.value match
|
||||
case "3" => sbtVersion.value
|
||||
case "2.12" => "1.5.8"
|
||||
case "2.10" => "0.13.18"
|
||||
},
|
||||
)
|
||||
}
|
||||
end SbtPlugin
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
val scala3 = "3.3.3"
|
||||
val scala212 = "2.12.19"
|
||||
|
||||
organization := "com.example"
|
||||
version := "0.1.0-SNAPSHOT"
|
||||
|
||||
lazy val checkSbt2Plugin = taskKey[Unit]("")
|
||||
|
||||
lazy val plugin = (projectMatrix in file("plugin"))
|
||||
.enablePlugins(SbtPlugin)
|
||||
.settings(
|
||||
organization := "com.example",
|
||||
name := "sbt-example",
|
||||
// TODO: Once 2.0 is released we can move this check to the `test` file
|
||||
checkSbt2Plugin := {
|
||||
val repo = (ThisBuild / baseDirectory).value / "repo"
|
||||
val sbtV = sbtBinaryVersion.value
|
||||
val expected = (repo / "com" / "example" /
|
||||
s"sbt-example_sbt${sbtV}_3" /
|
||||
"0.1.0-SNAPSHOT" /
|
||||
s"sbt-example_sbt${sbtV}_3-0.1.0-SNAPSHOT.pom")
|
||||
assert(expected.exists, s"$expected did not exist")
|
||||
},
|
||||
)
|
||||
.jvmPlatform(scalaVersions = Seq(scala3, scala212))
|
||||
|
||||
publishMavenStyle := true
|
||||
publishTo := Some(Resolver.file("test-publish", (ThisBuild / baseDirectory).value / "repo/"))
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
> compile
|
||||
|
||||
> publish
|
||||
|
||||
$ exists repo/com/example/sbt-example_2.12_1.0/0.1.0-SNAPSHOT/sbt-example_2.12_1.0-0.1.0-SNAPSHOT.pom
|
||||
$ absent repo/com/example/sbt-example_2.12_1.0/0.1.0-SNAPSHOT/sbt-example-0.1.0-SNAPSHOT.pom
|
||||
|
||||
> checkSbt2Plugin
|
||||
Loading…
Reference in New Issue