Is there a way to generate dot files for scala classes and files?

66 views
Skip to first unread message

bewan...@gmail.com

unread,
Jun 3, 2013, 5:04:25 PM6/3/13
to simple-b...@googlegroups.com
I knew Project.graphSettings can show the graphs of sbt settings. Is there a way to create .dot files for scala classes and files?

The incremental compiler uses Relations internal to invalidate sources. How can I get the relations of classes and generate a .dot file?

We have troubles in a play project. Usually one file change will propagate to all files recompilation. If we can get the graph of all classes, we can figure out how to make classes decoupled and won't recompile every file. 

Mark Harrah

unread,
Jun 5, 2013, 10:35:39 AM6/5/13
to simple-b...@googlegroups.com
On Mon, 3 Jun 2013 14:04:25 -0700 (PDT)
bewan...@gmail.com wrote:

> I knew Project.graphSettings can show the graphs of sbt settings. Is there
> a way to create .dot files for scala classes and files?
>
> The incremental compiler uses Relations internal to invalidate sources. How
> can I get the relations of classes and generate a .dot file?

The DotGraph object has some convenience methods for generating dot files from Relations. This is not an official, documented API, but it should be straightforward. You can get the Relations from the result of `compile`. For example,

$ sbt
> console-project
> val (_, analysis) = runTask(compile in Compile, currentState)
> DotGraph.sources(analysis.relations, file("dot"), Nil)

$ dot -Tpng -osrcDeps.png dot/int-source-deps

The Nil argument is the list of source directories, which is used to relativize the file paths. When unspecified, as here, the graph just has the source file name.

-Mark

> We have troubles in a play project. Usually one file change will propagate
> to all files recompilation. If we can get the graph of all classes, we can
> figure out how to make classes decoupled and won't recompile every file.
>
> --
> You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to simple-build-t...@googlegroups.com.
> To post to this group, send email to simple-b...@googlegroups.com.
> Visit this group at http://groups.google.com/group/simple-build-tool?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

bewan...@gmail.com

unread,
Jun 6, 2013, 1:48:55 PM6/6/13
to simple-b...@googlegroups.com
That is exactly what I want. Thanks so much.
Reply all
Reply to author
Forward
0 new messages