With SBT it is possible to download sources and javadocs of libraries. It is really straight forward, just add withSources()
and withJavadoc()
to the dependency.
Single dependency:
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.1.0" withSources() withJavadoc()
Multiple dependencies:
libraryDependencies ++= Seq( "com.typesafe.scala-logging" %% "scala-logging" % "3.1.0" withSources() withJavadoc(), "ch.qos.logback" % "logback-classic" % "1.1.2" withSources() withJavadoc(), "com.typesafe.akka" %% "akka-actor" % "2.3.6" withSources() withJavadoc(), "com.typesafe.akka" %% "akka-testkit" % "2.3.6" % "test" withSources() withJavadoc(), "org.scalatest" % "scalatest_2.11" % "2.2.1" % "test" withSources() withJavadoc() )
However, after reloading the build.sbt
file with reload
and then running eclipse
the sources and javadocs are not available in Eclipse. To make the sources and javadoc available in Eclipse you have to add the following statements to the build.sbt
file.
import com.typesafe.sbteclipse.plugin.EclipsePlugin._ EclipseKeys.withSource := true
Now run the commands reload
and eclipse
again. Go to Eclipse, make sure you refresh your project (F5
). If you navigate to the Referenced Libraries
under your project and open the library you have added withSources() and withJavadoc() to the source code and javadoc shoud be available. How convenient is this? Happy coding 🙂
Ps. alternatively you could use eclipse with-source=true
. I prefer to minimize what I have to type and remember. Your choice.