Skip to content

Commit

Permalink
Add ability to override classes used for GroovyDoc
Browse files Browse the repository at this point in the history
(closes #91)
  • Loading branch information
keeganwitt committed Sep 15, 2020
1 parent 5e70d02 commit eb6cc9a
Showing 1 changed file with 67 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,60 @@ public abstract class AbstractGroovyDocMojo extends AbstractGroovySourcesMojo {
@Parameter
protected String[] defaultClassTemplates;

/**
* Allows you to override the class that is normally org.codehaus.groovy.tools.groovydoc.GroovyDocTool, for use when
* creating custom GroovyDoc implementations.
*
* @since 1.10.1
*/
@Parameter
protected String groovyDocToolClass = null;

/**
* Allows you to override the class that is normally org.codehaus.groovy.tools.groovydoc.OutputTool, for use when
* creating custom GroovyDoc implementations.
* @since 1.10.1
*/
@Parameter
protected String outputToolClass = null;

/**
* Allows you to override the class that is normally org.codehaus.groovy.tools.groovydoc.FileOutputTool, for use
* when creating custom GroovyDoc implementations.
*
* @since 1.10.1
*/
@Parameter
protected String fileOutputToolClass = null;

/**
* Allows you to override the class that is normally org.codehaus.groovy.tools.groovydoc.ResourceManager, for use
* when creating custom GroovyDoc implementations.
*
* @since 1.10.1
*/
@Parameter
protected String resourceManagerClass = null;

/**
* Allows you to override the class that is normally org.codehaus.groovy.tools.groovydoc.ClasspathResourceManager,
* for use when creating custom GroovyDoc implementations.
*
* @since 1.10.1
*/
@Parameter
protected String classpathResourceManagerClass = null;

/**
* Allows you to override the class that is normally org.codehaus.groovy.tools.groovydoc.LinkArgument (or
* org.codehaus.groovy.ant.Groovydoc$LinkArgument for Groovy older than 1.6-RC-2), for use when creating custom
* GroovyDoc implementations.
*
* @since 1.10.1
*/
@Parameter
protected String linkArgumentClass = null;

/**
* Generates the GroovyDoc for the specified sources.
*
Expand Down Expand Up @@ -217,11 +271,11 @@ protected synchronized void doGroovyDocGeneration(final FileSet[] sourceDirector
}

// get classes we need with reflection
Class<?> groovyDocToolClass = classWrangler.getClass("org.codehaus.groovy.tools.groovydoc.GroovyDocTool");
Class<?> outputToolClass = classWrangler.getClass("org.codehaus.groovy.tools.groovydoc.OutputTool");
Class<?> fileOutputToolClass = classWrangler.getClass("org.codehaus.groovy.tools.groovydoc.FileOutputTool");
Class<?> resourceManagerClass = classWrangler.getClass("org.codehaus.groovy.tools.groovydoc.ResourceManager");
Class<?> classpathResourceManagerClass = classWrangler.getClass("org.codehaus.groovy.tools.groovydoc.ClasspathResourceManager");
Class<?> groovyDocToolClass = classWrangler.getClass(this.groovyDocToolClass == null ? "org.codehaus.groovy.tools.groovydoc.GroovyDocTool" : this.groovyDocToolClass);
Class<?> outputToolClass = classWrangler.getClass(this.outputToolClass == null ? "org.codehaus.groovy.tools.groovydoc.OutputTool" : this.outputToolClass);
Class<?> fileOutputToolClass = classWrangler.getClass(this.fileOutputToolClass == null ? "org.codehaus.groovy.tools.groovydoc.FileOutputTool" : this.fileOutputToolClass);
Class<?> resourceManagerClass = classWrangler.getClass(this.resourceManagerClass == null ? "org.codehaus.groovy.tools.groovydoc.ResourceManager" : this.resourceManagerClass);
Class<?> classpathResourceManagerClass = classWrangler.getClass(this.classpathResourceManagerClass == null ? "org.codehaus.groovy.tools.groovydoc.ClasspathResourceManager" : this.classpathResourceManagerClass);

// set up GroovyDoc options
Properties docProperties = setupProperties();
Expand Down Expand Up @@ -298,10 +352,14 @@ protected List<?> setupLinks() throws ClassNotFoundException, InvocationTargetEx
List linksList = new ArrayList();
if (links != null && links.size() > 0) {
Class<?> linkArgumentClass = null;
if (groovyAtLeast(GROOVY_1_6_0_RC2)) {
linkArgumentClass = classWrangler.getClass("org.codehaus.groovy.tools.groovydoc.LinkArgument");
} else if (groovyAtLeast(GROOVY_1_5_2)) {
linkArgumentClass = classWrangler.getClass("org.codehaus.groovy.ant.Groovydoc$LinkArgument");
if (this.linkArgumentClass == null) {
if (groovyAtLeast(GROOVY_1_6_0_RC2)) {
linkArgumentClass = classWrangler.getClass("org.codehaus.groovy.tools.groovydoc.LinkArgument");
} else if (groovyAtLeast(GROOVY_1_5_2)) {
linkArgumentClass = classWrangler.getClass("org.codehaus.groovy.ant.Groovydoc$LinkArgument");
}
} else {
linkArgumentClass = classWrangler.getClass(this.linkArgumentClass);
}
if (linkArgumentClass != null) {
Method setHref = findMethod(linkArgumentClass, "setHref", String.class);
Expand Down

0 comments on commit eb6cc9a

Please sign in to comment.