@@ -5,10 +5,11 @@ import sbt.Keys._
55import sbt ._
66import com .typesafe .sbt .web .pipeline .Pipeline
77import collection .mutable
8- import mutable .ListBuffer
98import java .io .File
9+ import xsbti .FileConverter
1010
1111object Import {
12+ @ transient
1213 val concat = TaskKey [Pipeline .Stage ](" web-concat" , " Concatenates groups of web assets" )
1314
1415 object Concat {
@@ -41,7 +42,7 @@ object SbtConcat extends AutoPlugin {
4142 import Concat ._
4243
4344 override def projectSettings = Seq (
44- groups := ListBuffer .empty[ ConcatGroup ] ,
45+ groups := Nil ,
4546 concat / includeFilter := NotHiddenFileFilter ,
4647 parentDir := " " ,
4748 concat := concatFiles.value
@@ -56,13 +57,12 @@ object SbtConcat extends AutoPlugin {
5657 case Right (fileNamesPathFinder) =>
5758 val r = fileNamesPathFinder.pair(Path .relativeTo(srcDirs ++ webModuleDirs) | Path .flat)
5859 (groupName, r.map(_._2))
59- case u => sys.error(s " Expected Seq[String] or PathFinder, but got $u" )
6060 }
6161 }
6262
6363 private def concatFiles : Def .Initialize [Task [Pipeline .Stage ]] = Def .task {
6464 val logValue = streams.value.log
65- mappings : Seq [PathMapping ] =>
65+ ( mappings : Seq [PathMapping ]) =>
6666 val groupsValue = toFileNames(groups.value,
6767 (Assets / sourceDirectories).value,
6868 (Assets / webModuleDirectories).value)
@@ -72,7 +72,11 @@ object SbtConcat extends AutoPlugin {
7272 // Mutable map so we can pop entries we've already seen, in case there are similarly named files
7373 val reverseMapping = ReverseGroupMapping .get(groupsValue, logValue)
7474 val concatGroups = mutable.Map .empty[String , StringBuilder ]
75- val filteredMappings = mappings.filter(m => (concat / includeFilter).value.accept(m._1) && m._1.isFile)
75+ implicit val converter : FileConverter = fileConverter.value
76+ val filteredMappings = mappings.filter{ m =>
77+ val f = SbtConcatCompat .toFile(m._1)
78+ (concat / includeFilter).value.accept(f) && f.isFile
79+ }
7680 val targetDir = webTarget.value / parentDir.value
7781
7882 groupsValue.foreach {
@@ -85,7 +89,7 @@ object SbtConcat extends AutoPlugin {
8589 // TODO This is not as memory efficient as it could be, write to file instead
8690 concatGroups.getOrElseUpdate(groupName, new StringBuilder )
8791 .append(s " \n /** $fileName **/ \n " )
88- .append(IO .read(mapping.head._1))
92+ .append(IO .read(SbtConcatCompat .toFile( mapping.head._1) ))
8993 reverseMapping.remove(fileName)
9094 } else logValue.warn(s " Unable to process $fileName. Not found. " )
9195 }
@@ -96,7 +100,9 @@ object SbtConcat extends AutoPlugin {
96100 val outputFile = targetDir / groupName
97101 IO .write(outputFile, concatenatedContents.toString())
98102 outputFile
99- }.pair(Path .relativeTo(webTarget.value))
103+ }.pair(Path .relativeTo(webTarget.value)).map {
104+ case (x1, x2) => (SbtConcatCompat .toFileRef(x1), x2)
105+ }
100106 } else {
101107 Seq .empty[PathMapping ]
102108 }
0 commit comments