diff --git a/main-actions/src/main/scala/sbt/Mapper.scala b/main-actions/src/main/scala/sbt/Mapper.scala index 01efce99e..bb43a6301 100644 --- a/main-actions/src/main/scala/sbt/Mapper.scala +++ b/main-actions/src/main/scala/sbt/Mapper.scala @@ -2,6 +2,7 @@ package sbt import sbt.io.{ AllPassFilter, FileFilter, PathFinder } import sbt.io.Path.* +import xsbti.{ FileConverter, VirtualFile } import java.io.File @@ -11,16 +12,19 @@ object Mapper { * Selects all descendants of `base` directory and maps them to a path relative to `base`. * `base` itself is not included. */ - def allSubpaths(base: File): Seq[(File, String)] = + def allSubpaths(base: File)(implicit conv: FileConverter): Seq[(VirtualFile, String)] = selectSubpaths(base, AllPassFilter) /** * Selects descendants of `base` directory matching `filter` and maps them to a path relative to `base`. * `base` itself is not included. */ - def selectSubpaths(base: File, filter: FileFilter): Seq[(File, String)] = + def selectSubpaths(base: File, filter: FileFilter)(implicit + conv: FileConverter + ): Seq[(VirtualFile, String)] = PathFinder(base).globRecursive(filter).get().collect { - case f if f != base => f -> base.toPath.relativize(f.toPath).toString + case f if f != base => + conv.toVirtualFile(f.toPath) -> base.toPath.relativize(f.toPath).toString } /** @@ -43,10 +47,11 @@ object Mapper { * @param baseDirectory The directory that should be turned into a mappings sequence. * @return mappings The `baseDirectory` and all of its contents */ - def directory(baseDirectory: File): Seq[(File, String)] = + def directory(baseDirectory: File)(implicit conv: FileConverter): Seq[(VirtualFile, String)] = Option(baseDirectory.getParentFile) .map(parent => PathFinder(baseDirectory).allPaths pair relativeTo(parent)) .getOrElse(PathFinder(baseDirectory).allPaths pair basic) + .map { case (f, s) => conv.toVirtualFile(f.toPath) -> s } /** * return a Seq of mappings excluding the directory itself. diff --git a/sbt-app/src/sbt-test/package/mappings-directory/build.sbt b/sbt-app/src/sbt-test/package/mappings-directory/build.sbt index ba90f90a7..7e6a058a3 100644 --- a/sbt-app/src/sbt-test/package/mappings-directory/build.sbt +++ b/sbt-app/src/sbt-test/package/mappings-directory/build.sbt @@ -5,7 +5,7 @@ version := "0.2" Compile / packageBin / mappings ++= { val converter = fileConverter.value - Path.directory(file("test")).map { case (f,s) => converter.toVirtualFile(f.toPath) -> s } + Mapper.directory(file("test"))(using converter) } lazy val unzipPackage = taskKey[Unit]("extract jar file")