Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude generated files from gradle javadoc task?

I am generating some code in my gradle build through a 3rd party plugin. The generated codes javadoc is malformed.

So i tried to exclude that path from gradles javadoc task but it does not work. I looked through similar questions but none offers a helpful answer.

$> ./gradlew --version
------------------------------------------------------------
Gradle 4.3
------------------------------------------------------------

Build time:   2017-10-30 15:43:29 UTC
Revision:     c684c202534c4138b51033b52d871939b8d38d72

Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_121 (Oracle Corporation 25.121-b13)
OS:           Windows 7 6.1 amd64

This is my build.gradle

sourceSets {
  main {
    compileClasspath += java.srcDir("${buildDir}/generated/src/main/com4j")
    runtimeClasspath += java.srcDir("${buildDir}/generated/src/main/com4j")
  }
  test {
    compileClasspath += java.srcDir("${buildDir}/generated/src/main/com4j")
    runtimeClasspath += java.srcDir("${buildDir}/generated/src/main/com4j")
  }
}

javadoc {
  exclude "**/generated/**"
  source = sourceSets.main.allJava
}

Has no effect.

$> ./gradlew javadoc
:javadocC:\cygwin64\home\username\sourcecode\COMJurer\build\generated\src\main\com4j\com\app\com4j\api\ClassFactory.java:15: warning: no @return
  public static com.app.com4j.api.IAPI createAPI() {
                                                     ^
C:\cygwin64\home\username\sourcecode\COMJurer\build\generated\src\main\com4j\com\app\com4j\api\IAPI.java:99: error: malformed HTML
   * @param xmlReturn Mandatory Holder<java.lang.String> parameter.
                                  ^
 C:\cygwin64\home\username\sourcecode\COMJurer\build\generated\src\main\com4j\com\app\com4j\api\IAPI.java:99: error: bad use of '>'
   * @param xmlReturn Mandatory Holder<java.lang.String> parameter.
                                                   ^

2 errors
1 warning
:javadoc FAILED

gradles documentation is lacking any specifics: https://docs.gradle.org/current/dsl/org.gradle.api.tasks.javadoc.Javadoc.html

like image 930
mrt181 Avatar asked Dec 07 '17 12:12

mrt181


People also ask

How do I exclude tasks in Gradle?

Using Command Line Flags Task :compileTestJava > Task :processTestResources NO-SOURCE > Task :testClasses > Task :test > ... To skip any task from the Gradle build, we can use the -x or –exclude-task option. In this case, we'll use “-x test” to skip tests from the build.

What is Gradle Javadoc?

Generating Javadocs Applying the Java plugin to a Gradle build script automatically provides a task for generating Javadocs out-of-the-box. That task is called javadoc , takes the compiled source code from the main source set as input and builds a set of HTML pages as output.


1 Answers

The problem is that your pattern refers to the path of the source directory.

Javadoc patterns are matched against the package of the classes.

So you need instead to use a pattern that refers to the package(s) you need to exclude, something like:

exclude 'com/app/com4j/api/**'
like image 112
Louis Jacomet Avatar answered Oct 21 '22 08:10

Louis Jacomet