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 // coursier settings
csrExtraCredentials :== Nil, csrExtraCredentials :== Nil,
csrLogger := LMCoursier.coursierLoggerTask.value, csrLogger := LMCoursier.coursierLoggerTask.value,
csrCachePath :== LMCoursier.defaultCacheLocation, csrCacheDirectory :== LMCoursier.defaultCacheLocation,
csrMavenProfiles :== Set.empty, csrMavenProfiles :== Set.empty,
) )
@ -2160,8 +2160,8 @@ object Classpaths {
}).value, }).value,
moduleName := normalizedName.value, moduleName := normalizedName.value,
ivyPaths := IvyPaths(baseDirectory.value, bootIvyHome(appConfiguration.value)), ivyPaths := IvyPaths(baseDirectory.value, bootIvyHome(appConfiguration.value)),
csrCachePath := { csrCacheDirectory := {
val old = csrCachePath.value val old = csrCacheDirectory.value
val ip = ivyPaths.value val ip = ivyPaths.value
val defaultIvyCache = bootIvyHome(appConfiguration.value) val defaultIvyCache = bootIvyHome(appConfiguration.value)
if (old != LMCoursier.defaultCacheLocation) old 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 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 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) 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 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]("") private[sbt] val csrProject = taskKey[lmcoursier.definitions.Project]("")

View File

@ -15,9 +15,14 @@ import sbt.librarymanagement._
import Keys._ import Keys._
import sbt.internal.librarymanagement.{ CoursierArtifactsTasks, CoursierInputsTasks } import sbt.internal.librarymanagement.{ CoursierArtifactsTasks, CoursierInputsTasks }
import sbt.util.Logger import sbt.util.Logger
import sbt.io.syntax._
private[sbt] object LMCoursier { 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( def coursierConfigurationTask(
withClassifiers: Boolean, withClassifiers: Boolean,
@ -56,7 +61,7 @@ private[sbt] object LMCoursier {
val createLogger = csrLogger.value val createLogger = csrLogger.value
val cache = csrCachePath.value val cache = csrCacheDirectory.value
val internalSbtScalaProvider = appConfiguration.value.provider.scalaProvider val internalSbtScalaProvider = appConfiguration.value.provider.scalaProvider
val sbtBootJars = internalSbtScalaProvider.jars() val sbtBootJars = internalSbtScalaProvider.jars()