GroovyDoc as Maven Plugin
Asked Answered
T

4

9

Is there a maven plugin available somewhere that utilizes GroovyDoc, preferably as a report?

I guess GMaven would be the place to look but the docs are ancient (1.0, whereas the current version is 1.3) and the GMaven plugin doesn't have any mojo that fits as you can see:

mvn help:describe -DgroupId=org.codehaus.gmaven -DartifactId=gmaven-plugin

This plugin has 9 goals:

groovy:compile
Description: Compiles Groovy sources.

groovy:console
Description: Launches the Groovy GUI console.

groovy:execute
Description: Executes a Groovy script.

groovy:generateStubs
Description: Generate Java stubs from Groovy sources.

groovy:generateTestStubs
Description: Generate Java stubs from Groovy test sources.

groovy:help
Description: Display help information on gmaven-plugin.
Call
mvn groovy:help -Ddetail=true -Dgoal=<goal-name>
to display parameter details.

groovy:providers
Description: Displays information about the Groovy runtime providers which are configured and selected.

groovy:shell
Description: Launches the Groovy Shell (aka. groovysh).

groovy:testCompile
Description: Compiles Groovy test sources.

So does anyone have any pointers to a maven groovydoc plugin? Google didn't come up with anything meaningful.

Theomancy answered 16/3, 2011 at 12:27 Comment(2)
The author of GMaven attempted a rewrite of the plugin a while back (github.com/keeganwitt/GMavenPlus). One of the goals was to provide support for GroovyDoc, but at the time of this writing, it hasn't been released yet.Certificate
@sean-patrick-floyd I'm plan to release a beta this month. I'm working on setting up Maven repositories now.Hopper
G
3

You want the gmavenplus plugin: http://groovy.github.io/GMavenPlus/groovydoc-mojo.html

<project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.gmavenplus</groupId>
        <artifactId>gmavenplus-plugin</artifactId>
        <version>1.5</version>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all</artifactId>
      <!-- any version of Groovy \>= 1.5.0 (except 1.6 RC 1) should work here -->
      <version>2.4.7</version>
    </dependency>
  </dependencies>
</project>

and run: mvn gplus:generateStubs gplus:groovydoc

Gers answered 18/1, 2017 at 19:4 Comment(6)
Too late for me, but hopefully it will help somebody else. Thanks!Theomancy
It's generating empty documentation for me. Is there anything I am missing?Gigantean
@ParameshKorrakuti what goals are you running? You did add javadocs/groovydocs to your actual source files, right?Gers
@SeanPatrickFloyd added groovydics and executing mvn gplus:generateStubs gplus:groovydoc command. It's creating frames with empty documentation.Gigantean
@ParameshKorrakuti I'm not sure why you'd have empty docs if you've actually got the javadoc sytle comments written in your code and are using the maven plugin as shown above. If you share a link to a github or similar, I'd be happy to poke around and see if I can help.Gers
This plugin is also referenced in the official Groovy documentation: docs.groovy-lang.org/docs/next/html/documentation/…Undersurface
O
10

Although there is not any Groovydoc maven compatible plugin, generating the documentation for your groovy classes is quite easy using Maven. This is the way we do in our projects:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.7</version>
  <executions>
    <execution>
      <id>groovydoc</id>
      <phase>site</phase>
      <goals>
        <goal>run</goal>
      </goals>
      <configuration>
        <target>
          <taskdef name="groovydoc"
            classname="org.codehaus.groovy.ant.Groovydoc" 
            classpathref="maven.compile.classpath"
          />
          <groovydoc destdir="${project.reporting.outputDirectory}/groovydoc"
            sourcepath="${basedir}/src/main/groovy" use="true"
            windowtitle="${project.name}"
            doctitle="${project.name}"
          >
            <link packages="java.,org.xml.,javax.,org.xml."
              href="http://download.oracle.com/javase/6/docs/api" />
            <link packages="org.apache.tools.ant." 
              href="http://evgeny-goldin.org/javadoc/ant/api" />
            <link packages="org.junit.,junit.framework."
              href="http://kentbeck.github.com/junit/javadoc/latest" />
            <link packages="groovy.,org.codehaus.groovy."
              href="http://groovy.codehaus.org/api/" />
            <link packages="org.codehaus.gmaven."
              href="http://evgeny-goldin.org/javadoc/gmaven" />
          </groovydoc>
        </target>
      </configuration>
    </execution>
  </executions>
</plugin>
Opalescent answered 7/12, 2011 at 14:1 Comment(2)
I'll accept this because it seems to work, even though I no longer have a need for it.Theomancy
Why do you no longer have a need for it? Did you find an alternate solution?Foment
I
3

I don't think there is a Maven plugin for Groovydoc, but you can use the Ant task. GMaven follows a different approach: generateStubs creates Java stubs for Groovy classes, which can then be processed by the regular Javadoc plugin. However, I don't know how well this approach works in practice, in particular because newer versions of GMaven use the Groovy compiler's stub generator, which wasn't created with the goal of producing proper Javadoc in mind.

Impression answered 16/3, 2011 at 22:52 Comment(0)
G
3

You want the gmavenplus plugin: http://groovy.github.io/GMavenPlus/groovydoc-mojo.html

<project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.gmavenplus</groupId>
        <artifactId>gmavenplus-plugin</artifactId>
        <version>1.5</version>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all</artifactId>
      <!-- any version of Groovy \>= 1.5.0 (except 1.6 RC 1) should work here -->
      <version>2.4.7</version>
    </dependency>
  </dependencies>
</project>

and run: mvn gplus:generateStubs gplus:groovydoc

Gers answered 18/1, 2017 at 19:4 Comment(6)
Too late for me, but hopefully it will help somebody else. Thanks!Theomancy
It's generating empty documentation for me. Is there anything I am missing?Gigantean
@ParameshKorrakuti what goals are you running? You did add javadocs/groovydocs to your actual source files, right?Gers
@SeanPatrickFloyd added groovydics and executing mvn gplus:generateStubs gplus:groovydoc command. It's creating frames with empty documentation.Gigantean
@ParameshKorrakuti I'm not sure why you'd have empty docs if you've actually got the javadoc sytle comments written in your code and are using the maven plugin as shown above. If you share a link to a github or similar, I'd be happy to poke around and see if I can help.Gers
This plugin is also referenced in the official Groovy documentation: docs.groovy-lang.org/docs/next/html/documentation/…Undersurface
S
0

The Groovydoc Maven Plugin worked for me: https://github.com/rvowles/groovydoc-maven-plugin

Stace answered 5/8, 2014 at 23:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.