li-raz
li-raz

Reputation: 1696

How to see the list of JARs that are loaded with my Scala Application

I need to do a security scan for my application. I have wrote this code to download all the dependent JARs

barvaz := {
    buildStandalone.value
   // Define the paths to the ".ivy2" in the current-working-directory (localIvy) and in the 
   user's home
   val localIvy    = (baseDirectory in publishLocal).value / ".ivy2"
   val projectBoot = (baseDirectory in publishLocal).value / "project/boot"

   // Package everything in target/standalone.zip so it could easily be copied around
   val ivy2Files    = (localIvy ** "*.jar").get.map(_.getPath.replaceAll(".*\\.ivy2", ".ivy2"))
   val projectFiles = (projectBoot ** "*.jar").get.map(_.getPath.replaceAll(".*boot", "project/boot"))
   val jarNames = (ivy2Files ++ projectFiles).map(_.replaceAll("\\\\", "/")) //Seq("sbt-launch.jar") ++

   Packaging.downloadLibSourcesAndBins((resourceDirectory in Compile).value / "barvaz", jarNames)

   val downloadedJars = ((target.value / "barvaz") ** "*.jar").get.map(f => f -> f.getPath.replaceFirst(".*barvaz", ""))

   IO.zip(downloadedJars, new File(s"target/barvaz-${version.value}.zip"))

  "Done"
}

however I have now duplicates of JARs from different versions , for example jettey from version 4.0.0 and 4.0.1 and of course some testing JARs How can I inspect which JARs are actually loaded?

Upvotes: 0

Views: 322

Answers (1)

Haemin Yoo
Haemin Yoo

Reputation: 541

You can try show fullClasspath in sbt.

Edit:

If you want a pretty text output (perhaps to feed into some other programs), you can try consoleProject and then in the scala repl, evaluate: println(fullClasspath.in(Compile).eval.map(_.data).mkString("\n")).

Upvotes: 1

Related Questions