Fix duplicate autoplugins packageBin mappings

This commit is contained in:
Anatolii Kmetiuk 2026-05-22 11:24:12 +09:00
parent 5e4d2744a1
commit 99b30b8899
6 changed files with 36 additions and 2 deletions

View File

@ -1772,10 +1772,18 @@ object Defaults extends BuildCommon with DefExtra {
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

View File

@ -0,0 +1,8 @@
ThisBuild / organization := "com.example"
ThisBuild / version := "0.1.0-SNAPSHOT"
val `scalac-options` = project.enablePlugins(SbtPlugin).settings(
addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.4"),
)
val components = project.enablePlugins(SbtPlugin)
val plugins = project.dependsOn(components, `scalac-options`).enablePlugins(SbtPlugin)

View File

@ -0,0 +1,5 @@
package example
import sbt.*
object ComponentsPlugin extends AutoPlugin

View File

@ -0,0 +1,5 @@
package example
import sbt.*
object PluginsPlugin extends AutoPlugin

View File

@ -0,0 +1,5 @@
package example
import sbt.*
object ScalacOptionsPlugin extends AutoPlugin

View File

@ -0,0 +1,3 @@
> scalac-options / Compile / packageBin
> scalac-options / Compile / copyResources
> scalac-options / Compile / packageBin