GroovyDoc as Maven Plugin

风流意气都作罢 提交于 2019-12-04 03:11:44

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

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>

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!