Skip to content

Commit

Permalink
Allow multiple comma-separated inference jar paths (#4092)
Browse files Browse the repository at this point in the history
  • Loading branch information
johannescoetzee authored Feb 8, 2024
1 parent a672fec commit eb8a3fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ private object Frontend {
import builder._
OParser.sequence(
programName("javasrc2cpg"),
opt[String]("inference-jar-paths")
.text(s"extra jars used only for type information")
.action((path, c) => c.withInferenceJarPaths(c.inferenceJarPaths + path)),
opt[Seq[String]]("inference-jar-paths")
.text(s"extra jars used only for type information (comma-separated list of paths)")
.action((paths, c) => c.withInferenceJarPaths(c.inferenceJarPaths ++ paths)),
opt[Unit]("fetch-dependencies")
.text("attempt to fetch dependencies jars for extra type information")
.action((_, c) => c.withFetchDependencies(true)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ class AstCreationPass(config: Config, cpg: Cpg, sourcesOverride: Option[List[Str

// Add solvers for inference jars
val jarsList = config.inferenceJarPaths.flatMap(recursiveJarsFromPath).toList
if (config.inferenceJarPaths.isEmpty) {
logger.debug("No inference jar paths given")
} else if (jarsList.isEmpty) {
logger.warn(s"Could not find any inference jars at provided paths: ${config.inferenceJarPaths.mkString(",")}")
} else {
logger.debug(s"Using inference jars: ${jarsList.mkString(":")}")
}
(jarsList ++ dependencies)
.flatMap { path =>
Try(new JarTypeSolver(path)).toOption
Expand Down

0 comments on commit eb8a3fe

Please sign in to comment.