Sculpt is a compiler plugin for analyzing the dependency structure of Scala source code. It is now public for the first time. The source code is available under an Apache 2 license here:
The reports it generates are intended to be useful to Scala coders looking to alter the dependency structure of a codebase in order to reduce incremental compile times or split the codebase into separately buildable parts.
Sculpt uses code derived from Zinc to listen to the same dependency information coming out of the compiler that is used to guide incremental compilation.
Features include:
store the raw dependency data in memory as case class instances
output the raw dependency data as JSON
analyze at method level, or aggregate dependencies at class level
generate report of dependency layers
generate report of dependency cycles
See the README in the repository for more details.
There are no binary releases; the project is released as source code only.
The project is not currently actively maintained. The Scala team at Lightbend is making it available anyway in the hopes that tooling authors might find it interesting or useful.
(Thanks, Jorge, for prodding me to get this out there…)
Thanks for publishing this. One question: I didn’t see how to get a map of which symbols are in which files. Can this tool do that? I think for many applications we also want the mapping of file to symbol.
ExtractDependencies.scala produces an Iterator[(Symbol, HashSet[Symbol])]. The Symbols themselves know what source files they’re from. That iterator then gets converted into instances of case class FullDependency by createFullDependencies. By design, FullDependency is outside the compiler cake and has no references to internal compiler/reflection data structures such as Symbol.
You could easily alter the FullDependency class to have fields for the source file pathnames, and alter createFullDependencies to copy that information out of the symbols.
Depending on your goals, you might also decide to simply ignore all of Sculpt except for ExtractDependencies.scala, and then just do your own thing with the Iterator[(Symbol, HashSet[Symbol])] it gives you.
bonus: an 11 minute interview with me at https://www.youtube.com/watch?v=OlT9p0L76Qs talking some about Sculpt, but also more wide-ranging stuff about my Scala history, moving from Boston to San Francisco, joining Lightbend, Scala vs. Lisp, the community build, Fortify, NetLogo, and other stuff.