make Coursier cache directory configurable

This commit is contained in:
Eugene Yokota 2019-05-11 01:11:07 -04:00
parent 9137e21028
commit 7433f1f4ed
3 changed files with 11 additions and 6 deletions

View File

@ -243,7 +243,7 @@ object Defaults extends BuildCommon {
// coursier settings
csrExtraCredentials :== Nil,
csrLogger := LMCoursier.coursierLoggerTask.value,
csrCachePath :== LMCoursier.defaultCacheLocation,
csrCacheDirectory :== LMCoursier.defaultCacheLocation,
csrMavenProfiles :== Set.empty,
)
@ -2160,8 +2160,8 @@ object Classpaths {
}).value,
moduleName := normalizedName.value,
ivyPaths := IvyPaths(baseDirectory.value, bootIvyHome(appConfiguration.value)),
csrCachePath := {
val old = csrCachePath.value
csrCacheDirectory := {
val old = csrCacheDirectory.value
val ip = ivyPaths.value
val defaultIvyCache = bootIvyHome(appConfiguration.value)
if (old != LMCoursier.defaultCacheLocation) old

View File

@ -324,7 +324,7 @@ object Keys {
val internalDependencyConfigurations = settingKey[Seq[(ProjectRef, Set[String])]]("The project configurations that this configuration depends on")
val useCoursier = settingKey[Boolean]("Use Coursier for dependency resolution.").withRank(BSetting)
val csrCachePath = settingKey[File]("Coursier cache path").withRank(CSetting)
val csrCacheDirectory = settingKey[File]("Coursier cache directory. Uses -Dsbt.coursier.home or Coursier's default.").withRank(CSetting)
val csrMavenProfiles = settingKey[Set[String]]("").withRank(CSetting)
private[sbt] val csrConfiguration = taskKey[CoursierConfiguration]("General dependency management (Coursier) settings, such as the resolvers and options to use.").withRank(DTask)
private[sbt] val csrProject = taskKey[lmcoursier.definitions.Project]("")

View File

@ -15,9 +15,14 @@ import sbt.librarymanagement._
import Keys._
import sbt.internal.librarymanagement.{ CoursierArtifactsTasks, CoursierInputsTasks }
import sbt.util.Logger
import sbt.io.syntax._
private[sbt] object LMCoursier {
def defaultCacheLocation: File = CoursierDependencyResolution.defaultCacheLocation
def defaultCacheLocation: File =
sys.props.get("sbt.coursier.home") match {
case Some(home) => new File(home).getAbsoluteFile / "cache"
case _ => CoursierDependencyResolution.defaultCacheLocation
}
def coursierConfigurationTask(
withClassifiers: Boolean,
@ -56,7 +61,7 @@ private[sbt] object LMCoursier {
val createLogger = csrLogger.value
val cache = csrCachePath.value
val cache = csrCacheDirectory.value
val internalSbtScalaProvider = appConfiguration.value.provider.scalaProvider
val sbtBootJars = internalSbtScalaProvider.jars()