Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable all JavaDoc in Gradle

Tags:

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.

like image 357
Peter Avatar asked Jan 19 '16 10:01

Peter


1 Answers

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 }
}
like image 178
Stanislav Avatar answered Oct 10 '22 01:10

Stanislav