Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
470 views
in Technique[技术] by (71.8m points)

sbt - How to display classpath used for run task?

How can the classpath used for run task be displayed under SBT 0.13?

I have found some info here https://groups.google.com/forum/#!msg/simple-build-tool/0rhVRPnjyZU/DOYAd14gh1wJ:

I was dumping my classpaths as a way to troubleshoot my build recently and maybe this task can help you too:

lazy val printClasspath = task {
  this.runClasspath.getPaths.foreach(println);
  None
}

runClasspath is a PathFinder [1] instance and you can interrogate it even further. I guess building a ':'-separated list of those paths will be easy.

I don't understand where and how I should use this tip. Please advise.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If I type this in the sbt shell:

inspect run

I see, among other output:

[info] Dependencies:
[info]  runtime:fullClasspath

So then if I type:

show runtime:fullClasspath

I get output like:

 List(
   Attributed(/Users/tisue/Dropbox/repos/euler/target/scala-2.10/classes),
   Attributed(/Users/tisue/.sbt/boot/scala-2.10.3/lib/scala-library.jar))

Which is probably what you were looking for?

You can also get it in a colon-separated form suitable for use with java -classpath on the command line:

export runtime:fullClasspath

which prints e.g.:

/Users/tisue/Dropbox/repos/euler/target/scala-2.10/classes:/Users/tisue/.sbt/boot/scala-2.10.3/lib/scala-library.jar

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...