mirror of
https://github.com/sbt/sbt.git
synced 2026-09-07 02:55:23 +02:00
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. Co-authored-by: Anatolii Kmetiuk <[email protected]>
This commit is contained in:
co-authored by
Anatolii Kmetiuk
parent
8ff4a8ecba
commit
e6666e4b10
@@ -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)
|
||||
+5
@@ -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
|
||||
Reference in New Issue
Block a user