Create Javadoc with Class Diagrams using UMLGraph with Gradle - kercheval/GradleCMPlugin GitHub Wiki
Nothing shows structure like diagrams do. If your project has an interesting class hierarchy, then creating JavaDoc with embedded diagrams will really be of use.
To generate these diagrams you will need the dot program in your path. This example overrides the javadoc task for all project and subprojects to create graphs when the javadoc task is run.
Note the use of the ant javadoc task to instantiate the doclet.
//
// Override the javadoc task to use umlgraph doclet. This depends on the presence
// of GraphViz on the path in your environment (http://www.graphviz.org)
//
allprojects {
configurations {
umljavadoc
}
dependencies {
umljavadoc 'org.umlgraph:umlgraph:5.6'
}
//
// While javadoc is not typically dependent on compilation, the compile steps
// sometimes generate some sources that we wish to have in the Javadoc.
//
task javadoc(overwrite: true, dependsOn: compileJava) {
setDescription('Generates Javadoc API documentation with UMLGraph diagrams')
setGroup(JavaBasePlugin.DOCUMENTATION_GROUP)
doLast {
def javaFilePath = file('src/main/java')
if (javaFilePath.exists()) {
ant.javadoc(classpath: (configurations.runtime + configurations.provided).asPath,
sourcepath: file('src/main/java'),
packagenames: '*',
destdir: "${docsDir}/javadoc",
private: 'true',
docletpath: configurations.umljavadoc.asPath) {
doclet(name: 'org.umlgraph.doclet.UmlGraphDoc') {
param(name: '-inferrel')
param(name: '-inferdep')
param(name: '-qualify')
param(name: '-postfixpackage')
param(name: '-hide', value: 'java.*')
param(name: '-collpackages', value: 'java.util.*')
param(name: '-nodefontsize', value: '9')
param(name: '-nodefontpackagesize', value: '7')
param(name: '-link', value: 'http://java.sun.com/j2se/1.5.0/docs/guide/javadoc/doclet/spec')
param(name: '-link', value: 'http://java.sun.com/j2se/1.5/docs/api')
}
}
}
}
}
}