title: Designing a Scala DSL for maven-poms
body: <p>I am thinking about a DSL / domain design to analyse a big bunch of maven dependencies.</p>
  
  <p>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:</p>
  
  <pre><code>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)
  )
  </code></pre>
  
  <p>Then there are three structures on that "nodes"</p>
  
  <ol>
  <li>inheritance: by &lt;parent&gt; and &lt;modules&gt; </li>
  <li>dependencies: by &lt;dependency&gt; </li>
  <li>physical: filesystem / svn dir-layout</li>
  </ol>
  
  <p><strong>Question: How should these be designed?</strong> </p>
  
  <p>Some possibilities in my mind:</p>
  
  <ol>
  <li>Impose structure on modules them selves, e.g. by making the list of dependencies mutable, and change its type to List(Either(Artifact,Module)).</li>
  <li>Reuse collection API, and map inheritance tree to Tree(Module). But what with the dependency <em>graph</em> ?</li>
  <li>Design completely new structures and map the list of poms onto this</li>
  <li><em>Others?</em> ...</li>
  </ol>
  
  <p>Of course, I want to have as much information as possible in the data-structure to avoid repeated calculations. Outline is:</p>
  
  <ol>
  <li>parse list of flat files</li>
  <li>enrich to structure (either by structure update (mutable) or mapping to a different structure (immutable/functional).</li>
  <li>query rich structure.</li>
  </ol>
  
  <p>Things I want to do with this:</p>
  
  <ul>
  <li>find incoming dependencies</li>
  <li>find "clusters"</li>
  <li>find relations of nth grade</li>
  <li>give refactoring hints (pull-up dependencies, merge modules)</li>
  <li>render pom.xml as html, browse to related artifacts. (similar to <a href="http://jarvana.com" rel="nofollow">http://jarvana.com</a>)</li>
  </ul>
  
  <p>Thanks for any insights ...</p>