Mark dependency management tests pending

This commit is contained in:
Eugene Yokota 2022-12-09 16:52:59 -05:00
parent 5bbb671341
commit eb7a51c629
30 changed files with 89 additions and 84 deletions

View File

@ -1,4 +1,5 @@
import sbt.nio.file.Glob
ThisBuild / scalaVersion := "2.12.17"
Compile / cleanKeepGlobs +=
Glob((Compile / compile / classDirectory).value, "X.class")

View File

@ -17,7 +17,7 @@ $ touch succeed
-> h fail
$ absent h
> set traceLevel in ThisBuild := 100
> set logLevel in ThisBuild := Level.Debug
> set ThisBuild / traceLevel := 100
> set ThisBuild / logLevel := Level.Debug
> h succeed
$ exists h

View File

@ -11,7 +11,7 @@ ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / organization := "com.example"
ThisBuild / organizationName := "example"
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
ThisBuild / licenses := List(License.Apache2)
// ThisBuild / licenses := List(License.Apache2)
lazy val Dev = config("dev").extend(Compile)
.describedAs("Dependencies required for development environments")
@ -24,11 +24,11 @@ lazy val root = (project in file("."))
scalaCompilerBridgeResolvers += userLocalFileResolver(appConfiguration.value),
resolvers += baseDirectory { base => "Test Repo" at (base / "test-repo").toURI.toString }.value,
moduleName := artifactID,
projectID := (if (baseDirectory.value / "retrieve" exists) retrieveID else publishedID),
artifact in (Compile, packageBin) := mainArtifact,
libraryDependencies ++= (if (baseDirectory.value / "retrieve" exists) publishedID :: Nil else Nil),
projectID := (if (baseDirectory.value / "retrieve").exists then retrieveID else publishedID),
Compile / packageBin / artifact := mainArtifact,
libraryDependencies ++= (if (baseDirectory.value / "retrieve").exists then publishedID :: Nil else Nil),
// needed to add a jar with a different type to the managed classpath
unmanagedClasspath in Compile ++= scalaInstance.value.libraryJars.toSeq,
Compile / unmanagedClasspath ++= scalaInstance.value.libraryJars.toSeq,
classpathTypes := Set(tpe),
// custom configuration artifacts
@ -63,13 +63,14 @@ def publishedID = org % artifactID % vers artifacts(mainArtifact)
def retrieveID = org % "test-retrieve" % "2.0"
// check that the test class is on the compile classpath, either because it was compiled or because it was properly retrieved
def checkTask(classpath: TaskKey[Classpath]) = Def.task {
val deps = libraryDependencies.value
val cp = (classpath in Compile).value.files
val loader = ClasspathUtilities.toLoader(cp, scalaInstance.value.loader)
try { Class.forName("test.Test", false, loader); () }
catch { case _: ClassNotFoundException | _: NoClassDefFoundError => sys.error(s"Dependency not retrieved properly: $deps, $cp") }
}
def checkTask(classpath: TaskKey[Classpath]) =
Def.task {
val deps = libraryDependencies.value
val cp = (Compile / classpath).value.files
val loader = ClasspathUtilities.toLoader(cp, scalaInstance.value.loader)
try { Class.forName("test.Test", false, loader); () }
catch { case _: ClassNotFoundException | _: NoClassDefFoundError => sys.error(s"Dependency not retrieved properly: $deps, $cp") }
}
// use the user local resolver to fetch the SNAPSHOT version of the compiler-bridge
def userLocalFileResolver(appConfig: AppConfiguration): Resolver = {

View File

@ -1,11 +1,11 @@
scalaVersion := "2.12.16"
autoScalaLibrary := false
libraryDependencies += "com.chuusai" % "shapeless_2.12" % "2.3.2"
val checkScalaLibrary = TaskKey[Unit]("checkScalaLibrary")
checkScalaLibrary := {
val scalaLibsJars = managedClasspath
.in(Compile)
val scalaLibsJars = (Compile / managedClasspath)
.value
.map(_.data.getName)
.filter(_.startsWith("scala-library"))

View File

@ -7,15 +7,16 @@ ThisBuild / useCoursier := false
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value, Some((baseDirectory in ThisBuild).value / "ivy" / "cache"))
ivyPaths := IvyPaths(baseDirectory.value, Some((ThisBuild / baseDirectory).value / "ivy" / "cache"))
val b = project
.settings(
localCache,
libraryDependencies += "org.example" %% "artifacta" % "1.0.0-SNAPSHOT" withSources() classifier("tests"),
libraryDependencies += ("org.example" %% "artifacta" % "1.0.0-SNAPSHOT")
.withSources().classifier("tests"),
scalaCompilerBridgeResolvers += userLocalFileResolver(appConfiguration.value),
externalResolvers := Vector(
MavenCache("demo", ((baseDirectory in ThisBuild).value / "demo-repo")),
MavenCache("demo", ((ThisBuild / baseDirectory).value / "demo-repo")),
DefaultMavenRepository
)
)
@ -26,8 +27,8 @@ val a = project
organization := "org.example",
name := "artifacta",
version := "1.0.0-SNAPSHOT",
publishArtifact in (Test,packageBin) := true,
publishTo := Some(MavenCache("demo", ((baseDirectory in ThisBuild).value / "demo-repo")))
Test / packageBin / publishArtifact := true,
publishTo := Some(MavenCache("demo", ((ThisBuild / baseDirectory).value / "demo-repo")))
)
// use the user local resolver to fetch the SNAPSHOT version of the compiler-bridge

