Reputation: 2600
I'm using SBT and IntellijIdea to run a project. I basically need to develop a module that relies on some other library to do its job. However, I want to "see" the control flow on the library while I'm debugging my project. That is:
-> callToLibrary(...)
While debugging, I want to be able to enter this call and see the code of the external library. What are the configurations on Intellij Idea and SBT in order to do so?
Specifications
In order to be more precise assume my project has the following structure:
project-name
-> .idea
-> project[project-name-build]
-> src -> main
-> test
-> target
-> build.sbt
-> External Libraries
Say I have the sources of my external library in some file stored in the path written in directory
. Say this sources files are just a project cloned from Github.
What would be the structure needed in the SBT file and the configuration in Intellij Idea in order to get the project working (not complaining with the imports) and being able to debug the project and the external library?
Upvotes: 0
Views: 2569
Reputation: 4161
Make sure you have transitiveClassifiers := Seq("sources")
in build.sbt, so that all your libraries have sources downloaded. Then all you need to do is debug your app as you normally would. When stepping into library code, the source will be displayed. Additionally, IntelliJ will decompile a class for you if source is not available. Something like this in your build.sbt
:
lazy val commonSettings = Seq[sbt.Def.Setting[_]](
scalaVersion := "2.11.8"
// ...
, transitiveClassifiers := Seq("sources")
)
lazy val root =
Project(
id = "some_name"
, base = file(".")
, aggregate = Seq( ... )
)
.enablePlugins(...)
.settings( commonSettings: _* )
)
Upvotes: 2