-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix tab-completion in distribution (#5308)
* fix tab-completion in distribution the `removeModuleInfoFromJars` hack only get's triggered for `Universal/stage` - our release uses `Universal/packageBin` and that doesn't seem to reuse anything related that we could trigger on unfortunately... So I thought it's easiest to just add the same hack to the start script... re #4625 (comment) * abs dir * handle both Universal/packageBin and stage: adapt mappings * remove hack from start script * refactor * fix copy pasta * simplify based on PR discussion
- Loading branch information
1 parent
b5fe810
commit 35dacc9
Showing
2 changed files
with
39 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,28 +129,23 @@ generateScaladocs := { | |
out | ||
} | ||
|
||
Universal / packageBin / mappings ++= sbt.Path.directory(new File("joern-cli/src/main/resources/scripts")) | ||
|
||
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") | ||
removeModuleInfoFromJars := { | ||
import java.nio.file.{Files, FileSystems} | ||
val logger = streams.value.log | ||
val libDir = (Universal/stagingDirectory).value / "lib" | ||
|
||
// remove all `/module-info.class` from all jars | ||
Files.walk(libDir.toPath) | ||
.filter(_.toString.endsWith(".jar")) | ||
.forEach { jar => | ||
val zipFs = FileSystems.newFileSystem(jar) | ||
zipFs.getRootDirectories.forEach { zipRootDir => | ||
Files.list(zipRootDir).filter(_.toString == "/module-info.class").forEach { moduleInfoClass => | ||
logger.info(s"workaround for scala completion bug: deleting $moduleInfoClass from $jar") | ||
Files.delete(moduleInfoClass) | ||
} | ||
} | ||
zipFs.close() | ||
} | ||
Universal/mappings ++= sbt.Path.directory(new File("joern-cli/src/main/resources/scripts")) | ||
|
||
// remove module-info.class from dependency jars - a hacky workaround for a scala3 compiler bug | ||
// see https://github.com/scala/scala3/issues/20421 | ||
val moduleInfoLocation = "module-info.class" | ||
Universal/mappings := (Universal/mappings).value.collect { | ||
case (jar, location) | ||
if location.startsWith("lib") | ||
&& location.endsWith(".jar") | ||
&& FileUtils.jarContainsEntryInRoot(jar, moduleInfoLocation) => | ||
val newJar = target.value / "without-module-info" / jar.getName() | ||
IO.copyFile(jar, newJar) | ||
FileUtils.removeJarEntryFromRoot(newJar, moduleInfoLocation) | ||
streams.value.log.info(s"workaround for scala completion bug: including a modified version of $jar without the $moduleInfoLocation entry: $newJar") | ||
newJar -> location | ||
case other => | ||
other // no need to change anything | ||
} | ||
removeModuleInfoFromJars := removeModuleInfoFromJars.triggeredBy(Universal/stage).value | ||
|
||
maintainer := "[email protected]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters