25

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.

Community
  • 1
  • 1
Peter
  • 1,844
  • 2
  • 31
  • 55

3 Answers3

59

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 }
}
Stanislav
  • 27,441
  • 9
  • 87
  • 82
  • Well it's kind of a sub-project that I should build without the rest, I only have dependencies on the same level, but the hint so far is not bad :) – Peter Jan 19 '16 at 10:44
  • Hm, could you provide an example of your project structure, with the location of the roo folder, settings.gradle file and some of the build.gradle files? `subprojects` should be used in the root build.gradle script – Stanislav Jan 19 '16 at 12:06
  • I want to build my subproject only, not the whole project, therefore it has it's own `build.gradle` – Peter Jan 19 '16 at 12:30
  • If you have to understand, that according to the build lifecycle, configuration of the root project (build.gradle file on the root folder) is always executed, even if you run only some subproject's task – Stanislav Jan 19 '16 at 13:02
  • In your case, I don't see any settings.gradle file, which should represent a subprojects... – Stanislav Jan 19 '16 at 13:04
  • It works placing it in the root directory. Now I can continue the same Problem with Tests... Thank you :) – Peter Jan 19 '16 at 13:09
16

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.

jgibson
  • 1,013
  • 11
  • 9
  • 1
    To be specific this won't "ignore" errors. It will downgrade them to warnings. So if you are failing the build on warnings, like this https://stackoverflow.com/a/33153700/1650674, then this will still fail the build. – tir38 Mar 01 '18 at 22:19
  • Worked for me !! thanks @jbibson – Pratik Bhandari Feb 15 '22 at 05:21
7

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
Asaf Pinhassi
  • 15,177
  • 12
  • 106
  • 130
  • 4
    for me, l added this code under allprojects {...} in the build.gradle when l had this error in a reactnative project – CanCoder Oct 13 '20 at 19:38