From 19a87aee948faeb3cc7385516641aaa02e2ba1b7 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Thu, 11 Jul 2024 22:56:50 +0200 Subject: [PATCH] Fix javadocAll task --- build.gradle | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index b8c0baf..6aff4f5 100644 --- a/build.gradle +++ b/build.gradle @@ -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