Fix javadocAll task

This commit is contained in:
JeremyStar™ 2024-07-11 22:56:50 +02:00
parent bfbe0b0053
commit 19a87aee94
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -26,12 +26,8 @@ plugins {
// Register task for Javadoc generation for all subsystems
tasks.register("javadocAll", Javadoc) {
// Task metadata
setDescription("Generates Javadoc API documentation for all subprojects.")
setGroup("documentation")
dependsOn(delombok) // Make sure the source is delomboked first
def subprojects= [
// Subprojects to document
def subprojects = [
":base",
":graphics",
":graphics:opengl",
@ -39,7 +35,16 @@ tasks.register("javadocAll", Javadoc) {
":slf4j-compat",
]
setSource(subprojects.collect({ project(it).sourceSets.main.allJava }))
// Task metadata
setDescription("Generates Javadoc API documentation for all subprojects.")
setGroup("documentation")
// Make sure the source is delomboked first
for (String subproject : subprojects)
dependsOn(project(subproject).delombok)
// Set output directory, source and classpath
setSource(subprojects.collect({ project(it).projectDir.getPath() + "/build/generated/sources/delombok/java/main/" }))
setClasspath(files(subprojects.collect({ project(it).sourceSets.main.compileClasspath })))
setDestinationDir(file("build/docs/javadoc"))
@ -54,6 +59,34 @@ tasks.register("javadocAll", Javadoc) {
"-Duser.language=en_US" // See above
])
}
// Fix module collisions
doFirst {
logger.log(LogLevel.WARN, "If this task fails, make sure to reset all module-info.java files using git or you may have issues.")
for (String subproject : subprojects) {
File source = new File(project(subproject).projectDir.getPath() + "/src/main/java/module-info.java");
File target = new File(project(subproject).projectDir.getPath() + "/src/main/module-info.java")
if (source.exists()) {
target.delete()
source.renameTo(target)
}
}
}
doLast {
for (String subproject : subprojects) {
File source = new File(project(subproject).projectDir.getPath() + "/src/main/module-info.java");
File target = new File(project(subproject).projectDir.getPath() + "/src/main/java/module-info.java")
if (source.exists()) {
target.delete()
source.renameTo(target)
}
}
}
// Force doLast block to execute even if task failed
}
// Set group, version and repositories for all projects