Sbt incremental compilation graphical logic

sbt supports dependencies between tasks, and the resulting graph can be reasonably justified. On the other hand, reducing the source code, it seems that the incremental compilation logic is much more opaque. I would like to be able to do the following things:

  • Say the equivalent of "if I changed this interface [this way], what would be invalid?"
  • Build a graph of how changing the various class interfaces affects the rest of the assembly. The scala import graphical dependencies are not a particularly good approximation to this, given how complex implicit dependencies can get in Scala. It seems that sbt should support this information in one way or another in order to do incremental compilation, so I just need to figure out how to access it and hope that it will be in a form suitable for my use.

Can this be done? I am not opposed to writing sbt plugins, but I will be grateful for tips on how to proceed.

Edit: It looks like Relation usesInternalSrc(dep: File): Set[File] might be promising. Does this mean all knowledge of sbt dependency?

Edit 2: Even more promising, there is a DotGraph object inside the sbt source tree. It has no documentation, and google has no human-readable texts. If I can figure out how to use it, I will send an answer.

+4
source share
1 answer

Example console-project session:

 > val (s, a) = runTask(compile in Compile, currentState) > DotGraph.sources(a.relations, file("source-graph"), Nil) 

source-graph is a directory that will contain two point files: one with source dependencies and one with binary. You can alternatively directly interact with a.relations type Relations , as suggested in the question, and which captures all the knowledge of sbt dependency. In 0.13 there will also be information about which dependencies are related to inheritance from something in another source file.

Regarding how changing a source file affects invalidation, it is very rude. Any change to any non-personal signature indicates the source that has been changed. In 0.12 and earlier versions, this will at least lead to invalid direct dependencies and possibly more. At 0.13, this will invalidate only direct dependencies, with the exception of inherited dependencies that are transitively invalid. There is currently no way to see what will be invalidated if the non-private API of the source file is changed, except that it does so.

+3
source

Source: https://habr.com/ru/post/1487525/


All Articles