forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
community build: add automatic dependency override handling
Introduce a new sbt plugin: `sbt-community-build`, which tracks the modules published during a community build run, and injects dependency overrides to force version alignment.
- Loading branch information
Showing
26 changed files
with
494 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
sbt-community-build/sbt-test/sbt-community-build/inter-project-transitive-dep/build.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
ThisBuild / scalaVersion := sys.props("plugin.scalaVersion") | ||
ThisBuild / organization := "org.example" | ||
|
||
lazy val a = project | ||
.settings( | ||
name := "a", | ||
version := "0.4.1-SNAPSHOT", | ||
libraryDependencies := Seq(), // don't depend on scala-library | ||
) | ||
|
||
lazy val b = project | ||
.settings(onlyThisTestResolverSettings) | ||
.settings( | ||
name := "b", | ||
libraryDependencies := Seq(organization.value %% "a" % "0.4.0-SNAPSHOT"), | ||
) | ||
|
||
lazy val c = project | ||
.settings(onlyThisTestResolverSettings) | ||
.settings( | ||
name := "c", | ||
libraryDependencies := Seq(), // don't depend on scala-library | ||
).dependsOn(b) |
33 changes: 33 additions & 0 deletions
33
...ld/sbt-test/sbt-community-build/inter-project-transitive-dep/project/ThisTestPlugin.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import sbt._ | ||
import Keys._ | ||
|
||
object ThisTestPlugin extends AutoPlugin { | ||
override def requires = plugins.IvyPlugin | ||
override def trigger = allRequirements | ||
|
||
val thisTestIvyHome = settingKey[File]("Ivy home directory for artifacts published by this test") | ||
val thisTestResolver = settingKey[Resolver]("Resolver for artifacts published by this test") | ||
val deleteDepsFile = taskKey[Unit]("Deletes the dotty-community-build-deps dependency tracking file") | ||
|
||
override val projectSettings = Seq( | ||
publishLocalConfiguration := publishLocalConfiguration.value.withResolverName("this-test") | ||
) | ||
|
||
override val buildSettings = defaultThisTestSettings ++ Seq( | ||
resolvers += thisTestResolver.value | ||
) | ||
|
||
def defaultThisTestSettings: Seq[Setting[_]] = { | ||
Seq( | ||
thisTestIvyHome := (LocalRootProject / target).value / "ivy-cache", | ||
thisTestResolver := Resolver.file("this-test", thisTestIvyHome.value / "local")(Resolver.ivyStylePatterns), | ||
deleteDepsFile := IO.delete(file(sys.props("dotty.communitybuild.dir")) / "dotty-community-build-deps"), | ||
) | ||
} | ||
|
||
object autoImport { | ||
def onlyThisTestResolverSettings: Seq[Setting[_]] = Seq( | ||
externalResolvers := thisTestResolver.value :: Nil | ||
) | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
...unity-build/sbt-test/sbt-community-build/inter-project-transitive-dep/project/plugins.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
addSbtPlugin("ch.epfl.lamp" % "sbt-community-build" % sys.props("plugin.version")) | ||
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % sys.props("plugin.sbtDottyVersion")) |
10 changes: 10 additions & 0 deletions
10
sbt-community-build/sbt-test/sbt-community-build/inter-project-transitive-dep/test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
> deleteDepsFile | ||
> reload | ||
|
||
> a/publishLocal | ||
|
||
-> c/update | ||
|
||
> reload | ||
|
||
> c/update |
26 changes: 26 additions & 0 deletions
26
sbt-community-build/sbt-test/sbt-community-build/multiple-deps/build.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
ThisBuild / scalaVersion := sys.props("plugin.scalaVersion") | ||
ThisBuild / organization := "org.example" | ||
|
||
lazy val a = project | ||
.settings( | ||
name := "a", | ||
version := "0.2.1-SNAPSHOT", | ||
libraryDependencies := Seq(), // don't depend on scala-library | ||
) | ||
|
||
lazy val b = project | ||
.settings( | ||
name := "b", | ||
version := "1.2.1-SNAPSHOT", | ||
libraryDependencies := Seq(), // don't depend on scala-library | ||
) | ||
|
||
lazy val c = project | ||
.settings(onlyThisTestResolverSettings) | ||
.settings( | ||
name := "c", | ||
libraryDependencies := Seq( | ||
organization.value %% "a" % "0.2.0-SNAPSHOT", | ||
organization.value %% "b" % "1.2.0-SNAPSHOT", | ||
), | ||
) |
33 changes: 33 additions & 0 deletions
33
sbt-community-build/sbt-test/sbt-community-build/multiple-deps/project/ThisTestPlugin.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import sbt._ | ||
import Keys._ | ||
|
||
object ThisTestPlugin extends AutoPlugin { | ||
override def requires = plugins.IvyPlugin | ||
override def trigger = allRequirements | ||
|
||
val thisTestIvyHome = settingKey[File]("Ivy home directory for artifacts published by this test") | ||
val thisTestResolver = settingKey[Resolver]("Resolver for artifacts published by this test") | ||
val deleteDepsFile = taskKey[Unit]("Deletes the dotty-community-build-deps dependency tracking file") | ||
|
||
override val projectSettings = Seq( | ||
publishLocalConfiguration := publishLocalConfiguration.value.withResolverName("this-test") | ||
) | ||
|
||
override val buildSettings = defaultThisTestSettings ++ Seq( | ||
resolvers += thisTestResolver.value | ||
) | ||
|
||
def defaultThisTestSettings: Seq[Setting[_]] = { | ||
Seq( | ||
thisTestIvyHome := (LocalRootProject / target).value / "ivy-cache", | ||
thisTestResolver := Resolver.file("this-test", thisTestIvyHome.value / "local")(Resolver.ivyStylePatterns), | ||
deleteDepsFile := IO.delete(file(sys.props("dotty.communitybuild.dir")) / "dotty-community-build-deps"), | ||
) | ||
} | ||
|
||
object autoImport { | ||
def onlyThisTestResolverSettings: Seq[Setting[_]] = Seq( | ||
externalResolvers := thisTestResolver.value :: Nil | ||
) | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
sbt-community-build/sbt-test/sbt-community-build/multiple-deps/project/plugins.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
addSbtPlugin("ch.epfl.lamp" % "sbt-community-build" % sys.props("plugin.version")) | ||
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % sys.props("plugin.sbtDottyVersion")) |
11 changes: 11 additions & 0 deletions
11
sbt-community-build/sbt-test/sbt-community-build/multiple-deps/test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
> deleteDepsFile | ||
> reload | ||
|
||
> a/publishLocal | ||
> b/publishLocal | ||
|
||
-> c/update | ||
|
||
> reload | ||
|
||
> c/update |
Oops, something went wrong.