The sbt-reproducible-build fails if  two artifacts point to the same file.

When packaging the artifacts of an sbt plugin,
we copy each files to avoid this issue.
This commit is contained in:
Adrien Piquerez 2023-05-04 10:46:21 +02:00
parent 26917d7de4
commit bb0bb5ce58
1 changed files with 8 additions and 1 deletions

View File

@ -2857,7 +2857,14 @@ object Classpaths {
val legacyPackages = packaged(defaultPackages).value
def addSuffix(a: Artifact): Artifact = a.withName(crossVersion(a.name))
val packages = legacyPackages.map { case (artifact, file) => addSuffix(artifact) -> file }
def copyArtifact(artifact: Artifact, file: File): (Artifact, File) = {
val nameWithSuffix = crossVersion(artifact.name)
val targetFile =
new File(file.getParentFile, file.name.replace(artifact.name, nameWithSuffix))
IO.copyFile(file, targetFile)
artifact.withName(nameWithSuffix) -> targetFile
}
val packages = legacyPackages.map { case (artifact, file) => copyArtifact(artifact, file) }
val legacyPackagedArtifacts = Def
.ifS(sbtPluginPublishLegacyMavenStyle.toTask)(packaged(defaultArtifactTasks))(
Def.task(Map.empty[Artifact, File])