Skip to content

Commit d7c1096

Browse files
committed
workaround for scala completion bug
on stage: remove module-info.class from dependency jars - a hacky workaround for a scala3 compiler bug: scala/scala3#20421 Fixes #4625
1 parent 10ab72d commit d7c1096

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

joern-cli/build.sbt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,26 @@ generateScaladocs := {
131131

132132
Universal / packageBin / mappings ++= sbt.Path.directory(new File("joern-cli/src/main/resources/scripts"))
133133

134+
lazy val removeModuleInfoFromJars = taskKey[Unit]("remove module-info.class from dependency jars - a hacky workaround for a scala3 compiler bug https://github.com/scala/scala3/issues/20421")
135+
removeModuleInfoFromJars := {
136+
import java.nio.file.{Files, FileSystems}
137+
val logger = streams.value.log
138+
val libDir = (Universal/stagingDirectory).value / "lib"
139+
140+
// remove all `/module-info.class` from all jars
141+
Files.walk(libDir.toPath)
142+
.filter(_.toString.endsWith(".jar"))
143+
.forEach { jar =>
144+
val zipFs = FileSystems.newFileSystem(jar)
145+
zipFs.getRootDirectories.forEach { zipRootDir =>
146+
Files.list(zipRootDir).filter(_.toString == "/module-info.class").forEach { moduleInfoClass =>
147+
logger.info(s"workaround for scala completion bug: deleting $moduleInfoClass from $jar")
148+
Files.delete(moduleInfoClass)
149+
}
150+
}
151+
zipFs.close()
152+
}
153+
}
154+
removeModuleInfoFromJars := removeModuleInfoFromJars.triggeredBy(Universal/stage).value
155+
134156
maintainer := "[email protected]"

0 commit comments

Comments
 (0)