简体   繁体   中英

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

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/**'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM