Class DependencyGraphParser


public class DependencyGraphParser extends Object
Creates a dependency graph from a text description.


Each (non-empty) line in the input defines one node of the resulting graph:
 line      ::= (indent? ("(null)" | node | reference))? comment?
 comment   ::= "#" rest-of-line
 indent    ::= "|  "*  ("+" | "\\") "- "
 reference ::= "^" id
 node      ::= coords (range)? space (scope("<" premanagedScope)?)? space "optional"? space
                  ("relocations=" coords ("," coords)*)? ("(" id ")")?
 coords    ::= groupId ":" artifactId (":" extension (":" classifier)?)? ":" version
The special token (null) may be used to indicate an "empty" root node with no dependency.

If indent is empty, the line defines the root node. Only one root node may be defined. The level is calculated by the distance from the beginning of the line. One level is three characters of indentation.

The ^id syntax allows to reuse a previously built node to share common sub graphs among different parent nodes.


 +- gid:aid2:ver scope
 |  \- gid:aid3:ver        (id1)    # assign id for reference below
 +- gid:aid4:ext:ver scope
 \- ^id1                            # reuse previous node

Multiple definitions in one resource

By using parseMultiResource(String), definitions divided by a line beginning with "---" can be read from the same resource. The rest of the line is ignored.


You may define substitutions (see setSubstitutions(String...), DependencyGraphParser(String, Collection)). Every '%s' in the definition will be substituted by the next String in the defined substitutions.


 parser.setSubstitutions( "foo", "bar" );
 String def = "gid:%s:ext:ver\n" + "+- gid:%s:ext:ver";
The first node will have "foo" as its artifact id, the second node (child to the first) will have "bar" as its artifact id.