mirror of https://github.com/sbt/sbt.git
[2.x] feat: Add csrLocalArtifactsShouldBeCached setting for caching local artifacts (#8504)
This adds a new setting that allows users to configure Coursier's FileCache to cache local file:// artifacts. When enabled, artifacts from local repositories are copied to the cache directory, which is useful for scenarios like bundling compiler artifacts in a local repo for offline use. Fixes #7547
This commit is contained in:
parent
56c86a1684
commit
81b6408f49
|
|
@ -717,6 +717,7 @@ lazy val mainProj = (project in file("main"))
|
||||||
mimaSettings,
|
mimaSettings,
|
||||||
mimaBinaryIssueFilters ++= Vector(
|
mimaBinaryIssueFilters ++= Vector(
|
||||||
exclude[DirectMissingMethodProblem]("sbt.internal.ConsoleProject.*"),
|
exclude[DirectMissingMethodProblem]("sbt.internal.ConsoleProject.*"),
|
||||||
|
exclude[DirectMissingMethodProblem]("sbt.coursierint.LMCoursier.coursierConfiguration"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.dependsOn(lmCore, lmIvy, lmCoursierShadedPublishing)
|
.dependsOn(lmCore, lmIvy, lmCoursierShadedPublishing)
|
||||||
|
|
|
||||||
|
|
@ -69,4 +69,6 @@ import scala.concurrent.duration.{ Duration, FiniteDuration }
|
||||||
protocolHandlerDependencies: Seq[ModuleID] = Vector.empty,
|
protocolHandlerDependencies: Seq[ModuleID] = Vector.empty,
|
||||||
retry: Option[(FiniteDuration, Int)] = None,
|
retry: Option[(FiniteDuration, Int)] = None,
|
||||||
sameVersions: Seq[Set[InclExclRule]] = Nil,
|
sameVersions: Seq[Set[InclExclRule]] = Nil,
|
||||||
|
@since
|
||||||
|
localArtifactsShouldBeCached: Boolean = false,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -240,6 +240,7 @@ class CoursierDependencyResolution(
|
||||||
.withChecksums(checksums)
|
.withChecksums(checksums)
|
||||||
.withCredentials(conf.credentials.map(ToCoursier.credentials))
|
.withCredentials(conf.credentials.map(ToCoursier.credentials))
|
||||||
.withFollowHttpToHttpsRedirections(conf.followHttpToHttpsRedirections.getOrElse(true))
|
.withFollowHttpToHttpsRedirections(conf.followHttpToHttpsRedirections.getOrElse(true))
|
||||||
|
.withLocalArtifactsShouldBeCached(conf.localArtifactsShouldBeCached)
|
||||||
|
|
||||||
val excludeDependencies = conf.excludeDependencies.map { (strOrg, strName) =>
|
val excludeDependencies = conf.excludeDependencies.map { (strOrg, strName) =>
|
||||||
(coursier.Organization(strOrg), coursier.ModuleName(strName))
|
(coursier.Organization(strOrg), coursier.ModuleName(strName))
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ package object syntax {
|
||||||
protocolHandlerDependencies = Vector.empty,
|
protocolHandlerDependencies = Vector.empty,
|
||||||
retry = None,
|
retry = None,
|
||||||
sameVersions = Nil,
|
sameVersions = Nil,
|
||||||
|
localArtifactsShouldBeCached = false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -287,6 +287,7 @@ object Defaults extends BuildCommon {
|
||||||
csrMavenProfiles :== Set.empty,
|
csrMavenProfiles :== Set.empty,
|
||||||
csrReconciliations :== LMCoursier.relaxedForAllModules,
|
csrReconciliations :== LMCoursier.relaxedForAllModules,
|
||||||
csrMavenDependencyOverride :== false,
|
csrMavenDependencyOverride :== false,
|
||||||
|
csrLocalArtifactsShouldBeCached :== false,
|
||||||
csrCacheDirectory := LMCoursier.defaultCacheLocation,
|
csrCacheDirectory := LMCoursier.defaultCacheLocation,
|
||||||
csrSameVersions :== Nil,
|
csrSameVersions :== Nil,
|
||||||
stagingDirectory := (ThisBuild / baseDirectory).value / "target" / "sona-staging",
|
stagingDirectory := (ThisBuild / baseDirectory).value / "target" / "sona-staging",
|
||||||
|
|
|
||||||
|
|
@ -494,6 +494,8 @@ object Keys {
|
||||||
val csrReconciliations = settingKey[Seq[(ModuleMatchers, Reconciliation)]]("Strategy to reconcile version conflicts.")
|
val csrReconciliations = settingKey[Seq[(ModuleMatchers, Reconciliation)]]("Strategy to reconcile version conflicts.")
|
||||||
val csrSameVersions = settingKey[Seq[Set[InclExclRule]]]("Modules to keep at the same version.")
|
val csrSameVersions = settingKey[Seq[Set[InclExclRule]]]("Modules to keep at the same version.")
|
||||||
val csrMavenDependencyOverride = settingKey[Boolean]("Enables Maven dependency override (bill of materials) support")
|
val csrMavenDependencyOverride = settingKey[Boolean]("Enables Maven dependency override (bill of materials) support")
|
||||||
|
val csrLocalArtifactsShouldBeCached =
|
||||||
|
settingKey[Boolean]("When true, local file:// artifacts are copied to the cache directory.")
|
||||||
|
|
||||||
val internalConfigurationMap = settingKey[Configuration => Configuration]("Maps configurations to the actual configuration used to define the classpath.").withRank(CSetting)
|
val internalConfigurationMap = settingKey[Configuration => Configuration]("Maps configurations to the actual configuration used to define the classpath.").withRank(CSetting)
|
||||||
val classpathConfiguration = taskKey[Configuration]("The configuration used to define the classpath.").withRank(CTask)
|
val classpathConfiguration = taskKey[Configuration]("The configuration used to define the classpath.").withRank(CTask)
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,7 @@ object LMCoursier {
|
||||||
updateConfig: Option[UpdateConfiguration],
|
updateConfig: Option[UpdateConfiguration],
|
||||||
sameVersions: Seq[Set[InclExclRule]],
|
sameVersions: Seq[Set[InclExclRule]],
|
||||||
enableDependencyOverrides: Option[Boolean],
|
enableDependencyOverrides: Option[Boolean],
|
||||||
|
localArtifactsShouldBeCached: Boolean,
|
||||||
log: Logger
|
log: Logger
|
||||||
): CoursierConfiguration = {
|
): CoursierConfiguration = {
|
||||||
val coursierExcludeDeps = Inputs
|
val coursierExcludeDeps = Inputs
|
||||||
|
|
@ -143,7 +144,7 @@ object LMCoursier {
|
||||||
.withForceVersions(userForceVersions.toVector)
|
.withForceVersions(userForceVersions.toVector)
|
||||||
.withMissingOk(missingOk)
|
.withMissingOk(missingOk)
|
||||||
.withSameVersions(sameVersions)
|
.withSameVersions(sameVersions)
|
||||||
// .withEnableDependencyOverrides(enableDependencyOverrides)
|
.withLocalArtifactsShouldBeCached(localArtifactsShouldBeCached)
|
||||||
}
|
}
|
||||||
|
|
||||||
def coursierConfigurationTask: Def.Initialize[Task[CoursierConfiguration]] = Def.task {
|
def coursierConfigurationTask: Def.Initialize[Task[CoursierConfiguration]] = Def.task {
|
||||||
|
|
@ -171,6 +172,7 @@ object LMCoursier {
|
||||||
Some(updateConfiguration.value),
|
Some(updateConfiguration.value),
|
||||||
csrSameVersions.value,
|
csrSameVersions.value,
|
||||||
Some(csrMavenDependencyOverride.value),
|
Some(csrMavenDependencyOverride.value),
|
||||||
|
csrLocalArtifactsShouldBeCached.value,
|
||||||
streams.value.log
|
streams.value.log
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -207,6 +209,7 @@ object LMCoursier {
|
||||||
Some(updateConfiguration.value),
|
Some(updateConfiguration.value),
|
||||||
csrSameVersions.value,
|
csrSameVersions.value,
|
||||||
Some(csrMavenDependencyOverride.value),
|
Some(csrMavenDependencyOverride.value),
|
||||||
|
csrLocalArtifactsShouldBeCached.value,
|
||||||
streams.value.log
|
streams.value.log
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -236,6 +239,7 @@ object LMCoursier {
|
||||||
Some(updateConfiguration.value),
|
Some(updateConfiguration.value),
|
||||||
csrSameVersions.value,
|
csrSameVersions.value,
|
||||||
Some(csrMavenDependencyOverride.value),
|
Some(csrMavenDependencyOverride.value),
|
||||||
|
csrLocalArtifactsShouldBeCached.value,
|
||||||
streams.value.log
|
streams.value.log
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
ThisBuild / scalaVersion := "2.13.16"
|
||||||
|
|
||||||
|
lazy val root = (project in file("."))
|
||||||
|
.settings(
|
||||||
|
name := "local-artifacts-cache-test",
|
||||||
|
csrLocalArtifactsShouldBeCached := true,
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
> show csrLocalArtifactsShouldBeCached
|
||||||
Loading…
Reference in New Issue