Skip to content

Commit fbd099b

Browse files
authored
Merge pull request #72 from xuwei-k/sbt-2-0-0-RC3
sbt 2.0.0-RC3
2 parents e865846 + 743d37f commit fbd099b

File tree

6 files changed

+49
-10
lines changed

6 files changed

+49
-10
lines changed

.github/workflows/build-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
java: 17, 11, 8
2121
scala: 2.12.20
2222
cmd: |
23-
sbt ++$MATRIX_SCALA test ^scripted
23+
sbt ++$MATRIX_SCALA test scripted "++ 3.x" test
2424
2525
finish:
2626
name: Finish

build.sbt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,18 @@ developers += Developer(
1111
url("https://github.com/playframework")
1212
)
1313

14-
addSbtWeb("1.5.8")
14+
addSbtWeb("1.6.0-M1")
15+
16+
crossScalaVersions += "3.7.2"
17+
18+
pluginCrossBuild / sbtVersion := {
19+
scalaBinaryVersion.value match {
20+
case "2.12" =>
21+
sbtVersion.value
22+
case _ =>
23+
"2.0.0-RC3"
24+
}
25+
}
1526

1627
licenses := Seq("MIT" -> url("https://opensource.org/licenses/mit-license.php"))
1728

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.11.3
1+
sbt.version=1.11.5
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package net.ground5hark.sbt.concat
2+
3+
import xsbti.FileConverter
4+
import java.io.File
5+
6+
private[concat] object SbtConcatCompat {
7+
def toFile(f: File)(implicit converter: FileConverter): File = f
8+
def toFileRef(f: File)(implicit converter: FileConverter): File = f
9+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package net.ground5hark.sbt.concat
2+
3+
import java.io.File
4+
import xsbti.FileConverter
5+
import xsbti.VirtualFileRef
6+
import xsbti.HashedVirtualFileRef
7+
8+
private[concat] object SbtConcatCompat {
9+
def toFile(f: VirtualFileRef)(using converter: FileConverter): File =
10+
converter.toPath(f).toFile
11+
def toFileRef(f: File)(using converter: FileConverter): HashedVirtualFileRef =
12+
converter.toVirtualFile(f.toPath)
13+
}

src/main/scala/net/ground5hark/sbt/concat/SbtConcat.scala

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import sbt.Keys._
55
import sbt._
66
import com.typesafe.sbt.web.pipeline.Pipeline
77
import collection.mutable
8-
import mutable.ListBuffer
98
import java.io.File
9+
import xsbti.FileConverter
1010

1111
object 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

Comments
 (0)