I am thinking about a DSL / domain design to analyse a big bunch of maven dependencies.
Input is a list of poms (effectively a map between poms and physical location), which I think will be parsed as “flat” (i.e. non-recursive) files to some nice scala type like this:
class Artifact(
val groupId : String,
val artifactId : String,
val version : String
)
class Module(
val id : Artifact,
val location : URI, // any good type for this ?
val parent : Option(Artifact),
val modules : List(Artifact),
val dependencies : List(Artifact)
)
Then there are three structures on that “nodes”
- inheritance: by <parent> and <modules>
- dependencies: by <dependency>
- physical: filesystem / svn dir-layout
Question: How should these be designed?
Some possibilities in my mind:
- Impose structure on modules them selves, e.g. by making the list of dependencies mutable, and change its type to List(Either(Artifact,Module)).
- Reuse collection API, and map inheritance tree to Tree(Module). But what with the dependency graph ?
- Design completely new structures and map the list of poms onto this
- Others? …
Of course, I want to have as much information as possible in the data-structure to avoid repeated calculations. Outline is:
- parse list of flat files
- enrich to structure (either by structure update (mutable) or mapping to a different structure (immutable/functional).
- query rich structure.
Things I want to do with this:
- find incoming dependencies
- find “clusters”
- find relations of nth grade
- give refactoring hints (pull-up dependencies, merge modules)
- render pom.xml as html, browse to related artifacts. (similar to http://jarvana.com)
Thanks for any insights …
Just for the records, I will instantiate new structures, based on immutable collections (trees and scalax.graph http://www.assembla.com/spaces/scala-graph/wiki ).
For the browsing of poms, I will render them to xhtml, injecting links for dependencies/inheritance, probably based on play-framework.
And if this project will ever produce something useful, I will post it here …