Skip to content

Commit d8b0336

Browse files
authored
Update scrooge support to be compatible with Scala 3 (#1350)
1 parent 3b9c834 commit d8b0336

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/scala/io/bazel/rules_scala/scrooge_support/Compiler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class Compiler(val config: ScroogeConfig) {
7171
var fileMapWriter: scala.Option[FileWriter] = None
7272

7373

74-
def run() {
74+
def run(): Unit = {
7575
// if --gen-file-map is specified, prepare the map file.
7676
fileMapWriter = config.fileMapPath.map { path =>
7777
val file = new File(path)

src/scala/io/bazel/rules_scala/scrooge_support/FocusedZipImporter.scala

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package io.bazel.rules_scala.scrooge_support
22

3-
import com.twitter.scrooge.frontend.{ FileContents, Importer }
3+
import com.twitter.scrooge.frontend.{FileContents, Importer}
44

55
import java.io.File
6-
import java.util.zip.{ZipFile, ZipEntry}
6+
import java.util.zip.{ZipEntry, ZipFile}
77
import scala.io.Source
88

99
object FocusedZipImporter {
@@ -31,10 +31,13 @@ case class FocusedZipImporter(focus: Option[File], zips: List[File], zipFiles: L
3131
case "." :: tail => loop(leftPart, tail)
3232
case child :: tail => loop(new File(leftPart, child), tail)
3333
}
34+
3435
val parts = n.split("/", -1).toList
35-
val newPath = loop(f, parts).getPath.replaceAllLiterally(File.separator, "/")
36-
if (parts(0) == File.pathSeparatorChar) newPath.substring(1)
37-
else newPath
36+
val newPath = loop(f, parts).getPath.replace(File.separator, "/")
37+
if (parts.head == File.separator)
38+
newPath.substring(1)
39+
else
40+
newPath
3841
}
3942

4043
private def resolve(filename: String): Option[(ZipEntry, ZipFile, FocusedZipImporter)] = {
@@ -51,6 +54,7 @@ case class FocusedZipImporter(focus: Option[File], zips: List[File], zipFiles: L
5154
}
5255

5356
private val maxLastMod = zips.map(_.lastModified).reduceOption(_ max _)
57+
5458
// uses the lastModified time of the zip/jar file
5559
def lastModified(filename: String): Option[Long] =
5660
resolve(filename).flatMap(_ => maxLastMod)

0 commit comments

Comments
 (0)