Skip to content

Commit

Permalink
Leverage crossTarget to create cacheBaseDirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
RustedBones committed Oct 17, 2024
1 parent b998e80 commit 2bd3dcb
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/scala/com/github/sbt/avro/SbtAvro.scala
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ object SbtAvro extends AutoPlugin {
Seq(Compile, Test).flatMap(c => inConfig(c)(configScopedSettings))

private def unpack(
scala: String,
cacheBaseDirectory: File,
deps: Seq[File],
extractTarget: File,
includeFilter: FileFilter,
Expand All @@ -134,7 +134,7 @@ object SbtAvro extends AutoPlugin {
): Seq[File] = {
def cachedExtractDep(jar: File): Seq[File] = {
val cached = FileFunction.cached(
streams.cacheDirectory / scala / jar.name,
cacheBaseDirectory / jar.name,
inStyle = FilesInfo.lastModified,
outStyle = FilesInfo.exists
) { deps =>
Expand All @@ -160,7 +160,13 @@ object SbtAvro extends AutoPlugin {
}

private def unpackDependenciesTask(key: TaskKey[Seq[File]]) = Def.task {
val scala = scalaVersion.value
val cacheBaseDirectory = Defaults.makeCrossTarget(
streams.value.cacheDirectory,
scalaBinaryVersion.value,
(pluginCrossBuild / sbtBinaryVersion).value,
sbtPlugin.value,
crossPaths.value
)
val conf = configuration.value.toConfigRef
val avroArtifacts = update
.value
Expand All @@ -169,7 +175,7 @@ object SbtAvro extends AutoPlugin {
.collect { case (`conf`, _, _, file) => file }

unpack(
scala = scala,
cacheBaseDirectory = cacheBaseDirectory,
deps = avroArtifacts,
extractTarget = (key / target).value,
includeFilter = (key / includeFilter).value,
Expand Down

0 comments on commit 2bd3dcb

Please sign in to comment.