View File

@ -1,23 +1,24 @@
ThisBuild / organization := "org.example"
ThisBuild / version := "2.0-SNAPSHOT"
lazy val root = (project in file(".")).
aggregate(a,b).
settings(
name := "use",
version := "1.0",
organization in ThisBuild := "org.example",
version in ThisBuild := "2.0-SNAPSHOT",
libraryDependencies += "org.example" % "b" % "2.0-SNAPSHOT",
ivyPaths := (ivyPaths in ThisBuild).value
ivyPaths := (ThisBuild / ivyPaths).value,
)
lazy val a = project.
dependsOn(b).
settings(
name := "a",
ivyPaths := (ivyPaths in ThisBuild).value
ivyPaths := (ThisBuild / ivyPaths).value,
)
lazy val b = project.
settings(
name := "b",
ivyPaths := (ivyPaths in ThisBuild).value
ivyPaths := (ThisBuild / ivyPaths).value,
)

View File

@ -1,20 +1,21 @@
ThisBuild / organization := "org.example"
ThisBuild / version := "2.0-SNAPSHOT"
lazy val root = (project in file(".")).
aggregate(a,b).
settings(
organization in ThisBuild := "org.example",
version in ThisBuild := "2.0-SNAPSHOT",
ivyPaths := (ivyPaths in ThisBuild).value
ivyPaths := (ThisBuild / ivyPaths).value,
)
lazy val a = project.
dependsOn(b).
settings(
name := "a",
ivyPaths := (ivyPaths in ThisBuild).value
ivyPaths := (ThisBuild / ivyPaths).value,
)
lazy val b = project.
settings(
name := "b",
ivyPaths := (ivyPaths in ThisBuild).value
ivyPaths := (ThisBuild / ivyPaths).value,
)

View File

@ -4,5 +4,5 @@ lazy val root = (project in file(".")).
organization := "org.example",
version := "1.0",
libraryDependencies += "org.example" % "b" % "2.0-SNAPSHOT",
ivyPaths := (ivyPaths in ThisBuild).value
ivyPaths := (ThisBuild / ivyPaths).value,
)

View File

@ -23,8 +23,8 @@ lazy val root = (project in file("."))
licenses := Seq("Apache 2" -> new URL("http://www.apache.org/licenses/LICENSE-2.0.txt")),
)),
ivyPaths := IvyPaths(
(baseDirectory in ThisBuild).value,
Some((baseDirectory in LocalRootProject).value / "ivy-cache")
(ThisBuild / baseDirectory).value,
Some((LocalRootProject / baseDirectory).value / "ivy-cache")
),
libraryDependencies += "com.github.nscala-time" %% "nscala-time" % "1.0.0",

View File

