Gradle cannot execute the javadoc task when the my project requires the module Log4j.
Running Gradle 4.8 with Java 10.
Log4j 2 is a Java module, but it doesn’t have the module-info.class at the package root. It is instead placed in META-INF/versions/9.
My module-info.java
module no.djviking.movies {
requires javafx.controls;
requires javafx.fxml;
requires javafx.web;
requires javafx.graphics;
requires org.apache.logging.log4j;
}
Javadoc task fails:
> Task :javadoc FAILED
Task ':javadoc' is not up-to-date because:
Task has failed previously.
Starting process 'command '/usr/java/jdk-10.0.1/bin/javadoc''. Working directory: /home/djviking/workspace/movies Command: /usr/java/jdk-10.0.1/bin/javadoc @/home/djviking/workspace/movies/build/tmp/javadoc/javadoc.options
Successfully started process 'command '/usr/java/jdk-10.0.1/bin/javadoc''
/home/djviking/workspace/movies/src/main/java/module-info.java:15: error: module not found: org.apache.logging.log4j
requires org.apache.logging.log4j;
Building gradle without Javadoc works fine.
Is there something I am missing from my javadoc task configuration?
My build.gradle:
final def log4jGroup = 'org.apache.logging.log4j'
final def log4jVersion = '2.11.0'
final def junitJupiterGroup = 'org.junit.jupiter'
final def junitJupiterVersion = '5.2.0'
final def junitPlatformGroup = 'org.junit.platform'
final def junitPlatformVersion = '1.2.0'
dependencies {
compile group: 'org.controlsfx', name: 'controlsfx', version: '9.0.0'
compile group: 'com.jfoenix', name: 'jfoenix', version: '9.0.4'
compile group: 'org.jfxtras', name: 'jfxtras-controls', version: '9.0-r1'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.0'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.0'
compile group: 'com.lmax', name: 'disruptor', version:'3.3.7'
testCompile group: junitJupiterGroup, name: 'junit-jupiter-api', version: junitJupiterVersion
testRuntime group: junitJupiterGroup, name: 'junit-jupiter-engine', version: junitJupiterVersion
testRuntimeOnly group: junitPlatformGroup, name: 'junit-platform-launcher', version: junitPlatformVersion
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives jar
archives sourcesJar
archives javadocJar
}
compileJava {
inputs.property("moduleName", moduleName)
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
]
classpath = files()
}
}
compileTestJava {
inputs.property("moduleName", moduleName)
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
'--add-modules', 'org.junit.jupiter.api',
'--add-reads', "$moduleName=org.junit.jupiter.api",
'--patch-module', "$moduleName=" + files(sourceSets.test.java.srcDirs).asPath,
]
classpath = files()
}
}
javadoc {
inputs.property("moduleName", moduleName)
doFirst {
options.addStringOption('-module-path', classpath.asPath)
options.addBooleanOption('html5', true)
}
}
test {
useJUnitPlatform()
doFirst {
jvmArgs = [
'--module-path', classpath.asPath
]
}
reports {
html.enabled = true
}
}