Trunk NetBeans cluster dependency graph generated using dot

Here is a cluster dependency graph for the NetBeans trunk (post-6.1 aka 6.5) build. The graph was generated using the dot program from graphviz package on my Ubuntu laptop.
 

dependencies

To produce the necessary input file for the dot program I hacked the following method:

    private void generateGroupDependencies (File output, boolean implementationOnly) throws BuildException, IOException {
PrintWriter w = new PrintWriter (new FileWriter (output));

Map<Dependency,Set<ModuleInfo>> referrers = new HashMap<Dependency,Set<ModuleInfo>>();

TreeMap<String, Set<Dependency>> groups = new TreeMap<String, Set<Dependency>>();
for (ModuleInfo m : modules) {
if (regexp != null && !regexp.matcher(m.group).matches()) {
continue;
}
Set<Dependency> l = groups.get(m.group);
if (l == null) {
l = new TreeSet<Dependency>();
groups.put(m.group, l);
}
l.addAll(m.depends);
for (Dependency d : m.depends) {
Set<ModuleInfo> r = referrers.get(d);
if (r == null) {
r = new HashSet<ModuleInfo>();
referrers.put(d, r);
}
r.add(m);
}
}

w.println("digraph G {");
w.println(" ratio=auto;");
w.println(" concentrate=true;");
w.println(" node[shape=box,tailport=s];");
for (Map.Entry<String,Set<Dependency>> e : groups.entrySet()) {
String groupName = e.getKey();
Set<Dependency> depends = e.getValue();
Set<String> seenGroup = new HashSet<String>();
boolean first = true;
for (Dependency d : depends) {
String print = " REQUIRES ";
if (d.exact && d.compare != null) {
// ok, impl deps
} else {
if (implementationOnly) {
continue;
}
}

// special dependencies are ignored
if (d.isSpecial ()) {
continue;
}
// dependencies within one group are not important
Set<ModuleInfo> r = referrers.get(d);
ModuleInfo ref = findModuleInfo(d, r.size() == 1 ? r.iterator().next() : null);
if (groupName.equals (ref.group)) {
continue;
}
// Have we seen this group already - group == cluster
if(seenGroup.contains(ref.group)) {
// skip
continue;
}
seenGroup.add(ref.group);

w.print (" ");
w.print (groupName);
w.print (" -> ");
w.print (ref.group);
w.print (";");
w.println ();
}
}
w.println("}");
w.close ();
}

in nbbuild/antsrc/org/netbeans/nbbuild/ModuleDependencies.java file. Then I built and ran the ant task like this:

>  cd nbbuild
>  ant bootstrap generate-golden-files

to generate the dependency files in nbbuild/build/generated. This produced the following contents: 

digraph G {
ratio=auto;
concentrate=true;
node[shape=box,tailport=s];
apisupport -> ide;
apisupport -> java;
apisupport -> platform;
apisupport -> harness;
cnd -> platform;
cnd -> ide;
gsf -> platform;
gsf -> ide;
harness -> platform;
ide -> platform;
identity -> java;
identity -> platform;
identity -> j2ee;
identity -> ide;
j2ee -> java;
j2ee -> ide;
j2ee -> platform;
j2ee -> gsf;
java -> platform;
java -> ide;
mobility -> java;
mobility -> platform;
mobility -> ide;
mobility -> j2ee;
nb -> platform;
nb -> ide;
profiler -> java;
profiler -> platform;
profiler -> ide;
profiler -> j2ee;
ruby -> platform;
ruby -> ide;
ruby -> gsf;
soa -> java;
soa -> ide;
soa -> platform;
soa -> j2ee;
soa -> xml;
uml -> platform;
uml -> java;
uml -> ide;
visualweb -> java;
visualweb -> platform;
visualweb -> j2ee;
visualweb -> ide;
visualweb -> nb;
xml -> platform;
xml -> ide;
}

in nbbuild/build/generated/cluster-deps.txt and then I ran the following command on the file:

>  cd build/generated
>  dot -Tpng cluster-deps.txt -o cluster-deps.png

and we have the graph in cluster-deps.png file.

Similar technique could be applied to generate dependency graphs for modules dependencies etc. I will look into making it part of the build which could be invoked on demand to produce the dependency graphs.

Comments:

Thanks--I was just about to do that myself as I get ready to embed a minimal ide into an application.

Posted by guest on May 24, 2008 at 12:59 AM PDT #

Extremely cool. Would make for a great action for module suite projects.

Posted by Geertjan on May 24, 2008 at 06:19 AM PDT #

Post a Comment:
Comments are closed for this entry.
About

sandipchitale

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today