mirror of https://github.com/sbt/sbt.git
[2.0.x] Fix duplicate autoplugins packageBin mappings (#9255)
Deduplicate executable jar package entries. In the issue, the duplicate was something like: (resource_managed/.../sbt/sbt.autoplugins, "sbt/sbt.autoplugins") (classes/.../sbt/sbt.autoplugins, "sbt/sbt.autoplugins") This is because copyResources copied autoplugin metadata to the classes directory. Solution: when composing the packageBinMappings, differentiate between artifacts that come from class directory and from outside of it. If there is a duplicate, prefer resource that comes from outside of it.
This commit is contained in:
parent
8ff4a8ecba
commit
d53a50ac24
|
|
@ -1722,10 +1722,18 @@ object Defaults extends BuildCommon {
|
|||
def packageBinMappings: Initialize[Task[Seq[(HashedVirtualFileRef, String)]]] =
|
||||
Def.task {
|
||||
val converter = fileConverter.value
|
||||
val classDirPath = classDirectory.value.toPath.toAbsolutePath.normalize
|
||||
val xs = products.value
|
||||
xs
|
||||
val allMappings = xs
|
||||
.flatMap(Path.allSubpaths)
|
||||
.withFilter(_._1.isFile())
|
||||
.filter(_._1.isFile())
|
||||
val resourcePaths = allMappings.collect {
|
||||
case (p, path) if !p.toPath.toAbsolutePath.normalize.startsWith(classDirPath) => path
|
||||
}.toSet
|
||||
allMappings
|
||||
.filterNot { (p, path) =>
|
||||
resourcePaths(path) && p.toPath.toAbsolutePath.normalize.startsWith(classDirPath)
|
||||
}
|
||||
.map { (p, path) =>
|
||||
val vf = converter.toVirtualFile(p.toPath())
|
||||
(vf: HashedVirtualFileRef) -> path
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
ThisBuild / organization := "com.example"
|
||||
ThisBuild / version := "0.1.0-SNAPSHOT"
|
||||
|
||||
val `scalac-options` = project.enablePlugins(SbtPlugin)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package example
|
||||
|
||||
import sbt.*
|
||||
|
||||
object ScalacOptionsPlugin extends AutoPlugin
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
> scalac-options / Compile / packageBin
|
||||
> scalac-options / Compile / copyResources
|
||||
> scalac-options / Compile / packageBin
|
||||
Loading…
Reference in New Issue