Make “gradle javadoc” task work with Java 9

血红的双手。 提交于 2021-02-07 20:58:35

问题


I have a multi-module Gradle Java project using source/target = 1.9/1.9. There are two modules, my.base and my.dependsOnBase. The my.base module has no other dependencies:

module my.base {
    exports my.base.foo;
    exports my.base.bar;
}

The my.dependsOnBase module has only a single dependency, which is my.base:

module my.dependsOnBase {
    requires my.base;
    exports my.dependsOnBase.baz;
}

When I run $ gradle javadoc it works fine on my.base. But when it gets to my.dependsOnBase I get the following error output:

/path/to/my $ gradle javadoc

> Task :dependsOnBase:javadoc FAILED
/path/to/my/dependsOnBase/src/main/java/module-info.java:26: error: module not found: my.base
    requires my.base;
                     ^
1 error


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dependsOnBase:javadoc'.
> Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '/path/to/my/dependsOnBase/build/tmp/javadoc/javadoc.options'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
7 actionable tasks: 3 executed, 4 up-to-date

Earlier in the project I was able to get Java compilation, which suffered a similar problem, working using:

compileJava {
    inputs.property("moduleName", moduleName)
    doFirst {
        options.compilerArgs = [
                '--module-path', classpath.asPath,
        ]
        classpath = files()
    }
}

But those properties aren't directly applicable to the Gradle javadoc task.

How can I get my Javadoc working?


回答1:


This worked for me

javadoc {
  inputs.property("moduleName", moduleName)
  doFirst {
    options.addStringOption('-module-path', classpath.asPath)
  }
}


来源:https://stackoverflow.com/questions/47891643/make-gradle-javadoc-task-work-with-java-9

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