Disable all JavaDoc in Gradle

只愿长相守 提交于 2019-12-18 11:22:06

问题


General Update, after some research
I want to build my project running gradle 2.0 with gradle build in the console I get stuck at the JavaDoc generation. I'm using Java 8, precisly jdk1.8.0_66 and jre1.8.0_66. Now when I want to build my project typing gradle build in my powershell I get this error:

5 errors
10 warnings
:my-subproject1:javadoc FAILED
    FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':my-subproject1:javadoc'.
> Javadoc generation failed.

One sample error and one sample warning:

C:\some\long\path\MyClass.java:37: error: @param name not found
         * @param appCode
                  ^
C:\some\long\path\MyOtherClass.java:37: warning: no description for @param
         * @param appCode

If I disable one of my subprojects using tasks.findByPath(":my-subproject:javadoc").enabled = false in my build.gradle file I get the same error for the next subproject.
Research has shown that I'm not alone with my problem; Java 8 seems to be really strict with the JavaDoc. This is due to the new doclint for Javadoc. Found on this site. It also provides a solution for Maven and Gradle. But for me it doesn't work, another answer I got doesn't work either. My attempts to solve it look like this right now in my build.gradle for this subproject:

//Solution by the second link
allprojects {
    tasks.withType(Javadoc).all { enabled = false }
}
//Solution by the first link
if (JavaVersion.current().isJava8Compatible()) {
    allprojects {
        tasks.withType(Javadoc) {
            options.addStringOption('Xdoclint:none', '-quiet')
        }
    }
}


dependencies{
    compile project(':my-subproject1')
    compile project(':my-subproject2')
    compile project(':my-subproject3')
}

Does anybody know how to solve this issue or is there another workaround?

Edit:

C:. | Root
├───build.gradle
│   └───2.0
│       └───taskArtifacts
├───buildSrc
│   ├───.gradle
│   │   ├───2.0
│   │   │   └───taskArtifacts
│   │   └───noVersion
│   │       └───buildSrc
│   ├───build
│   │   ├───classes
│   │   │   └───main
│   │   ├───dependency-cache
│   │   ├───libs
│   │   └───tmp
│   └───src
│       └───main
│           └───java
│               └───com
│                   └───custom
│                       └───gradle
│                           └───util
├───my-subproject1
├───my-subproject2
├───my-subproject3
│   ├───my-sub-subproject
│   ├───my-current-directory | Magic happens here
│   │   ├───some.package.identifier
│   │   │   ├───.clover
│   │   │   ├───.settings
│   │   │   ├───bin
│   │   │   │   └───package
│   │   │   │       └───subpackage
│   │   │   └───buil.gradle | This should build my subproject

Solution: Put it in the root build.gradle file.


回答1:


If you have a root project build script, then you can disable all the subprojects's tasks by it's type. In your case, by type Javadoc, like:

subprojects {
    tasks.withType(Javadoc).all { enabled = false }
}



回答2:


I ran into this as well and after digging through Gradle's source code I found a solution that works in Gradle 2.9.

Instead of options.addStringOption('Xdoclint:none', '-quiet') try options.addBooleanOption('Xdoclint:none', true). That should properly pass the -Xdoclint:none option to the underlying javadoc invocation and ignore the errors while still producing Javadoc output. I did this directly in the javadoc task declaration, but it would probably work using the allprojects method that you tried above.




回答3:


This is how I disabled it - in my my build.gradle file I added:

tasks.withType(Javadoc).all { enabled = false } // non ascii characters make it crash


来源:https://stackoverflow.com/questions/34874175/disable-all-javadoc-in-gradle

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