@ -7,10 +7,12 @@ val luceneVersion = "4.0.0"
val akkaVersion = "2.3.1"
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
ThisBuild / organization := "org.example"
ThisBuild / version := "1.0-SNAPSHOT"
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths( (baseDirectory in ThisBuild).value, Some((target in LocalRootProject).value / "ivy-cache")),
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
scalaVersion := "2.10.4",
fullResolvers := fullResolvers.value.filterNot(_.name == "inter-project"),
updateOptions := updateOptions.value.withCachedResolution(true)
@ -48,10 +50,8 @@ lazy val c = project.
lazy val root = (project in file(".")).
settings(commonSettings: _*).
settings(
organization in ThisBuild := "org.example",
version in ThisBuild := "1.0-SNAPSHOT",
check := {
val acp = (externalDependencyClasspath in Compile in a).value.map {_.data.getName}.sorted
val acp = (a / Compile / externalDependencyClasspath).value.map {_.data.getName}.sorted
if (!(acp contains "netty-3.2.0.Final.jar")) {
sys.error("netty-3.2.0.Final not found when it should be included: " + acp.toString)
}

View File

@ -10,7 +10,7 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths( (baseDirectory in ThisBuild).value, Some((target in LocalRootProject).value / "ivy-cache")),
ivyPaths := IvyPaths( (ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
scalaVersion := "2.10.4",
fullResolvers := fullResolvers.value.filterNot(_.name == "inter-project")
)

View File

@ -6,7 +6,7 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths( (baseDirectory in ThisBuild).value, Some((baseDirectory in LocalRootProject).value / "ivy-cache")),
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
dependencyCacheDirectory := (baseDirectory in LocalRootProject).value / "dependency",
scalaVersion := "2.10.4",
resolvers += Resolver.sonatypeRepo("snapshots")
@ -67,16 +67,16 @@ lazy val root = (project in file(".")).
organization in ThisBuild := "org.example",
version in ThisBuild := "1.0",
check := {
val acp = (externalDependencyClasspath in Compile in a).value.map {_.data.getName}.sorted
val bcp = (externalDependencyClasspath in Compile in b).value.map {_.data.getName}.sorted
val ccp = (externalDependencyClasspath in Compile in c).value.map {_.data.getName}.sorted filterNot { _ == "demo_2.10.jar"}
val acp = (a / Compile / externalDependencyClasspath).value.map {_.data.getName}.sorted
val bcp = (b / Compile / externalDependencyClasspath).value.map {_.data.getName}.sorted
val ccp = (c / Compile / externalDependencyClasspath).value.map {_.data.getName}.sorted filterNot { _ == "demo_2.10.jar"}
if (!(acp contains "commons-io-1.4-sources.jar")) {
sys.error("commons-io-1.4-sources not found when it should be included: " + acp.toString)
}
// if (!(acp contains "commons-io-1.4.jar")) {
// sys.error("commons-io-1.4 not found when it should be included: " + acp.toString)
// }
// stock Ivy implementation doesn't contain regular (non-source) jar, which probably is a bug
val acpWithoutSource = acp filterNot { _ == "commons-io-1.4.jar"}
val bcpWithoutSource = bcp filterNot { _ == "commons-io-1.4.jar"}
@ -86,10 +86,10 @@ lazy val root = (project in file(".")).
"\n - a (cached) " + acpWithoutSource.toString +
"\n - b (plain) " + bcpWithoutSource.toString +
"\n - c (inter-project) " + ccpWithoutSource.toString)
val atestcp = (externalDependencyClasspath in Test in a).value.map {_.data.getName}.sorted filterNot { _ == "commons-io-1.4.jar"}
val btestcp = (externalDependencyClasspath in Test in b).value.map {_.data.getName}.sorted filterNot { _ == "commons-io-1.4.jar"}
val ctestcp = (externalDependencyClasspath in Test in c).value.map {_.data.getName}.sorted filterNot { _ == "demo_2.10.jar"} filterNot { _ == "commons-io-1.4.jar"}
val atestcp = (a / Test / externalDependencyClasspath).value.map {_.data.getName}.sorted filterNot { _ == "commons-io-1.4.jar"}
val btestcp = (b / Test / externalDependencyClasspath).value.map {_.data.getName}.sorted filterNot { _ == "commons-io-1.4.jar"}
val ctestcp = (c / Test / externalDependencyClasspath).value.map {_.data.getName}.sorted filterNot { _ == "demo_2.10.jar"} filterNot { _ == "commons-io-1.4.jar"}
if (ctestcp contains "junit-4.13.1.jar") {
sys.error("junit found when it should be excluded: " + ctestcp.toString)
}

View File

@ -5,7 +5,7 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
def commonSettings: Vector[Def.Setting[_]] =
Vector(
organization := "com.example",
ivyPaths := IvyPaths( (baseDirectory in ThisBuild).value, Some((baseDirectory in LocalRootProject).value / "ivy-cache")),
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
dependencyCacheDirectory := (baseDirectory in LocalRootProject).value / "dependency",
scalaCompilerBridgeResolvers += userLocalFileResolver(appConfiguration.value),
resolvers += Resolver.file("buggy", (baseDirectory in LocalRootProject).value / "repo")(

View File

@ -11,7 +11,7 @@ inThisBuild(Seq(
))
def commonSettings: Seq[Def.Setting[_]] = Seq(
ivyPaths := IvyPaths((baseDirectory in ThisBuild).value, Some((baseDirectory in LocalRootProject).value / "ivy-cache")),
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
dependencyCacheDirectory := (baseDirectory in LocalRootProject).value / "dependency",
fullResolvers := fullResolvers.value.filterNot(_.name == "inter-project")
)

View File

@ -6,8 +6,8 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths( (baseDirectory in ThisBuild).value, Some((baseDirectory in LocalRootProject).value / "ivy-cache")),
dependencyCacheDirectory := (baseDirectory in LocalRootProject).value / "dependency",
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
dependencyCacheDirectory := (LocalRootProject / baseDirectory).value / "dependency",
scalaVersion := "2.10.4",
resolvers += Resolver.sonatypeRepo("snapshots")
)
@ -35,8 +35,8 @@ lazy val root = (project in file(".")).
version := "1.0",
updateOptions := updateOptions.value.withCachedResolution(true),
check := {
val acp = (externalDependencyClasspath in Compile in a).value.sortBy {_.data.getName}
val bcp = (externalDependencyClasspath in Compile in b).value.sortBy {_.data.getName}
val acp = (a / Compile / externalDependencyClasspath).value.sortBy {_.data.getName}
val bcp = (b / Compile / externalDependencyClasspath).value.sortBy {_.data.getName}
if (acp exists { _.data.getName contains "commons-io" }) {
sys.error("commons-io found when it should be excluded")
}

View File

@ -4,7 +4,7 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths( (baseDirectory in ThisBuild).value, Some((baseDirectory in LocalRootProject).value / "ivy-cache")),
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
dependencyCacheDirectory := (baseDirectory in LocalRootProject).value / "dependency",
scalaVersion := "2.10.4",
resolvers += Resolver.sonatypeRepo("snapshots")
@ -60,15 +60,15 @@ lazy val d = project.
lazy val root = (project in file(".")).
aggregate(a, b, c).
settings(
organization in ThisBuild := "org.example",
version in ThisBuild := "1.0",
ThisBuild / organization := "org.example",
ThisBuild / version := "1.0",
check := {
// sys.error(dependencyCacheDirectory.value.toString)
val acp = (externalDependencyClasspath in Compile in a).value.sortBy {_.data.getName}
val bcp = (externalDependencyClasspath in Compile in b).value.sortBy {_.data.getName}
val ccp = (externalDependencyClasspath in Compile in c).value.sortBy {_.data.getName}
val dcp = (externalDependencyClasspath in Compile in d).value.sortBy {_.data.getName}
val acp = (a / Compile / externalDependencyClasspath).value.sortBy {_.data.getName}
val bcp = (b / Compile / externalDependencyClasspath).value.sortBy {_.data.getName}
val ccp = (c / Compile / externalDependencyClasspath).value.sortBy {_.data.getName}
val dcp = (d / Compile / externalDependencyClasspath).value.sortBy {_.data.getName}
if (!(acp exists {_.data.getName contains "spring-core-3.2.2.RELEASE"})) {
sys.error("spring-core-3.2.2 is not found on a")
}

View File

@ -8,7 +8,7 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths( (baseDirectory in ThisBuild).value, Some((baseDirectory in LocalRootProject).value / "ivy-cache")),
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
dependencyCacheDirectory := (baseDirectory in LocalRootProject).value / "dependency",
resolvers += Resolver.sonatypeRepo("snapshots")
)
@ -36,10 +36,10 @@ lazy val root = (project in file(".")).
version := "1.0",
updateOptions := updateOptions.value.withCachedResolution(true),
check := {
val ur = (update in a).value
val acp = (externalDependencyClasspath in Compile in a).value.map {_.data.getName}
val atestcp0 = (fullClasspath in Test in a).value
val atestcp = (externalDependencyClasspath in Test in a).value.map {_.data.getName}
val ur = (a / update).value
val acp = (a / Compile / externalDependencyClasspath).value.map {_.data.getName}
val atestcp0 = (a / Test / fullClasspath).value
val atestcp = (a / Test / externalDependencyClasspath).value.map {_.data.getName}
// This is checking to make sure interproject dependency works
if (acp exists { _ contains "scalatest" }) {
sys.error("scalatest found when it should NOT be included: " + acp.toString)

View File

@ -1,10 +1,12 @@
lazy val check = taskKey[Unit]("Runs the check")
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
ThisBuild / organization := "org.example"
ThisBuild / version := "1.0"
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths( (baseDirectory in ThisBuild).value, Some((baseDirectory in LocalRootProject).value / "ivy-cache")),
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
dependencyCacheDirectory := (baseDirectory in LocalRootProject).value / "dependency",
libraryDependencies := Seq(
"net.databinder" %% "unfiltered-uploads" % "0.8.0",
@ -37,11 +39,9 @@ lazy val b = project.
lazy val root = (project in file(".")).
settings(
organization in ThisBuild := "org.example",
version in ThisBuild := "1.0",
check := {
val acp = (externalDependencyClasspath in Compile in a).value.sortBy {_.data.getName}
val bcp = (externalDependencyClasspath in Compile in b).value.sortBy {_.data.getName}
val acp = (a / Compile / externalDependencyClasspath).value.sortBy {_.data.getName}
val bcp = (b / Compile / externalDependencyClasspath).value.sortBy {_.data.getName}
if (acp == bcp) ()
else sys.error("Different classpaths are found:" +
"\n - a (overrides + cached) " + acp.toString +

View File

@ -4,10 +4,10 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths( (baseDirectory in ThisBuild).value, Some((target in LocalRootProject).value / "ivy-cache")),
scalaVersion in ThisBuild := "2.11.12",
organization in ThisBuild := "com.example",
version in ThisBuild := "0.1.0-SNAPSHOT",
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
ThisBuild / scalaVersion := "2.11.12",
ThisBuild / organization := "com.example",
ThisBuild / version := "0.1.0-SNAPSHOT",
autoScalaLibrary := false,
crossPaths := false
)

View File

@ -4,7 +4,7 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths( (baseDirectory in ThisBuild).value, Some((target in LocalRootProject).value / "ivy-cache")),
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
scalaVersion := "2.10.4",
fullResolvers := fullResolvers.value.filterNot(_.name == "inter-project")
)
@ -34,6 +34,6 @@ lazy val c = project.
lazy val root = (project in file(".")).
settings(commonSettings: _*).
settings(
organization in ThisBuild := "org.example",
version in ThisBuild := "1.0-SNAPSHOT"
ThisBuild / organization := "org.example",
ThisBuild / version := "1.0-SNAPSHOT",
)

View File

@ -1,2 +1,2 @@
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.2.5")
addSbtPlugin("org.scalameta" % "sbt-metals" % "0.4.4")
// addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.2.5")
// addSbtPlugin("org.scalameta" % "sbt-metals" % "0.4.4")

View File

@ -6,7 +6,7 @@ ThisBuild / useCoursier := false
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def customIvyPaths: Seq[Def.Setting[_]] = Seq(
ivyPaths := IvyPaths((baseDirectory in ThisBuild).value, Some((baseDirectory in ThisBuild).value / "ivy-cache"))
ivyPaths := IvyPaths(baseDirectory.value, Some((ThisBuild / baseDirectory).value / "ivy" / "cache"))
)
lazy val sharedResolver: Resolver = {

View File

@ -2,8 +2,8 @@ lazy val root = project
val checkComputedOnce = taskKey[Unit]("Check computed once")
checkComputedOnce := {
val buildValue = (foo in ThisBuild).value
val buildValue = (ThisBuild / foo).value
assert(buildValue == "build 0", "Setting in ThisBuild was computed twice")
val globalValue = (foo in Global).value
val globalValue = (ThisBuild / foo).value
assert(globalValue == "global 0", "Setting in Global was computed twice")
}