mirror of https://github.com/sbt/sbt.git
Take ivyPaths into account
This commit is contained in:
parent
87f812d6f3
commit
5436809323
|
|
@ -32,7 +32,8 @@ final class CoursierConfiguration private (
|
|||
val authenticationByRepositoryId: Vector[(String, Authentication)],
|
||||
val credentials: Seq[Credentials],
|
||||
val logger: Option[CacheLogger],
|
||||
val cache: Option[File]
|
||||
val cache: Option[File],
|
||||
val ivyHome: Option[File]
|
||||
) extends Serializable {
|
||||
|
||||
private def this() =
|
||||
|
|
@ -56,6 +57,7 @@ final class CoursierConfiguration private (
|
|||
Vector.empty,
|
||||
Vector.empty,
|
||||
None,
|
||||
None,
|
||||
None
|
||||
)
|
||||
|
||||
|
|
@ -81,7 +83,8 @@ final class CoursierConfiguration private (
|
|||
authenticationByRepositoryId == other.authenticationByRepositoryId &&
|
||||
credentials == other.credentials &&
|
||||
logger == other.logger &&
|
||||
cache == other.cache
|
||||
cache == other.cache &&
|
||||
ivyHome == other.ivyHome
|
||||
case _ => false
|
||||
}
|
||||
|
||||
|
|
@ -107,11 +110,12 @@ final class CoursierConfiguration private (
|
|||
code = 37 * (code + credentials.##)
|
||||
code = 37 * (code + logger.##)
|
||||
code = 37 * (code + cache.##)
|
||||
code = 37 * (code + ivyHome.##)
|
||||
code
|
||||
}
|
||||
|
||||
override def toString: String =
|
||||
s"CoursierConfiguration($log, $resolvers, $parallelDownloads, $maxIterations, $sbtScalaOrganization, $sbtScalaVersion, $sbtScalaJars, $interProjectDependencies, $excludeDependencies, $fallbackDependencies, $autoScalaLibrary, $hasClassifiers, $classifiers, $mavenProfiles, $scalaOrganization, $scalaVersion, $authenticationByRepositoryId, $credentials, $logger, $cache)"
|
||||
s"CoursierConfiguration($log, $resolvers, $parallelDownloads, $maxIterations, $sbtScalaOrganization, $sbtScalaVersion, $sbtScalaJars, $interProjectDependencies, $excludeDependencies, $fallbackDependencies, $autoScalaLibrary, $hasClassifiers, $classifiers, $mavenProfiles, $scalaOrganization, $scalaVersion, $authenticationByRepositoryId, $credentials, $logger, $cache, $ivyHome)"
|
||||
|
||||
private[this] def copy(
|
||||
log: Option[Logger] = log,
|
||||
|
|
@ -133,7 +137,8 @@ final class CoursierConfiguration private (
|
|||
authenticationByRepositoryId: Vector[(String, Authentication)] = authenticationByRepositoryId,
|
||||
credentials: Seq[Credentials] = credentials,
|
||||
logger: Option[CacheLogger] = logger,
|
||||
cache: Option[File] = cache
|
||||
cache: Option[File] = cache,
|
||||
ivyHome: Option[File] = ivyHome
|
||||
): CoursierConfiguration =
|
||||
new CoursierConfiguration(
|
||||
log,
|
||||
|
|
@ -155,7 +160,8 @@ final class CoursierConfiguration private (
|
|||
authenticationByRepositoryId,
|
||||
credentials,
|
||||
logger,
|
||||
cache
|
||||
cache,
|
||||
ivyHome
|
||||
)
|
||||
|
||||
def withLog(log: Option[Logger]): CoursierConfiguration =
|
||||
|
|
@ -238,6 +244,11 @@ final class CoursierConfiguration private (
|
|||
|
||||
def withCache(cache: File): CoursierConfiguration =
|
||||
copy(cache = Option(cache))
|
||||
|
||||
def withIvyHome(ivyHomeOpt: Option[File]): CoursierConfiguration =
|
||||
copy(ivyHome = ivyHomeOpt)
|
||||
def withIvyHome(ivyHome: File): CoursierConfiguration =
|
||||
copy(ivyHome = Option(ivyHome))
|
||||
}
|
||||
|
||||
object CoursierConfiguration {
|
||||
|
|
@ -287,7 +298,8 @@ object CoursierConfiguration {
|
|||
authenticationByRepositoryId,
|
||||
credentials,
|
||||
logger,
|
||||
cache
|
||||
cache,
|
||||
None
|
||||
)
|
||||
|
||||
def apply(
|
||||
|
|
@ -332,6 +344,54 @@ object CoursierConfiguration {
|
|||
authenticationByRepositoryId,
|
||||
credentials,
|
||||
Option(logger),
|
||||
Option(cache)
|
||||
Option(cache),
|
||||
None
|
||||
)
|
||||
|
||||
def apply(
|
||||
log: Option[Logger],
|
||||
resolvers: Vector[Resolver],
|
||||
parallelDownloads: Int,
|
||||
maxIterations: Int,
|
||||
sbtScalaOrganization: Option[String],
|
||||
sbtScalaVersion: Option[String],
|
||||
sbtScalaJars: Vector[File],
|
||||
interProjectDependencies: Vector[Project],
|
||||
excludeDependencies: Vector[(String, String)],
|
||||
fallbackDependencies: Vector[FallbackDependency],
|
||||
autoScalaLibrary: Boolean,
|
||||
hasClassifiers: Boolean,
|
||||
classifiers: Vector[String],
|
||||
mavenProfiles: Vector[String],
|
||||
scalaOrganization: Option[String],
|
||||
scalaVersion: Option[String],
|
||||
authenticationByRepositoryId: Vector[(String, Authentication)],
|
||||
credentials: Seq[Credentials],
|
||||
logger: Option[CacheLogger],
|
||||
cache: Option[File],
|
||||
ivyHome: Option[File]
|
||||
): CoursierConfiguration =
|
||||
new CoursierConfiguration(
|
||||
log,
|
||||
resolvers,
|
||||
parallelDownloads,
|
||||
maxIterations,
|
||||
sbtScalaOrganization,
|
||||
sbtScalaVersion,
|
||||
sbtScalaJars,
|
||||
interProjectDependencies,
|
||||
excludeDependencies,
|
||||
fallbackDependencies,
|
||||
autoScalaLibrary,
|
||||
hasClassifiers,
|
||||
classifiers,
|
||||
mavenProfiles,
|
||||
scalaOrganization,
|
||||
scalaVersion,
|
||||
authenticationByRepositoryId,
|
||||
credentials,
|
||||
logger,
|
||||
cache,
|
||||
ivyHome
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
val checksums = CacheDefaults.checksums
|
||||
val projectName = "" // used for logging only…
|
||||
|
||||
val ivyProperties = ResolutionParams.defaultIvyProperties()
|
||||
val ivyProperties = ResolutionParams.defaultIvyProperties(conf.ivyHome)
|
||||
|
||||
val classifiers =
|
||||
if (conf.hasClassifiers)
|
||||
|
|
|
|||
|
|
@ -84,12 +84,12 @@ object ResolutionParams {
|
|||
private def cacheKey(cache: FileCache[Task]): Object =
|
||||
m.invoke(cache)
|
||||
|
||||
def defaultIvyProperties(): Map[String, String] = {
|
||||
def defaultIvyProperties(ivyHomeOpt: Option[File]): Map[String, String] = {
|
||||
|
||||
val ivyHome = sys.props.getOrElse(
|
||||
"ivy.home",
|
||||
new File(sys.props("user.home")).toURI.getPath + ".ivy2"
|
||||
)
|
||||
val ivyHome = sys.props
|
||||
.get("ivy.home")
|
||||
.orElse(ivyHomeOpt.map(_.getAbsoluteFile.toURI.getPath))
|
||||
.getOrElse(new File(sys.props("user.home")).toURI.getPath + ".ivy2")
|
||||
|
||||
val sbtIvyHome = sys.props.getOrElse(
|
||||
"sbt.ivy.home",
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ object ResolutionTasks {
|
|||
|
||||
val interProjectRepo = InterProjectRepository(interProjectDependencies)
|
||||
|
||||
val ivyProperties = ResolutionParams.defaultIvyProperties()
|
||||
val ivyProperties = ResolutionParams.defaultIvyProperties(ivyPaths.value.ivyHome)
|
||||
|
||||
val authenticationByRepositoryId = coursierCredentials.value.mapValues(_.authentication)
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ check := {
|
|||
sbtResolvers.flatMap{ sbtResolver: sbt.librarymanagement.Resolver =>
|
||||
lmcoursier.internal.Resolvers.repository(
|
||||
resolver = sbtResolver,
|
||||
ivyProperties = lmcoursier.internal.ResolutionParams.defaultIvyProperties(),
|
||||
ivyProperties = lmcoursier.internal.ResolutionParams.defaultIvyProperties(
|
||||
ivyPaths.value.ivyHome
|
||||
),
|
||||
log = s.log,
|
||||
authentication = None,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Imported from https://github.com/sbt/sbt/tree/f5edeec2fdabd4313d2976b389bb6101775a5554/sbt/src/sbt-test/dependency-management/cache-local
|
||||
|
|
@ -0,0 +1 @@
|
|||
ivyPaths := { IvyPaths(baseDirectory.value, Some(target.value / ".ivy2")) }
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
organization := "org.example"
|
||||
|
||||
name := "def"
|
||||
|
||||
version := "1.0"
|
||||
|
||||
autoScalaLibrary := false
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
publishTo := baseDirectory(base => Some(Resolver.file("filesys-publish", base / "repo")) ).value
|
||||
|
||||
resolvers += baseDirectory(base => "filesys" at (base / "repo").toURI.toString).value
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
organization := "org.example"
|
||||
|
||||
name := "use"
|
||||
|
||||
version := "1.0"
|
||||
|
||||
autoScalaLibrary := false
|
||||
|
||||
libraryDependencies += "org.example" %% "def" % "1.0"
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
addSbtPlugin {
|
||||
|
||||
val name = sys.props.getOrElse(
|
||||
"plugin.name",
|
||||
sys.error("plugin.name Java property not set")
|
||||
)
|
||||
val version = sys.props.getOrElse(
|
||||
"plugin.version",
|
||||
sys.error("plugin.version Java property not set")
|
||||
)
|
||||
|
||||
"io.get-coursier" % name % version
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
$ copy-file changes/def.sbt build.sbt
|
||||
$ copy-file changes/resolver.sbt resolver.sbt
|
||||
> reload
|
||||
> publishLocal
|
||||
> publish
|
||||
|
||||
$ delete build.sbt
|
||||
$ delete resolver.sbt
|
||||
$ copy-file changes/use.sbt build.sbt
|
||||
> reload
|
||||
> update
|
||||
> update
|
||||
|
||||
# needed for sbt-coursier (clear in-memory cache)
|
||||
> clean
|
||||
$ delete target/.ivy2/local
|
||||
-> update
|
||||
|
||||
$ copy-file changes/resolver.sbt resolver.sbt
|
||||
> reload
|
||||
> update
|
||||
|
|
@ -7,7 +7,7 @@ import coursier.sbtcoursiershared.{InputsTasks, SbtCoursierShared}
|
|||
import sbt.{AutoPlugin, Classpaths, Def, Setting, Task, taskKey}
|
||||
import sbt.Project.inTask
|
||||
import sbt.KeyRanks.DTask
|
||||
import sbt.Keys.{appConfiguration, autoScalaLibrary, classpathTypes, dependencyResolution, scalaBinaryVersion, scalaModuleInfo, scalaOrganization, scalaVersion, streams, updateClassifiers, updateSbtClassifiers}
|
||||
import sbt.Keys.{appConfiguration, autoScalaLibrary, classpathTypes, dependencyResolution, ivyPaths, scalaBinaryVersion, scalaModuleInfo, scalaOrganization, scalaVersion, streams, updateClassifiers, updateSbtClassifiers}
|
||||
import sbt.librarymanagement.DependencyResolution
|
||||
|
||||
import scala.language.reflectiveCalls
|
||||
|
|
@ -133,6 +133,7 @@ object LmCoursierPlugin extends AutoPlugin {
|
|||
.withLogger(createLogger)
|
||||
.withCache(cache)
|
||||
.withLog(s.log)
|
||||
.withIvyHome(ivyPaths.value.ivyHome)
|
||||
}
|
||||
}
|
||||
private def mkDependencyResolution: Def.Initialize[Task[DependencyResolution]] =
|
||||
|
|
|
|||
Loading…
Reference in New Issue