From 9ff9a3d1bc4a3a665f56456c561d384ef35a4a2a Mon Sep 17 00:00:00 2001 From: Keegan Witt Date: Sun, 4 Oct 2020 20:58:32 -0400 Subject: [PATCH] Add support for runtimeGroovydoc optimization --- .../mojo/AbstractGroovyDocMojo.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGroovyDocMojo.java b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGroovyDocMojo.java index 66a0daaa1..8ee3c6759 100644 --- a/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGroovyDocMojo.java +++ b/src/main/java/org/codehaus/gmavenplus/mojo/AbstractGroovyDocMojo.java @@ -44,6 +44,11 @@ */ public abstract class AbstractGroovyDocMojo extends AbstractGroovySourcesMojo { + /** + * Groovy 3.0.0 alpha-4 version. + */ + protected static final Version GROOVY_3_0_0_ALPHA_4 = new Version(3, 0, 0, "alpha-4"); + /** * Groovy 1.6.0 RC-2 version. */ @@ -233,6 +238,14 @@ public abstract class AbstractGroovyDocMojo extends AbstractGroovySourcesMojo { @Parameter protected String linkArgumentClass = null; + /** + * Enable attaching GroovyDoc annotation. Requires Groovy 3.0.0 alpha-4 or newer. + * + * @since 1.10.2 + */ + @Parameter(defaultValue = "false") + protected boolean attachGroovyDocAnnotation; + /** * Generates the GroovyDoc for the specified sources. * @@ -279,6 +292,13 @@ protected synchronized void doGroovyDocGeneration(final FileSet[] sourceDirector Class classpathResourceManagerClass = classWrangler.getClass(this.classpathResourceManagerClass == null ? "org.codehaus.groovy.tools.groovydoc.ClasspathResourceManager" : this.classpathResourceManagerClass); // set up GroovyDoc options + if (attachGroovyDocAnnotation) { + if (groovyAtLeast(GROOVY_3_0_0_ALPHA_4)) { + System.setProperty("runtimeGroovydoc", "true"); + } else { + getLog().warn("Requested to enable attaching GroovyDoc annotation, but your Groovy version (" + classWrangler.getGroovyVersionString() + ") doesn't support it (must be " + GROOVY_3_0_0_ALPHA_4 + " or newer). Ignoring enableGroovyDocAnnotation parameter."); + } + } Properties docProperties = setupProperties(); Object fileOutputTool = invokeConstructor(findConstructor(fileOutputToolClass)); Object classpathResourceManager = invokeConstructor(findConstructor(classpathResourceManagerClass));