[2.x] refactor: Remove useCoursier setting (drop Ivy) (#7712)

**Problem**
It's been a while since Coursier has been the default library management engine,
and we don't need to support two.

**Solution**
This removes `useCoursier` setting.
This commit is contained in:
eugene yokota 2024-10-02 14:33:54 -04:00 committed by GitHub
parent d4e2f91008
commit eb5c3cfccf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
127 changed files with 82 additions and 1918 deletions

View File

@ -9,7 +9,7 @@
package sbt
import java.io.{ File, PrintWriter }
import java.net.{ URI, URL }
import java.net.URL
import java.nio.file.{ Files, Paths, Path => NioPath }
import java.util.Optional
import java.util.concurrent.TimeUnit
@ -259,7 +259,6 @@ object Defaults extends BuildCommon {
exportJars :== true,
trackInternalDependencies :== TrackLevel.TrackAlways,
exportToInternal :== TrackLevel.TrackAlways,
useCoursier :== SysProp.defaultUseCoursier,
retrieveManaged :== false,
retrieveManagedSync :== false,
configurationsToRetrieve :== None,
@ -303,10 +302,7 @@ object Defaults extends BuildCommon {
csrSameVersions := Seq(
ScalaArtifacts.Artifacts.map(a => InclExclRule(scalaOrganization.value, a)).toSet
),
csrCacheDirectory := {
if (useCoursier.value) LMCoursier.defaultCacheLocation
else Classpaths.dummyCoursierDirectory(appConfiguration.value)
}
csrCacheDirectory := LMCoursier.defaultCacheLocation,
)
/** Core non-plugin settings for sbt builds. These *must* be on every build or the sbt engine will fail to run at all. */
@ -723,8 +719,6 @@ object Defaults extends BuildCommon {
},
crossSbtVersions := Vector((pluginCrossBuild / sbtVersion).value),
crossTarget := target.value,
cleanIvy := IvyActions.cleanCachedResolutionCache(ivyModule.value, streams.value.log),
clean := clean.dependsOnTask(cleanIvy).value,
scalaCompilerBridgeBinaryJar := Def.settingDyn {
val sv = scalaVersion.value
val managed = managedScalaInstance.value
@ -2879,9 +2873,8 @@ object Defaults extends BuildCommon {
)
def dependencyResolutionTask: Def.Initialize[Task[DependencyResolution]] =
Def.taskIf {
if (useCoursier.value) CoursierDependencyResolution(csrConfiguration.value)
else IvyDependencyResolution(ivyConfiguration.value)
Def.task {
CoursierDependencyResolution(csrConfiguration.value)
}
def templateRunLocalInputTask(
@ -3380,16 +3373,14 @@ object Classpaths {
val ac = appConfiguration.value
val ip = ivyPaths.value
// if ivyPaths is customized, create coursier-cache directory in it
if (useCoursier.value) {
val defaultIvyCache = bootIvyHome(ac)
if (old != LMCoursier.defaultCacheLocation) old
else if (ip.ivyHome == defaultIvyCache) old
else
ip.ivyHome match {
case Some(home) => new File(home) / "coursier-cache"
case _ => old
}
} else Classpaths.dummyCoursierDirectory(ac)
val defaultIvyCache = bootIvyHome(ac)
if (old != LMCoursier.defaultCacheLocation) old
else if (ip.ivyHome == defaultIvyCache) old
else
ip.ivyHome match {
case Some(home) => new File(home) / "coursier-cache"
case _ => old
}
},
dependencyCacheDirectory := {
val st = state.value
@ -3497,9 +3488,7 @@ object Classpaths {
)
)
val use = useCoursier.value
if (use) confs ++ extraSources.toSeq ++ extraDocs.toSeq
else confs
confs ++ extraSources.toSeq ++ extraDocs.toSeq
},
moduleSettings := moduleSettings0.value,
makePomConfiguration := {
@ -3895,18 +3884,6 @@ object Classpaths {
csrResolvers :=
CoursierRepositoriesTasks.coursierResolversTask(scalaCompilerBridgeResolvers).value,
externalResolvers := scalaCompilerBridgeResolvers.value,
ivyConfiguration := InlineIvyConfiguration(
lock = Option(lock(appConfiguration.value)),
log = Option(streams.value.log),
updateOptions = UpdateOptions(),
paths = Option(ivyPaths.value),
resolvers = scalaCompilerBridgeResolvers.value.toVector,
otherResolvers = Vector.empty,
moduleConfigurations = Vector.empty,
checksums = checksums.value.toVector,
managedChecksums = false,
resolutionCacheDir = Some(target.value / "bridge-resolution-cache"),
)
)
) ++ Seq(
bootIvyConfiguration := (updateSbtClassifiers / ivyConfiguration).value,
@ -4894,79 +4871,6 @@ trait BuildExtra extends BuildCommon with DefExtra {
Seq(artLocal := artifact.value, taskLocal := taskDef.value, art, pkgd)
}
def externalIvySettings(
file: Initialize[File] = inBase("ivysettings.xml"),
addMultiResolver: Boolean = true
): Setting[Task[IvyConfiguration]] =
externalIvySettingsURI(file(_.toURI), addMultiResolver)
def externalIvySettingsURL(
url: URL,
addMultiResolver: Boolean = true
): Setting[Task[IvyConfiguration]] =
externalIvySettingsURI(Def.value(url.toURI), addMultiResolver)
def externalIvySettingsURI(
uri: Initialize[URI],
addMultiResolver: Boolean = true
): Setting[Task[IvyConfiguration]] = {
val other = Def.task {
(
baseDirectory.value,
appConfiguration.value,
projectResolver.value,
updateOptions.value,
streams.value
)
}
ivyConfiguration := ((uri zipWith other) { case (u, otherTask) =>
otherTask map { case (base, app, pr, uo, s) =>
val extraResolvers = if (addMultiResolver) Vector(pr) else Vector.empty
ExternalIvyConfiguration()
.withLock(lock(app))
.withBaseDirectory(base)
.withLog(s.log)
.withUpdateOptions(uo)
.withUri(u)
.withExtraResolvers(extraResolvers)
}
}).value
}
private[this] def inBase(name: String): Initialize[File] = Def.setting {
baseDirectory.value / name
}
@deprecated(
"externalIvyFile is not supported by Coursier, and will be removed in the future",
since = "1.5.0"
)
def externalIvyFile(
file: Initialize[File] = inBase("ivy.xml"),
iScala: Initialize[Option[ScalaModuleInfo]] = scalaModuleInfo
): Setting[Task[ModuleSettings]] =
moduleSettings := IvyFileConfiguration(
ivyValidate.value,
iScala.value,
file.value,
managedScalaInstance.value
)
@deprecated(
"externalPom is not supported by Coursier, and will be removed in the future",
since = "1.5.0"
)
def externalPom(
file: Initialize[File] = inBase("pom.xml"),
iScala: Initialize[Option[ScalaModuleInfo]] = scalaModuleInfo,
): Setting[Task[ModuleSettings]] =
moduleSettings := PomConfiguration(
ivyValidate.value,
iScala.value,
file.value,
managedScalaInstance.value,
)
def runInputTask(
config: Configuration,
mainClass: String,

View File

@ -248,7 +248,6 @@ object Keys {
val semanticdbOptions = settingKey[Seq[String]]("The Scalac options introduced for SemanticDB").withRank(CSetting)
val clean = taskKey[Unit]("Deletes files produced by the build, such as generated sources, compiled classes, and task caches.").withRank(APlusTask)
private[sbt] val cleanIvy = taskKey[Unit]("Deletes the ivy cached resolution")
val console = taskKey[Unit]("Starts the Scala interpreter with the project classes on the classpath.").withRank(APlusTask)
val consoleQuick = TaskKey[Unit]("consoleQuick", "Starts the Scala interpreter with the project dependencies on the classpath.", ATask, console)
val consoleProject = taskKey[Unit]("Starts the Scala interpreter with the sbt and the build definition on the classpath and useful imports.").withRank(AMinusTask)
@ -486,7 +485,6 @@ object Keys {
@cacheLevel(include = Array.empty)
val bspReporter = taskKey[BuildServerReporter]("").withRank(DTask)
val useCoursier = settingKey[Boolean]("Use Coursier for dependency resolution.").withRank(BSetting)
val csrCacheDirectory = settingKey[File]("Coursier cache directory. Uses -Dsbt.coursier.home or Coursier's default.").withRank(CSetting)
val csrMavenProfiles = settingKey[Set[String]]("").withRank(CSetting)
val csrConfiguration = taskKey[CoursierConfiguration]("General dependency management (Coursier) settings, such as the resolvers and options to use.").withRank(DTask)

View File

@ -260,7 +260,6 @@ private[sbt] object LibraryManagement {
Keys.TaskStreams,
UpdateConfiguration,
Option[Level.Value],
Boolean,
Seq[ScopedKey[_]],
ScopedKey[_],
Option[FiniteDuration],
@ -285,7 +284,6 @@ private[sbt] object LibraryManagement {
Keys.streams,
Keys.updateConfiguration.toTaskable,
(Keys.update / Keys.logLevel).?.toTaskable,
Keys.useCoursier.toTaskable,
Keys.executionRoots,
Keys.resolvedScoped.toTaskable,
Keys.forceUpdatePeriod.toTaskable,
@ -310,7 +308,6 @@ private[sbt] object LibraryManagement {
s,
conf,
maybeUpdateLevel,
csr,
er,
rs,
fup,
@ -332,80 +329,56 @@ private[sbt] object LibraryManagement {
import Keys._
val cacheDirectory = s.cacheDirectory
val isRoot = er.contains(rs)
if csr then {
// following copied from https://github.com/coursier/sbt-coursier/blob/9173406bb399879508aa481fed16efda72f55820/modules/sbt-lm-coursier/src/main/scala/sbt/hack/Foo.scala
val shouldForce = isRoot || {
fup match
case None => false
case Some(period) =>
val fullUpdateOutput = cacheDirectory / "output"
val now = System.currentTimeMillis
val diff = now - fullUpdateOutput.lastModified()
val elapsedDuration = new FiniteDuration(
diff,
java.util.concurrent.TimeUnit.MILLISECONDS
)
fullUpdateOutput.exists() && elapsedDuration > period
}
val updateConf = {
import UpdateLogging.{ Full, DownloadOnly, Default }
val conf1 = maybeUpdateLevel.orElse(state0.get(logLevel.key)) match
case Some(Level.Debug) if conf.logging == Default => conf.withLogging(logging = Full)
case Some(_) if conf.logging == Default => conf.withLogging(logging = DownloadOnly)
case _ => conf
// logical clock is folded into UpdateConfiguration
conf1.withLogicalClock(LogicalClock(state0.hashCode))
}
cachedUpdate(
// LM API
lm = lm,
// Ivy-free ModuleDescriptor
module = im,
s.cacheStoreFactory.sub(ucn),
Reference.display(thisRef),
updateConf,
identity,
skip = sk,
force = shouldForce,
depsUpdated = tu.exists(!_.stats.cached),
uwConfig = uwConfig,
evictionLevel = Level.Debug,
versionSchemeOverrides = Nil,
assumedEvictionErrorLevel = Level.Debug,
assumedVersionScheme = VersionScheme.Always,
assumedVersionSchemeJava = VersionScheme.Always,
mavenStyle = mavenStyle,
compatWarning = cwo,
includeCallers = false,
includeDetails = false,
log = s.log
)
} else {
lazy val updateConfig = conf
.withMetadataDirectory(dcd)
.withArtifactFilter(
conf.artifactFilter.map(af => af.withInverted(!af.inverted))
)
val out = ivySbt0.withIvy(s.log)(_.getSettings.getDefaultIvyUserDir)
withExcludes(out, mod.classifiers, lock(app)) { excludes =>
lm.updateClassifiers(
GetClassifiersConfiguration(
mod,
excludes.toVector,
updateConfig,
srcTypes.toVector,
docTypes.toVector
),
uwConfig,
Vector.empty,
s.log
) match
case Left(_) => ???
case Right(ur) => ur
}
// following copied from https://github.com/coursier/sbt-coursier/blob/9173406bb399879508aa481fed16efda72f55820/modules/sbt-lm-coursier/src/main/scala/sbt/hack/Foo.scala
val shouldForce = isRoot || {
fup match
case None => false
case Some(period) =>
val fullUpdateOutput = cacheDirectory / "output"
val now = System.currentTimeMillis
val diff = now - fullUpdateOutput.lastModified()
val elapsedDuration = new FiniteDuration(
diff,
java.util.concurrent.TimeUnit.MILLISECONDS
)
fullUpdateOutput.exists() && elapsedDuration > period
}
val updateConf = {
import UpdateLogging.{ Full, DownloadOnly, Default }
val conf1 = maybeUpdateLevel.orElse(state0.get(logLevel.key)) match
case Some(Level.Debug) if conf.logging == Default => conf.withLogging(logging = Full)
case Some(_) if conf.logging == Default => conf.withLogging(logging = DownloadOnly)
case _ => conf
// logical clock is folded into UpdateConfiguration
conf1.withLogicalClock(LogicalClock(state0.hashCode))
}
cachedUpdate(
// LM API
lm = lm,
// Ivy-free ModuleDescriptor
module = im,
s.cacheStoreFactory.sub(ucn),
Reference.display(thisRef),
updateConf,
identity,
skip = sk,
force = shouldForce,
depsUpdated = tu.exists(!_.stats.cached),
uwConfig = uwConfig,
evictionLevel = Level.Debug,
versionSchemeOverrides = Nil,
assumedEvictionErrorLevel = Level.Debug,
assumedVersionScheme = VersionScheme.Always,
assumedVersionSchemeJava = VersionScheme.Always,
mavenStyle = mavenStyle,
compatWarning = cwo,
includeCallers = false,
includeDetails = false,
log = s.log
)
}.tag(Tags.Update, Tags.Network)
// Used by Defaults.withExcludes
def withExcludes(out: File, classifiers: Seq[String], lock: xsbti.GlobalLock)(
f: Map[ModuleID, Vector[ConfigRef]] => UpdateReport
): UpdateReport = {

View File

@ -16,13 +16,7 @@ import java.nio.file.Files
import lmcoursier.definitions.{ Configuration, Project }
import org.apache.ivy.core.module.id.ModuleRevisionId
import Def.Setting
import sbt.Keys.{
csrProject,
csrPublications,
publishLocalConfiguration,
publishConfiguration,
useCoursier
}
import sbt.Keys.{ csrProject, csrPublications, publishLocalConfiguration, publishConfiguration }
import sbt.ProjectExtra.*
import sbt.librarymanagement.PublishConfiguration
import scala.jdk.CollectionConverters.*
@ -201,20 +195,18 @@ object IvyXml {
shadedConfigOpt: Option[Configuration]
): Setting[Task[T]] =
task := task.dependsOnTask {
Def.taskIf {
if useCoursier.value then
val currentProject = {
val proj = csrProject.value
val publications = csrPublications.value
proj.withPublications(publications)
}
IvyXml.writeFiles(
currentProject,
shadedConfigOpt,
sbt.Keys.ivySbt.value,
sbt.Keys.streams.value.log
)
else ()
Def.task {
val currentProject = {
val proj = csrProject.value
val publications = csrPublications.value
proj.withPublications(publications)
}
IvyXml.writeFiles(
currentProject,
shadedConfigOpt,
sbt.Keys.ivySbt.value,
sbt.Keys.streams.value.log
)
}
}.value

View File

@ -1,5 +1,3 @@
ThisBuild / useCoursier := false
scalacOptions ++= Seq("-feature", "-language:postfixOps", "-Ywarn-unused:_,-imports")
addSbtPlugin("com.github.sbt" % "sbt-dynver" % "5.0.1")

View File

@ -1,16 +1,11 @@
import xsbti.HashedVirtualFileRef
// https://github.com/coursier/coursier/issues/1123
ThisBuild / useCoursier := false
Seq(
ThisBuild / autoAPIMappings := true,
ThisBuild / packageDoc / publishArtifact := false,
packageSrc / publishArtifact := false,
ThisBuild / organization := "org.example",
ThisBuild / scalaVersion := "3.2.1",
version := "1.0",
)
autoAPIMappings := true
packageDoc / publishArtifact := false
packageSrc / publishArtifact := false
organization := "org.example"
scalaVersion := "3.2.1"
version := "1.0"
val aPublishResolver = Def.setting {
Resolver.file("a-resolver", (ThisBuild / baseDirectory).value / "a-repo")

View File

@ -1,7 +1,6 @@
// ThisBuild / useCoursier := false
ThisBuild / scalaVersion := "2.12.19"
ThisBuild / organization := "org.example"
ThisBuild / version := "0.1"
scalaVersion := "2.12.19"
organization := "org.example"
version := "0.1"
name := "blubber"
libraryDependencies += "org.typelevel" %% "cats-effect" % "2.2.0"

View File

@ -5,7 +5,6 @@ lazy val checkFull = taskKey[Unit]("")
lazy val check = taskKey[Unit]("")
lazy val checkArtifact = taskKey[Unit]("")
ThisBuild / useCoursier := false
ThisBuild / scalaVersion := "2.12.19"
ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / organization := "com.example"

View File

@ -3,7 +3,6 @@ import xsbti.AppConfiguration
ThisBuild / scalaVersion := "2.12.19"
// TTL of Coursier is 24h
ThisBuild / useCoursier := false
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =

View File

@ -1,62 +0,0 @@
lazy val check = taskKey[Unit]("Runs the check")
val sprayV = "1.1.1"
val playVersion = "2.2.0"
val summingbirdVersion = "0.4.0"
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 localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] =
Seq(
localCache,
scalaVersion := "2.10.4",
fullResolvers := fullResolvers.value.filterNot(_.name == "inter-project"),
updateOptions := updateOptions.value.withCachedResolution(true)
)
lazy val a = project.
settings(commonSettings: _*).
settings(
name := "a",
libraryDependencies := Seq(
organization.value %% "c" % version.value,
"commons-io" % "commons-io" % "1.3",
"org.apache.spark" %% "spark-core" % "0.9.0-incubating",
"org.apache.avro" % "avro" % "1.7.7",
"com.linkedin.pegasus" % "data-avro" % "1.9.40",
"org.jboss.netty" % "netty" % "3.2.0.Final"
)
)
lazy val b = project.
settings(commonSettings: _*).
settings(
name := "b",
// this adds circular dependency
libraryDependencies := Seq(organization.value %% "c" % version.value)
)
lazy val c = project.
settings(commonSettings: _*).
settings(
name := "c",
libraryDependencies := Seq(organization.value %% "b" % version.value)
)
lazy val root = (project in file(".")).
settings(commonSettings: _*).
settings(
check := {
val acp = (a / Compile / externalDependencyClasspath).value.map {_.data.name}.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

@ -1,53 +0,0 @@
lazy val check = taskKey[Unit]("Runs the check")
val sprayV = "1.1.1"
val playVersion = "2.2.0"
val summingbirdVersion = "0.4.0"
val luceneVersion = "4.0.0"
val akkaVersion = "2.3.1"
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] =
Seq(
localCache,
scalaVersion := "2.10.4",
fullResolvers := fullResolvers.value.filterNot(_.name == "inter-project")
)
lazy val a = project.
settings(
commonSettings,
name := "a",
libraryDependencies := Seq(
"commons-io" % "commons-io" % "1.3",
"org.apache.spark" %% "spark-core" % "0.9.0-incubating",
"org.apache.avro" % "avro" % "1.7.7",
"com.linkedin.pegasus" % "data-avro" % "1.9.40",
"org.jboss.netty" % "netty" % "3.2.0.Final"
)
)
lazy val b = project.
settings(
commonSettings,
name := "b"
)
lazy val c = project.
settings(
commonSettings,
name := "c",
libraryDependencies := Seq(organization.value %% "b" % version.value)
)
lazy val root = (project in file(".")).
settings(commonSettings).
settings(inThisBuild(Seq(
organization := "org.example",
version := "1.0-SNAPSHOT",
updateOptions := updateOptions.value.withCachedResolution(true)
)))

View File

@ -1,13 +0,0 @@
> a/publishLocal
> b/publishLocal
> c/publishLocal
$ copy-file changes/multi.sbt multi.sbt
> reload
> b/publishLocal
> check

View File

@ -1,3 +0,0 @@
public class A {
public static final int x = 3;
}

View File

@ -1,5 +0,0 @@
public final class C {
public static void main(String[] args) {
System.out.println(A.x);
}
}

View File

@ -1,106 +0,0 @@
ThisBuild / useCoursier := false
lazy val check = taskKey[Unit]("Runs the check")
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] =
Seq(
localCache,
dependencyCacheDirectory := (LocalRootProject / baseDirectory).value / "dependency",
scalaVersion := "2.10.4",
resolvers += Resolver.sonatypeRepo("snapshots")
)
lazy val classifierTest = project.
settings(commonSettings: _*).
settings(
libraryDependencies := Seq(
("net.sf.json-lib" % "json-lib" % "2.4").classifier("jdk15").intransitive(),
"commons-io" % "commons-io" % "1.4"
)
)
lazy val transitiveTest = project.
settings(commonSettings: _*).
settings(
libraryDependencies := Seq(
"junit" % "junit" % "4.13.1" % "test"
)
)
lazy val a = project.
dependsOn(classifierTest, transitiveTest % "test->test").
settings(commonSettings: _*).
settings(
updateOptions := updateOptions.value.withCachedResolution(true),
(Compile / packageBin / artifact) := Artifact("demo"),
libraryDependencies := Seq(
"com.typesafe.akka" %% "akka-remote" % "2.3.4" exclude("com.typesafe.akka", "akka-actor_2.10"),
"net.databinder" %% "unfiltered-uploads" % "0.8.0",
("commons-io" % "commons-io" % "1.4").classifier("sources"),
"com.typesafe" % "config" % "0.4.9-SNAPSHOT"
)
)
lazy val b = project.
dependsOn(classifierTest, transitiveTest % "test->test").
settings(commonSettings: _*).
settings(
libraryDependencies := Seq(
"com.typesafe.akka" %% "akka-remote" % "2.3.4" exclude("com.typesafe.akka", "akka-actor_2.10"),
"net.databinder" %% "unfiltered-uploads" % "0.8.0",
("commons-io" % "commons-io" % "1.4").classifier("sources"),
"com.typesafe" % "config" % "0.4.9-SNAPSHOT"
)
)
lazy val c = project.
dependsOn(a).
settings(commonSettings: _*).
settings(
updateOptions := updateOptions.value.withCachedResolution(true)
)
lazy val root = (project in file(".")).
settings(
(ThisBuild / organization) := "org.example",
(ThisBuild / version) := "1.0",
check := {
val acp = (a / Compile / externalDependencyClasspath).value.map {_.data.name}.sorted
val bcp = (b / Compile / externalDependencyClasspath).value.map {_.data.name}.sorted
val ccp = (c / Compile / externalDependencyClasspath).value.map {_.data.name}.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"}
val ccpWithoutSource = ccp filterNot { _ == "commons-io-1.4.jar"}
if (acpWithoutSource == bcpWithoutSource && acpWithoutSource == ccpWithoutSource) ()
else sys.error("Different classpaths are found:" +
"\n - a (cached) " + acpWithoutSource.toString +
"\n - b (plain) " + bcpWithoutSource.toString +
"\n - c (inter-project) " + ccpWithoutSource.toString)
val atestcp = (a / Test / externalDependencyClasspath).value.map {_.data.name}.sorted filterNot { _ == "commons-io-1.4.jar"}
val btestcp = (b / Test / externalDependencyClasspath).value.map {_.data.name}.sorted filterNot { _ == "commons-io-1.4.jar"}
val ctestcp = (c / Test / externalDependencyClasspath).value.map {_.data.name}.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)
}
if (atestcp == btestcp) ()
else sys.error("Different classpaths are found:" +
"\n - a test (cached) " + atestcp.toString +
"\n - b test (plain) " + btestcp.toString)
}
)

View File

@ -1,15 +0,0 @@
> a/update
> a/updateClassifiers
> a/publishLocal
> check
> a/clean
> b/clean
> c/clean
> check

View File

@ -1,5 +0,0 @@
package a
object A {
romanowski.sbt.bug.MissingClass("A")
}

View File

@ -1,5 +0,0 @@
package b
object B {
romanowski.sbt.bug.MissingClass("A")
}

View File

@ -1,43 +0,0 @@
import xsbti.AppConfiguration
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
ThisBuild / scalaVersion := "2.12.17"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Vector[Def.Setting[_]] =
Vector(
organization := "com.example",
localCache,
dependencyCacheDirectory := (LocalRootProject / baseDirectory).value / "dependency",
scalaCompilerBridgeResolvers += userLocalFileResolver(appConfiguration.value),
resolvers += Resolver.file("buggy", (LocalRootProject / baseDirectory).value / "repo")(
Patterns(
ivyPatterns = Vector("[organization]/[module]/[revision]/ivy.xml"),
artifactPatterns = Vector("[organization]/[module]/[revision]/[artifact]"),
isMavenCompatible = false,
descriptorOptional = true,
skipConsistencyCheck = true
)
)
)
lazy val a = project settings(
commonSettings,
updateOptions := updateOptions.value.withCachedResolution(true), //comment this line to make ws compile
libraryDependencies += "a" % "b" % "1.0.0" % "compile->runtime",
libraryDependencies += "a" % "b" % "1.0.0" % "compile->runtime2"
)
lazy val b = project dependsOn(a) settings(
commonSettings,
updateOptions := updateOptions.value.withCachedResolution(true), //comment this line to make ws compile
libraryDependencies += "a" % "b" % "1.0.1" % "compile->runtime"
)
// use the user local resolver to fetch the SNAPSHOT version of the compiler-bridge
def userLocalFileResolver(appConfig: AppConfiguration): Resolver = {
val ivyHome = appConfig.provider.scalaProvider.launcher.ivyHome
Resolver.file("User Local", ivyHome / "local")(Resolver.defaultIvyPatterns)
}

View File

@ -1,16 +0,0 @@
<ivy-module xmlns:e="http://ant.apache.org/ivy/extra" version="2.0">
<info organisation="a" module="b" revision="1.0.0" status="release" publication="20160201120702">
<description>a</description>
</info>
<configurations>
<conf name="runtime" description="..."/>
<conf name="runtime2" description="..."/>
</configurations>
<publications>
<artifact name="b1.jar" type="jar" ext="jar" conf="runtime"/>
<artifact name="b2.jar" type="jar" ext="jar" conf="runtime"/>
<artifact name="b3.jar" type="jar" ext="jar" conf="runtime2"/>
</publications>
<dependencies>
</dependencies>
</ivy-module>

View File

@ -1,16 +0,0 @@
<ivy-module xmlns:e="http://ant.apache.org/ivy/extra" version="2.0">
<info organisation="a" module="b" revision="1.0.1" status="release" publication="20160201120702">
<description>a</description>
</info>
<configurations>
<conf name="runtime" description="..."/>
<conf name="runtime2" description="..."/>
</configurations>
<publications>
<artifact name="b1.jar" type="jar" ext="jar" conf="runtime"/>
<artifact name="b2.jar" type="jar" ext="jar" conf="runtime"/>
<artifact name="b3.jar" type="jar" ext="jar" conf="runtime2"/>
</publications>
<dependencies>
</dependencies>
</ivy-module>

View File

@ -1,11 +0,0 @@
# In this test, we have a project `a`, on which a project `b` depends.
# project `a` has a library dependency on:
# - "a" % "b" % "1.0.0" % "compile->runtime"
# - "a" % "b" % "1.0.0" % "compile->runtime2"
# project "b" depends on:
# - project `a`
# - "b" % "b" % "1.0.1" % "compile->runtime"
# "a" % "b" % "1.0.0" will be evicted in favor of "a" % "b" % "1.0.1", but we
# have to keep the dependency on the two configurations "runtime" and "runtime2".
# This test makes sure that we actually do.
> compile

View File

@ -1,56 +0,0 @@
// https://github.com/sbt/sbt/issues/1710
// https://github.com/sbt/sbt/issues/1760
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
inThisBuild(Seq(
organization := "com.example",
version := "0.1.0",
scalaVersion := "2.10.4",
updateOptions := updateOptions.value.withCachedResolution(true)
))
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] = Seq(
localCache,
dependencyCacheDirectory := (LocalRootProject / baseDirectory).value / "dependency",
fullResolvers := fullResolvers.value.filterNot(_.name == "inter-project")
)
val x1 = project.settings(
commonSettings,
libraryDependencies += "com.example" %% "y1" % "0.1.0" % "compile;runtime->runtime",
libraryDependencies += "com.example" %% "y2" % "0.1.0" % "compile;runtime->runtime"
)
val y1 = project.settings(
commonSettings,
libraryDependencies ++= Seq(
"com.ning" % "async-http-client" % "1.8.14", // this includes slf4j 1.7.5
"com.twitter" % "summingbird-core_2.10" % "0.5.0", // this includes slf4j 1.6.6
("org.slf4j" % "slf4j-api" % "1.6.6").force(),
"commons-logging" % "commons-logging" % "1.1" // this includes servlet-api 2.3
)
)
val y2 = project.settings(
commonSettings,
libraryDependencies ++= Seq(
"com.twitter" % "summingbird-core_2.10" % "0.5.0", // this includes slf4j 1.6.6
"com.ning" % "async-http-client" % "1.8.14", // this includes slf4j 1.7.5
"commons-logging" % "commons-logging" % "1.1.3"
)
)
TaskKey[Unit]("check") := {
val x1cp = (x1 / Compile / externalDependencyClasspath).value.map(_.data.name).sorted
def x1cpStr = x1cp.mkString("\n* ", "\n* ", "")
// if (!(x1cp contains "slf4j-api-1.6.6.jar"))
// sys.error(s"slf4j-api-1.6.6.jar is not found on X1:$x1cpStr")
if (x1cp contains "servlet-api-2.3.jar")
sys.error(s"servlet-api-2.3.jar is found when it should be evicted:$x1cpStr")
}

View File

@ -1,3 +0,0 @@
> y1/publishLocal
> y2/publishLocal
> check

View File

@ -1,54 +0,0 @@
// https://github.com/sbt/sbt/issues/1649
lazy val check = taskKey[Unit]("Runs the check")
ThisBuild / useCoursier := false
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] =
Seq(
localCache,
dependencyCacheDirectory := (LocalRootProject / baseDirectory).value / "dependency",
scalaVersion := "2.10.4",
resolvers += Resolver.sonatypeRepo("snapshots")
)
lazy val a = project.
settings(
commonSettings,
libraryDependencies += "net.databinder" %% "unfiltered-uploads" % "0.8.0" exclude("commons-io", "commons-io"),
ivyXML :=
<dependencies>
<exclude module="commons-codec"/>
</dependencies>
)
lazy val b = project.
settings(
commonSettings,
libraryDependencies += "net.databinder" %% "unfiltered-uploads" % "0.8.0"
)
lazy val root = (project in file(".")).
aggregate(a, b).
settings(inThisBuild(Seq(
organization := "org.example",
version := "1.0",
updateOptions := updateOptions.value.withCachedResolution(true),
check := {
val acp = (a / Compile / externalDependencyClasspath).value.sortBy {_.data.name}
val bcp = (b / Compile / externalDependencyClasspath).value.sortBy {_.data.name}
if (acp exists { _.data.name contains "commons-io" }) {
sys.error("commons-io found when it should be excluded")
}
if (acp exists { _.data.name contains "commons-codec" }) {
sys.error("commons-codec found when it should be excluded")
}
// This is checking to make sure excluded graph is not getting picked up
if (!(bcp exists { _.data.name contains "commons-io" })) {
sys.error("commons-io NOT found when it should NOT be excluded")
}
}
)))

View File

@ -1,5 +0,0 @@
> a/update
> b/update
> check

View File

@ -1,108 +0,0 @@
lazy val check = taskKey[Unit]("Runs the check")
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] =
Seq(
localCache,
dependencyCacheDirectory := (LocalRootProject / baseDirectory).value / "dependency",
scalaVersion := "2.10.4",
resolvers += Resolver.sonatypeRepo("snapshots")
)
def cachedResolutionSettings: Seq[Def.Setting[_]] =
commonSettings ++ Seq(
updateOptions := updateOptions.value.withCachedResolution(true)
)
lazy val a = project.
settings(cachedResolutionSettings: _*).
settings(
libraryDependencies := Seq(
("org.springframework" % "spring-core" % "3.2.2.RELEASE").force().exclude("org.springframework", "spring-asm"),
("org.springframework" % "spring-tx" % "3.1.2.RELEASE").force().exclude("org.springframework", "spring-asm"),
("org.springframework" % "spring-beans" % "3.2.2.RELEASE").force().exclude("org.springframework", "spring-asm"),
("org.springframework" % "spring-context" % "3.1.2.RELEASE").force().exclude("org.springframework", "spring-asm")
)
)
lazy val b = project.
settings(commonSettings: _*).
settings(
libraryDependencies := Seq(
("org.springframework" % "spring-core" % "3.2.2.RELEASE").force().exclude("org.springframework", "spring-asm"),
("org.springframework" % "spring-tx" % "3.1.2.RELEASE").force().exclude("org.springframework", "spring-asm"),
("org.springframework" % "spring-beans" % "3.2.2.RELEASE").force().exclude("org.springframework", "spring-asm"),
("org.springframework" % "spring-context" % "3.1.2.RELEASE").force().exclude("org.springframework", "spring-asm")
)
)
lazy val c = project.
dependsOn(a).
settings(cachedResolutionSettings: _*).
settings(
libraryDependencies := Seq(
// transitive force seems to be broken in ivy
// "org.springframework" % "spring-core" % "4.0.3.RELEASE" exclude("org.springframework", "spring-asm")
)
)
lazy val d = project.
dependsOn(b).
settings(commonSettings: _*).
settings(
libraryDependencies := Seq(
// transitive force seems to be broken in ivy
// "org.springframework" % "spring-core" % "4.0.3.RELEASE" exclude("org.springframework", "spring-asm")
)
)
lazy val root = (project in file(".")).
aggregate(a, b, c).
settings(
ThisBuild / organization := "org.example",
ThisBuild / version := "1.0",
check := {
// sys.error(dependencyCacheDirectory.value.toString)
val acp = (a / Compile / externalDependencyClasspath).value.sortBy {_.data.name}
val bcp = (b / Compile / externalDependencyClasspath).value.sortBy {_.data.name}
val ccp = (c / Compile / externalDependencyClasspath).value.sortBy {_.data.name}
val dcp = (d / Compile / externalDependencyClasspath).value.sortBy {_.data.name}
if (!(acp exists {_.data.name contains "spring-core-3.2.2.RELEASE"})) {
sys.error("spring-core-3.2.2 is not found on a")
}
if (!(bcp exists {_.data.name contains "spring-core-3.2.2.RELEASE"})) {
sys.error("spring-core-3.2.2 is not found on b")
}
if (!(ccp exists {_.data.name contains "spring-core-3.2.2.RELEASE"})) {
sys.error("spring-core-3.2.2 is not found on c")
}
if (!(dcp exists {_.data.name contains "spring-core-3.2.2.RELEASE"})) {
sys.error("spring-core-3.2.2 is not found on d\n" + dcp.toString)
}
if (!(acp exists {_.data.name contains "spring-tx-3.1.2.RELEASE"})) {
sys.error("spring-tx-3.1.2 is not found on a")
}
if (!(bcp exists {_.data.name contains "spring-tx-3.1.2.RELEASE"})) {
sys.error("spring-tx-3.1.2 is not found on b")
}
if (!(ccp exists {_.data.name contains "spring-tx-3.1.2.RELEASE"})) {
sys.error("spring-tx-3.1.2 is not found on c")
}
if (!(dcp exists {_.data.name contains "spring-tx-3.1.2.RELEASE"})) {
sys.error("spring-tx-3.1.2 is not found on d")
}
if (acp == bcp) ()
else sys.error("Different classpaths are found:" +
"\n - a (consolidated) " + acp.toString +
"\n - b (plain) " + bcp.toString)
if (ccp == dcp) ()
else sys.error("Different classpaths are found:" +
"\n - c (consolidated) " + ccp.toString +
"\n - d (plain) " + dcp.toString)
}
)

View File

@ -1,5 +0,0 @@
> check
> clean
> check

View File

@ -1,59 +0,0 @@
// https://github.com/sbt/sbt/issues/1730
lazy val check = taskKey[Unit]("Runs the check")
val scalatest = "org.scalatest" %% "scalatest" % "3.0.5"
val junit = "junit" % "junit" % "4.13.1"
ThisBuild / scalaVersion := "2.12.19"
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] =
Seq(
localCache,
dependencyCacheDirectory := (LocalRootProject / baseDirectory).value / "dependency",
resolvers += Resolver.sonatypeRepo("snapshots")
)
lazy val transitiveTest = project.
settings(
commonSettings,
libraryDependencies += junit % Test
)
lazy val transitiveTestDefault = project.
settings(
commonSettings,
libraryDependencies += scalatest
)
lazy val a = project.
dependsOn(transitiveTestDefault % Test, transitiveTest % "test->test").
settings(commonSettings)
lazy val root = (project in file(".")).
aggregate(a).
settings(inThisBuild(Seq(
organization := "org.example",
version := "1.0",
updateOptions := updateOptions.value.withCachedResolution(true),
check := {
val ur = (a / update).value
val acp = (a / Compile / externalDependencyClasspath).value.map {_.data.name}
val atestcp0 = (a / Test / fullClasspath).value
val atestcp = (a / Test / externalDependencyClasspath).value.map {_.data.name}
// 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)
}
// This is checking to make sure interproject dependency works
if (!(atestcp exists { _ contains "scalatest" })) {
sys.error("scalatest NOT found when it should be included: " + atestcp.toString)
}
// This is checking to make sure interproject dependency works
if (!(atestcp exists { _ contains "junit" })) {
sys.error("junit NOT found when it should be included: " + atestcp.toString)
}
}
)))

View File

@ -1,53 +0,0 @@
lazy val check = taskKey[Unit]("Runs the check")
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
ThisBuild / organization := "org.example"
ThisBuild / version := "1.0"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] =
Seq(
localCache,
dependencyCacheDirectory := (LocalRootProject / baseDirectory).value / "dependency",
libraryDependencies := Seq(
"net.databinder" %% "unfiltered-uploads" % "0.8.0",
"commons-io" % "commons-io" % "1.3",
"org.scala-refactoring" %% "org.scala-refactoring.library" % "0.6.2",
"org.scala-lang" % "scala-compiler" % scalaVersion.value
),
scalaVersion := "2.11.2",
resolvers += Resolver.sonatypeRepo("snapshots")
)
def consolidatedResolutionSettings: Seq[Def.Setting[_]] =
commonSettings ++ Seq(
updateOptions := updateOptions.value.withCachedResolution(true)
)
// overrides cached
lazy val a = project.
settings(consolidatedResolutionSettings: _*).
settings(
dependencyOverrides += "commons-io" % "commons-io" % "2.0"
)
// overrides plain
lazy val b = project.
settings(commonSettings: _*).
settings(
dependencyOverrides += "commons-io" % "commons-io" % "2.0"
)
lazy val root = (project in file(".")).
settings(
check := {
val acp = (a / Compile / externalDependencyClasspath).value.sortBy {_.data.name}
val bcp = (b / Compile / externalDependencyClasspath).value.sortBy {_.data.name}
if (acp == bcp) ()
else sys.error("Different classpaths are found:" +
"\n - a (overrides + cached) " + acp.toString +
"\n - b (overrides + plain) " + bcp.toString)
}
)

View File

@ -1,4 +1,3 @@
ThisBuild / useCoursier := false
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
lazy val check = taskKey[Unit]("Runs the check")

View File

@ -1,5 +1,3 @@
ThisBuild / useCoursier := false
lazy val root = (project in file("."))
.settings(
configurationsToRetrieve := Some(Vector(Compile)),

View File

@ -1,5 +1,3 @@
ThisBuild / useCoursier := false
libraryDependencies ++= Seq(
"org.spark-project" %% "spark-core" % "0.5.1",
"log4j" % "log4j" % "1.2.17"

View File

@ -1,5 +1,3 @@
ThisBuild / useCoursier := false
resolvers += Resolver.file("buggy", file("repo"))(
Patterns(
ivyPatterns = Vector("[organization]/[module]/[revision]/ivy.xml"),

View File

@ -1,5 +1,4 @@
import xsbti.AppConfiguration
// ThisBuild / useCoursier := false
ThisBuild / organization := "com.example"
ThisBuild / scalaVersion := "2.13.12"
ThisBuild / versionScheme := Some("semver-spec")

View File

@ -1,7 +0,0 @@
ThisBuild / useCoursier := false
lazy val root = (project in file("."))
.settings(
scalaVersion := "2.12.19",
externalPom()
)

View File

@ -1,78 +0,0 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>example</artifactId>
<packaging>jar</packaging>
<version>1.0.0-SNAPSHOT</version>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<recompileMode>incremental</recompileMode>
<useZincServer>true</useZincServer>
<args>
<arg>-target:jvm-1.6</arg>
<arg>-feature</arg>
<arg>-deprecation</arg>
<arg>-encoding</arg>
<arg>UTF-8</arg>
</args>
<javacArgs>
<javacArg>-source</javacArg>
<javacArg>1.6</javacArg>
<javacArg>-Xlint:-options</javacArg>
<javacArg>-target</javacArg>
<javacArg>1.6</javacArg>
</javacArgs>
<jvmArgs>
<jvmArg>-Xmx768m</jvmArg>
<jvmArg>-Xss10m</jvmArg>
</jvmArgs>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
<executions>
<execution>
<id>scala-compile</id>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,8 +0,0 @@
// Put in src/test/scala
object Foo {
// From main slf4j-api JAR
val logger = org.slf4j.LoggerFactory.getLogger("Foo")
// From test slf4j-api JAR
val bp = new org.slf4j.helpers.BogoPerf
}

View File

@ -1,3 +0,0 @@
> export Compile/dependencyClasspath
> export Test/dependencyClasspath
> Test/compile

View File

@ -1,21 +0,0 @@
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
lazy val root = (project in file("."))
.settings(
localCache,
organization := "com.example",
version := "1.0",
name := "define-color",
projectID := {
val old = projectID.value
old.extra("e:color" -> "red")
},
publishMavenStyle := false,
publishTo := {
val base = baseDirectory.value
Some(Resolver.file("test-repo", base / "repo" / "test")(Resolver.defaultIvyPatterns))
}
)

View File

@ -1,22 +0,0 @@
ThisBuild / useCoursier := false
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
lazy val root = (project in file("."))
.settings(
localCache,
organization := "org.example",
name := "use-color",
publishMavenStyle := false,
resolvers := baseDirectory( base =>
Resolver.file("test-repo", base / "repo" / "test")(Resolver.defaultIvyPatterns) :: Nil
).value,
libraryDependencies := {
val base = baseDirectory.value
val color = IO.read(base / "color")
val dep = "com.example" %% "define-color" % "1.0" extra("e:color" -> color)
dep :: Nil
}
)

View File

@ -1,12 +0,0 @@
> publish
$ delete DefineColor.sbt
$ copy-file changes/UseColor.sbt UseColor.sbt
$ copy-file changes/blue color
> reload
-> update
$ copy-file changes/red color
> reload
> update

View File

@ -1,19 +0,0 @@
ThisBuild / useCoursier := false
name := "force-update-period"
scalaVersion := "2.12.18"
libraryDependencies += "log4j" % "log4j" % "1.2.16" % "compile"
autoScalaLibrary := false
TaskKey[Unit]("check-last-update-time") := {
val s = streams.value
val updateOutput = target.value / "update" / updateCacheName.value / "output"
if (!updateOutput.exists()) {
sys.error("Update cache does not exist")
}
val timeDiff = System.currentTimeMillis() - updateOutput.lastModified()
s.log.info(s"Amount of time since last full update: $timeDiff")
if (timeDiff > 5000) {
sys.error("Update not performed")
}
}

View File

@ -1,11 +0,0 @@
$ absent target/out/jvm/scala-2.12.18/force-update-period/resolution-cache
> compile
$ exists target/out/jvm/scala-2.12.18/force-update-period/resolution-cache
> checkLastUpdateTime
$ sleep 5000
> compile
# This is expected to fail
-> checkLastUpdateTime
> set forceUpdatePeriod := Some(new scala.concurrent.duration.FiniteDuration(5000, java.util.concurrent.TimeUnit.MILLISECONDS))
> compile
> checkLastUpdateTime

View File

@ -1,51 +0,0 @@
ThisBuild / useCoursier := false
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
import scala.xml._
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
lazy val root = (project in file(".")).
settings(
localCache,
ivyXML := inlineXML(customInfo.value, organization.value, moduleName.value, version.value),
scalaVersion := "2.9.1",
projectID ~= (_ cross false),
customInfo := (baseDirectory.value / "info").exists,
TaskKey[Unit]("check-download") := checkDownload.value,
delivered := (XML loadFile deliverLocal.value),
TaskKey[Unit]("check-info") := checkInfo.value
)
lazy val delivered = taskKey[NodeSeq]("")
lazy val customInfo = settingKey[Boolean]("")
def inlineXML(addInfo: Boolean, organization: String, moduleID: String, version: String): NodeSeq =
if (addInfo)
(<info organisation={organization} module={moduleID} revision={version}>
<license name="Two-clause BSD-style" url="https://github.com/szeiger/scala-query/blob/master/LICENSE.txt" />
<description homepage="https://github.com/szeiger/scala-query/">
ScalaQuery is a type-safe database query API for Scala.
</description>
</info>
<dependency org="org.scala-tools.testing" name="scalacheck_2.9.1" rev="1.9"/>)
else
<dependency org="org.scala-tools.testing" name="scalacheck_2.9.1" rev="1.9"/>
def checkDownload = Def task {
if ((Compile / dependencyClasspath).value.isEmpty) sys.error("Dependency not downloaded"); ()
}
def checkInfo = Def task {
val d = delivered.value
val addInfo = customInfo.value
if ((d \ "info").isEmpty)
sys.error("No info tag generated")
else if (addInfo) {
if (!deliveredWithCustom(d)) sys.error("Expected 'license' and 'description' tags in info tag, got: \n" + (d \ "info")) else ()
} else
if (deliveredWithCustom(d)) sys.error("Expected empty 'info' tag, got: \n" + (d \ "info")) else ()
}
def deliveredWithCustom(d: NodeSeq) = (d \ "info" \ "license").nonEmpty && (d \ "info" \ "description").nonEmpty

View File

@ -1,11 +0,0 @@
> checkDownload
> checkInfo
> clean
$ touch info
> reload
> show customInfo
> checkDownload
> show customInfo
> checkInfo

View File

@ -1 +0,0 @@
managedScalaInstance := false

View File

@ -1,10 +0,0 @@
ThisBuild / useCoursier := false
externalIvySettings()
externalIvyFile()
TaskKey[Unit]("check") := {
val ur = update.value
val files = ur.matching( moduleFilter(organization = "org.scalacheck", name = "scalacheck*", revision = "1.13.4") )
assert(files.nonEmpty, "ScalaCheck module not found in update report")
}

View File

@ -1,17 +0,0 @@
<ivysettings>
<settings defaultResolver="test-chain"/>
<include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-shared.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-local.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-main-chain.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-default-chain.xml"/>
<caches defaultCacheDir="${ivy.settings.dir}/target/cache"/>
<resolvers>
<chain name="test-chain" returnFirst="true" checkmodified="true">
<resolver ref="local"/>
<resolver ref="shared"/>
<resolver ref="main"/>
</chain>
</resolvers>
</ivysettings>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="org" module="ivy-settings-test"/>
<dependencies>
<dependency org="org.scalacheck" name="scalacheck_2.12" rev="1.13.4"/>
</dependencies>
</ivy-module>

View File

@ -1,11 +0,0 @@
> update
# works because scalaVersion is the same as sbtScalaVersion
> compile
$ delete auto-instance.sbt
$ copy-file changes/scalacheck-ivy.xml ivy.xml
-> update
$ copy-file changes/scala-tools-ivysettings.xml ivysettings.xml
> check
> Test/compile

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="org" module="ivy-settings-test"/>
</ivy-module>

View File

@ -1,3 +0,0 @@
<ivysettings>
<caches defaultCacheDir="${ivy.settings.dir}/target/cache"/>
</ivysettings>

View File

@ -1,3 +0,0 @@
import org.scalacheck._
object Test extends Properties("Test")

View File

@ -1,38 +0,0 @@
ThisBuild / useCoursier := false
lazy val commonSettings = Seq(
autoScalaLibrary := false,
scalaModuleInfo := None,
(Compile / unmanagedJars) ++= {
val converter = fileConverter.value
val xs = scalaInstance.value.allJars.toSeq
xs.map(_.toPath).map(x => converter.toVirtualFile(x): HashedVirtualFileRef)
},
(packageSrc / publishArtifact) := false,
(packageDoc / publishArtifact) := false,
publishMavenStyle := false
)
lazy val dep = project.
settings(
commonSettings,
organization := "org.example",
version := "1.0",
publishTo := ((ThisBuild / baseDirectory) apply { base =>
Some(Resolver.file("file", base / "repo")(Resolver.ivyStylePatterns))
}).value
)
lazy val use = project.
settings(
commonSettings,
libraryDependencies += "org.example" %% "dep" % "1.0",
externalIvySettings(),
publishTo := (baseDirectory { base =>
Some(Resolver.file("file", base / "repo")(Resolver.ivyStylePatterns))
}).value,
TaskKey[Unit]("check") := (baseDirectory map {base =>
val inCache = ( (base / "target" / "use-cache") ** "*.jar").get()
assert(inCache.isEmpty, "Cache contained jars: " + inCache)
}).value
)

View File

@ -1,3 +0,0 @@
object D {
val x = 3
}

View File

@ -1,3 +0,0 @@
> dep/publish
> use/update
> use/check

View File

@ -1,3 +0,0 @@
object U {
val x = D.x
}

View File

@ -1,10 +0,0 @@
<ivysettings>
<caches defaultCacheDir="${ivy.settings.dir}/target/use-cache" useOrigin="true"/>
<settings defaultResolver="file"/>
<resolvers>
<filesystem name="file" checkconsistency="false" descriptor="required" local="true">
<ivy pattern="${ivy.settings.dir}/../repo/[organisation]/[module]/[revision]/ivys/ivy.xml"/>
<artifact pattern="${ivy.settings.dir}/../repo/[organisation]/[module]/[revision]/[type]s/[artifact].[ext]"/>
</filesystem>
</resolvers>
</ivysettings>

View File

@ -1,21 +0,0 @@
ThisBuild / useCoursier := false
lazy val commonSettings = Seq(
autoScalaLibrary := false,
unmanagedJars in Compile ++= (scalaInstance map (_.allJars.toSeq)).value
)
lazy val dep = project.
settings(
commonSettings,
organization := "org.example",
version := "1.0"
)
lazy val use = project.
dependsOn(dep).
settings(
commonSettings,
libraryDependencies += "junit" % "junit" % "4.13.1",
externalIvySettings()
)

View File

@ -1,11 +0,0 @@
<ivysettings>
<caches defaultCacheDir="${ivy.settings.dir}/target/use-cache" useOrigin="true"/>
<settings defaultResolver="test-chain"/>
<resolvers>
<ibiblio name="central" m2compatible="true"/>
<chain name="test-chain" returnFirst="true" checkmodified="true">
<resolver ref="inter-project"/>
<resolver ref="central"/>
</chain>
</resolvers>
</ivysettings>

View File

@ -1,3 +0,0 @@
object D {
val x = 3
}

View File

@ -1,3 +0,0 @@
-> use/compile
$ copy-file changes/ivysettings.xml use/ivysettings.xml
> use/compile

View File

@ -1,5 +0,0 @@
import junit._
object U {
val x = D.x
}

View File

@ -1,10 +0,0 @@
<ivysettings>
<caches defaultCacheDir="${ivy.settings.dir}/target/use-cache" useOrigin="true"/>
<settings defaultResolver="test-chain"/>
<resolvers>
<ibiblio name="central" m2compatible="true"/>
<chain name="test-chain" returnFirst="true" checkmodified="true">
<resolver ref="central"/>
</chain>
</resolvers>
</ivysettings>

View File

@ -1 +0,0 @@
object A { val x = B.x }

View File

@ -1 +0,0 @@
object B { val x = 3 }

View File

@ -1,7 +0,0 @@
ThisBuild / useCoursier := false
lazy val a = (project in file(".")).
settings(externalIvySettings()) dependsOn(b)
lazy val b = (project in file("b")).
settings(externalIvySettings( Def setting ((baseDirectory in ThisBuild).value / "ivysettings.xml") ))

View File

@ -1,13 +0,0 @@
<ivysettings>
<settings defaultResolver="multi-test-chain"/>
<include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-local.xml"/>
<resolvers>
<chain name="multi-test-chain" returnFirst="true" checkmodified="false">
<resolver ref="inter-project"/>
<resolver ref="local"/>
<resolver ref="public"/>
</chain>
</resolvers>
</ivysettings>

View File

@ -1,5 +1,3 @@
ThisBuild / useCoursier := false
addSbtPlugin("org.example" % "def" % "latest.integration")
resolvers ++= {

View File

@ -1,38 +0,0 @@
ThisBuild / useCoursier := false
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
val checkIvyXml = taskKey[Unit]("Checks the ivy.xml transform was correct")
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
lazy val root = (project in file("."))
.settings(
localCache,
name := "test-parent-pom",
resolvers += MavenCache("Maven2 Local Test", baseDirectory.value / "local-repo"),
libraryDependencies += "com.example" % "example-child" % "1.0-SNAPSHOT",
libraryDependencies += "org.apache.geronimo.specs" % "geronimo-jta_1.1_spec" % "1.1.1",
version := "1.0-SNAPSHOT",
autoScalaLibrary := false,
checkIvyXml := {
val resolverConverter = updateOptions.value.resolverConverter
ivySbt.value.withIvy(streams.value.log) { ivy =>
val cacheDir = ivy.getSettings.getDefaultRepositoryCacheBasedir
val xmlFile =
cacheDir / "org.apache.geronimo.specs" / "geronimo-jta_1.1_spec" / "ivy-1.1.1.xml"
val lines = IO.read(xmlFile)
if(lines.isEmpty) sys.error(s"Unable to read $xmlFile, could not resolve geronimo...")
// Note: We do not do this if the maven plugin is enabled, because there is no rewrite of ivy.xml, extra attributes
// are handled in a different mechanism. This is a hacky mechanism to detect that.
val isMavenResolver = resolverConverter != PartialFunction.empty
if(!isMavenResolver) assert(lines contains "xmlns:e", s"Failed to appropriately modify ivy.xml file for sbt extra attributes!\n$lines")
val xmlFile2 = cacheDir / "com.example" / "example-child" / "ivy-1.0-SNAPSHOT.xml"
val lines2 = IO.read(xmlFile2)
if (!isMavenResolver) {
assert(lines2 contains "Apache-2.0", s"Failed to roll up license from the parent POM!\n$lines2")
}
}
}
)

View File

@ -1,4 +0,0 @@
#NOTE: This is an internal implementation file, its format can be changed without prior notice.
#Tue Dec 16 09:06:35 EST 2014
example-child-1.0-SNAPSHOT.jar>=
example-child-1.0-SNAPSHOT.pom>=

View File

@ -1,16 +0,0 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>example-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.example</groupId>
<artifactId>example-child</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
</project>

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata modelVersion="1.1.0">
<groupId>com.example</groupId>
<artifactId>example-child</artifactId>
<version>1.0-SNAPSHOT</version>
<versioning>
<snapshot>
<localCopy>true</localCopy>
</snapshot>
<lastUpdated>20141216140635</lastUpdated>
<snapshotVersions>
<snapshotVersion>
<extension>jar</extension>
<value>1.0-SNAPSHOT</value>
<updated>20141216140635</updated>
</snapshotVersion>
<snapshotVersion>
<extension>pom</extension>
<value>1.0-SNAPSHOT</value>
<updated>20141216140635</updated>
</snapshotVersion>
</snapshotVersions>
</versioning>
</metadata>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.example</groupId>
<artifactId>example-child</artifactId>
<versioning>
<versions>
<version>1.0-SNAPSHOT</version>
</versions>
<lastUpdated>20141216140635</lastUpdated>
</versioning>
</metadata>

View File

@ -1,3 +0,0 @@
#NOTE: This is an internal implementation file, its format can be changed without prior notice.
#Tue Dec 16 09:01:47 EST 2014
example-parent-1.0-SNAPSHOT.pom>=

View File

@ -1,15 +0,0 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>example-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<licenses>
<license>
<name>Apache-2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
</project>

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata modelVersion="1.1.0">
<groupId>com.example</groupId>
<artifactId>example-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<versioning>
<snapshot>
<localCopy>true</localCopy>
</snapshot>
<lastUpdated>20141216140147</lastUpdated>
<snapshotVersions>
<snapshotVersion>
<extension>pom</extension>
<value>1.0-SNAPSHOT</value>
<updated>20141216140147</updated>
</snapshotVersion>
</snapshotVersions>
</versioning>
</metadata>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.example</groupId>
<artifactId>example-parent</artifactId>
<versioning>
<versions>
<version>1.0-SNAPSHOT</version>
</versions>
<lastUpdated>20141216140147</lastUpdated>
</versioning>
</metadata>

View File

@ -1,2 +0,0 @@
> update
> checkIvyXml

View File

@ -1,5 +1,3 @@
ThisBuild / useCoursier := false
retrieveManaged := true
libraryDependencies += "log4j" % "log4j" % "1.2.16"

View File

@ -3,10 +3,3 @@
> v3 / checkUpdate
> v4 / checkUpdate
> v5 / checkUpdate
> set ThisBuild / useCoursier:=false
> v1 / checkUpdate
> v2 / checkUpdate
> v3 / checkUpdate
> v4 / checkUpdate
> v5 / checkUpdate

View File

@ -2,23 +2,15 @@
> sbtPlugin1 / checkPublish
> testMaven1 / checkUpdate
> set testMaven1 / useCoursier := false
> testMaven1 / checkUpdate
> sbtPlugin1 / publishLocal
> testLocal1 / checkUpdate
> set testLocal1 / useCoursier := false
> testLocal1 / checkUpdate
> sbtPlugin2 / checkPackagedArtifacts
# test publish without legacy artifacts and resolve
> sbtPlugin2 / checkPublish
> testMaven2 / checkUpdate
> set testMaven2 / useCoursier := false
> testMaven2 / checkUpdate
> sbtPlugin2 / publishLocal
> testLocal2 / checkUpdate
> set testLocal2 / useCoursier := false
> testLocal2 / checkUpdate

View File

@ -1,23 +0,0 @@
scalaOrganization := "org.other"
scalaArtifacts += "thing"
ThisBuild / scalaVersion := "2.11.12"
libraryDependencies ++= Seq(
"org.other" % "thing" % "1.2.3",
"org.other" %% "wotsit" % "4.5.6"
)
lazy val check = taskKey[Unit]("Runs the check")
check := {
val lastLog = BuiltinCommands lastLogFile state.value
val last = IO read lastLog.get
def containsWarn1 = last contains "Binary version (1.2.3) for dependency org.other#thing;1.2.3"
def containsWarn2 = last contains "Binary version (4.5.6) for dependency org.other#wotsit_2.11;4.5.6"
def containsWarn3 = last contains "differs from Scala binary version in project (2.11)."
if (!containsWarn1) sys error "thing should not be exempted from the Scala binary version check"
if (containsWarn2) sys error "wotsit should be exempted from the Scala binary version check"
if (!containsWarn3) sys error "Binary version check failed"
}

Some files were not shown because too many files have changed in this diff Show More