Add comments and fix Javadoc generation

This commit is contained in:
JeremyStar™ 2024-07-11 04:03:08 +02:00
parent 34e60b06dc
commit fa3d2ec19d
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
13 changed files with 247 additions and 68 deletions

View file

@ -17,6 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
// Plugins
plugins { plugins {
id("java") id("java")
id("io.freefair.lombok") version("${pluginLombok}") id("io.freefair.lombok") version("${pluginLombok}")
@ -24,6 +25,7 @@ plugins {
id("maven-publish") id("maven-publish")
} }
// Project dependencies
dependencies { dependencies {
// -> Runtime <- // -> Runtime <-
// Lombok // Lombok
@ -52,16 +54,18 @@ dependencies {
testImplementation("org.jooq:joor:${dependencyJoor}") testImplementation("org.jooq:joor:${dependencyJoor}")
} }
// Git properties configuration
// Allows us to embed git commit information in the engine build
gitProperties { gitProperties {
dotGitDirectory = file("${rootProject.rootDir}/.git") dotGitDirectory = file("${rootProject.rootDir}/.git")
failOnNoGitDirectory = false failOnNoGitDirectory = false // Allow continuing if .git directory is missing for the few who use tarballs
extProperty = "gitProps" extProperty = "gitProps"
dateFormat = "yyyy-MM-dd'T'HH:mmZ" dateFormat = "yyyy-MM-dd'T'HH:mmZ"
dateFormatTimeZone = "UTC" dateFormatTimeZone = "UTC"
} }
tasks.register("writeGitProperties") { tasks.register("writeGitProperties") { // This task's only purpose is to copy the git.properties from our git properties plugin to the resources directory so it's included in the final build
doLast { doLast {
File target = file("${project.projectDir}/src/main/resources/git.properties") File target = file("${project.projectDir}/src/main/resources/git.properties")
File source = file("${project.projectDir}/build/resources/main/git.properties") File source = file("${project.projectDir}/build/resources/main/git.properties")
@ -70,21 +74,50 @@ tasks.register("writeGitProperties") {
source.renameTo(target) source.renameTo(target)
} }
outputs.upToDateWhen({ false }) outputs.upToDateWhen({ false }) // Force task execution
} }
generateGitProperties.outputs.upToDateWhen({ false }) generateGitProperties.outputs.upToDateWhen({ false }) // Force task execution
processResources.dependsOn(writeGitProperties) processResources.dependsOn(writeGitProperties) // Ensure git.properties file is present
javadoc.options { // Fix delombok task
setMemberLevel(JavadocMemberLevel.PUBLIC) delombok.doFirst {
setOverview("src/main/javadoc/overview.html") File target = file("${project.projectDir}/src/main/module-info.java")
setLocale("en_US") File source = file("${project.projectDir}/src/main/java/module-info.java")
setJFlags([
// Force Javadoc to use English translations target.delete()
"-Duser.language=en_US" source.renameTo(target)
]) }
delombok.doLast {
File target = file("${project.projectDir}/src/main/java/module-info.java")
File source = file("${project.projectDir}/src/main/module-info.java")
target.delete()
source.renameTo(target)
} }
// Javadoc configuration
javadoc {
outputs.upToDateWhen { false } // Force task execution
dependsOn(delombok) // Make sure the source is delomboked first
javadoc {
setClasspath(files(project.sourceSets.main.compileClasspath)) // Include dependencies
options {
if (new File(projectDir, "src/main/javadoc/theme.css").exists())
stylesheetFile = new File(projectDir, "src/main/javadoc/theme.css") // Theming is cool :3
setMemberLevel(JavadocMemberLevel.PUBLIC) // Only display public stuff
setOverview("src/main/javadoc/overview.html") // We want a custom overview page to greet the visitor
setLocale("en_US") //
setJFlags([
"-Duser.language=en_US" // See above
])
}
}
}
// Unit testing configuration
test { test {
useJUnitPlatform() useJUnitPlatform()
testLogging { testLogging {
@ -92,6 +125,8 @@ test {
} }
} }
// Build publishing configuration
// Note: You can safely ignore any errors or warnings thrown by your IDE here
publishing { publishing {
repositories { repositories {
maven { maven {

View file

@ -0,0 +1 @@
../../../../src/main/javadoc/theme.css

View file

@ -17,19 +17,26 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
// Plugins
plugins { plugins {
id("java") id("java")
id("io.freefair.lombok") version("${pluginLombok}") id("io.freefair.lombok") version("${pluginLombok}")
id("maven-publish") id("maven-publish")
} }
// Register task for Javadoc generation for all subsystems
tasks.register("javadocAll", Javadoc) { tasks.register("javadocAll", Javadoc) {
// Task metadata
setDescription("Generates Javadoc API documentation for all subprojects.") setDescription("Generates Javadoc API documentation for all subprojects.")
setGroup("documentation") setGroup("documentation")
dependsOn(delombok) // Make sure the source is delomboked first
def subprojects= [ def subprojects= [
":base", ":base",
":testapp", ":graphics",
":graphics:opengl",
":graphics:vulkan",
":slf4j-compat",
] ]
setSource(subprojects.collect({ project(it).sourceSets.main.allJava })) setSource(subprojects.collect({ project(it).sourceSets.main.allJava }))
@ -37,18 +44,19 @@ tasks.register("javadocAll", Javadoc) {
setDestinationDir(file("build/docs/javadoc")) setDestinationDir(file("build/docs/javadoc"))
options { options {
setMemberLevel(JavadocMemberLevel.PUBLIC) if (new File(projectDir, "src/main/javadoc/theme.css").exists())
setOverview("src/main/javadoc/overview.html") stylesheetFile = new File(projectDir, "src/main/javadoc/theme.css") // Theming is cool :3
setLocale("en_US") setMemberLevel(JavadocMemberLevel.PUBLIC) // Only display public stuff
setOverview("src/main/javadoc/overview.html") // We want a custom overview page to greet the visitor
setLocale("en_US") //
setJFlags([ setJFlags([
// Force Javadoc to use English translations "-Duser.language=en_US" // See above
"-Duser.language=en_US"
]) ])
} }
dependsOn(delombok)
} }
// Set group, version and repositories for all projects
allprojects { allprojects {
group = project.group group = project.group
version = project.versioningVersion + "-" + project.versioningType + project.versioningTyperelease + project.versioningFork version = project.versioningVersion + "-" + project.versioningType + project.versioningTyperelease + project.versioningFork

View file

@ -17,11 +17,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
// Plugins
plugins { plugins {
id("java") id("java")
id("io.freefair.lombok") version("${pluginLombok}") id("io.freefair.lombok") version("${pluginLombok}")
} }
// Dependencies
dependencies { dependencies {
// -> Runtime <- // -> Runtime <-
// Lombok // Lombok
@ -48,16 +50,45 @@ dependencies {
implementation("org.fusesource.jansi:jansi:${dependencyJansi}") // for some reason required or the build fails don"t ask me why implementation("org.fusesource.jansi:jansi:${dependencyJansi}") // for some reason required or the build fails don"t ask me why
} }
javadoc.options { // Fix delombok task
setMemberLevel(JavadocMemberLevel.PUBLIC) delombok.doFirst {
setOverview("src/main/javadoc/overview.html") File target = file("${project.projectDir}/src/main/module-info.java")
setLocale("en_US") File source = file("${project.projectDir}/src/main/java/module-info.java")
setJFlags([
// Force Javadoc to use English translations target.delete()
"-Duser.language=en_US" source.renameTo(target)
]) }
delombok.doLast {
File target = file("${project.projectDir}/src/main/java/module-info.java")
File source = file("${project.projectDir}/src/main/module-info.java")
target.delete()
source.renameTo(target)
} }
// Javadoc configuration
javadoc {
outputs.upToDateWhen { false } // Force task execution
dependsOn(delombok) // Make sure the source is delomboked first
javadoc {
setClasspath(files(project.sourceSets.main.compileClasspath)) // Include dependencies
options {
if (new File(projectDir, "src/main/javadoc/theme.css").exists())
stylesheetFile = new File(projectDir, "src/main/javadoc/theme.css") // Theming is cool :3
setMemberLevel(JavadocMemberLevel.PUBLIC) // Only display public stuff
setOverview("src/main/javadoc/overview.html") // We want a custom overview page to greet the visitor
setLocale("en_US") //
setJFlags([
"-Duser.language=en_US" // See above
])
}
}
}
// Unit testing configuration
test { test {
useJUnitPlatform() useJUnitPlatform()
testLogging { testLogging {

View file

@ -19,12 +19,13 @@
import org.gradle.internal.os.OperatingSystem import org.gradle.internal.os.OperatingSystem
// Plugins
plugins { plugins {
id("java") id("java")
id("io.freefair.lombok") version("${pluginLombok}") id("io.freefair.lombok") version("${pluginLombok}")
} }
// Determine LWJGL native stuff // Determine operating system and architecture
switch (OperatingSystem.current()) { switch (OperatingSystem.current()) {
case OperatingSystem.LINUX: case OperatingSystem.LINUX:
project.dependencyLwjglNatives = "natives-linux" project.dependencyLwjglNatives = "natives-linux"
@ -48,6 +49,7 @@ switch (OperatingSystem.current()) {
break break
} }
// Dependencies
dependencies { dependencies {
// -> Runtime <- // -> Runtime <-
// Lombok // Lombok
@ -98,16 +100,45 @@ dependencies {
implementation("org.fusesource.jansi:jansi:${dependencyJansi}") // for some reason required or the build fails don"t ask me why implementation("org.fusesource.jansi:jansi:${dependencyJansi}") // for some reason required or the build fails don"t ask me why
} }
javadoc.options { // Fix delombok task
setMemberLevel(JavadocMemberLevel.PUBLIC) delombok.doFirst {
setOverview("src/main/javadoc/overview.html") File target = file("${project.projectDir}/src/main/module-info.java")
setLocale("en_US") File source = file("${project.projectDir}/src/main/java/module-info.java")
setJFlags([
// Force Javadoc to use English translations target.delete()
"-Duser.language=en_US" source.renameTo(target)
]) }
delombok.doLast {
File target = file("${project.projectDir}/src/main/java/module-info.java")
File source = file("${project.projectDir}/src/main/module-info.java")
target.delete()
source.renameTo(target)
} }
// Javadoc configuration
javadoc {
outputs.upToDateWhen { false } // Force task execution
dependsOn(delombok) // Make sure the source is delomboked first
javadoc {
setClasspath(files(project.sourceSets.main.compileClasspath)) // Include dependencies
options {
if (new File(projectDir, "src/main/javadoc/theme.css").exists())
stylesheetFile = new File(projectDir, "src/main/javadoc/theme.css") // Theming is cool :3
setMemberLevel(JavadocMemberLevel.PUBLIC) // Only display public stuff
setOverview("src/main/javadoc/overview.html") // We want a custom overview page to greet the visitor
setLocale("en_US") //
setJFlags([
"-Duser.language=en_US" // See above
])
}
}
}
// Unit testing configuration
test { test {
useJUnitPlatform() useJUnitPlatform()
testLogging { testLogging {

View file

@ -0,0 +1 @@
../../../../../src/main/javadoc/theme.css

View file

@ -0,0 +1 @@
../../../../src/main/javadoc/theme.css

View file

@ -19,12 +19,13 @@
import org.gradle.internal.os.OperatingSystem import org.gradle.internal.os.OperatingSystem
// Plugins
plugins { plugins {
id("java") id("java")
id("io.freefair.lombok") version("${pluginLombok}") id("io.freefair.lombok") version("${pluginLombok}")
} }
// Determine LWJGL native stuff // Determine operating system and architecture
switch (OperatingSystem.current()) { switch (OperatingSystem.current()) {
case OperatingSystem.LINUX: case OperatingSystem.LINUX:
project.dependencyLwjglNatives = "natives-linux" project.dependencyLwjglNatives = "natives-linux"
@ -48,6 +49,7 @@ switch (OperatingSystem.current()) {
break break
} }
// Dependencies
dependencies { dependencies {
// -> Runtime <- // -> Runtime <-
// Lombok // Lombok
@ -95,16 +97,45 @@ dependencies {
implementation("org.fusesource.jansi:jansi:${dependencyJansi}") // for some reason required or the build fails don"t ask me why implementation("org.fusesource.jansi:jansi:${dependencyJansi}") // for some reason required or the build fails don"t ask me why
} }
javadoc.options { // Fix delombok task
setMemberLevel(JavadocMemberLevel.PUBLIC) delombok.doFirst {
setOverview("src/main/javadoc/overview.html") File target = file("${project.projectDir}/src/main/module-info.java")
setLocale("en_US") File source = file("${project.projectDir}/src/main/java/module-info.java")
setJFlags([
// Force Javadoc to use English translations target.delete()
"-Duser.language=en_US" source.renameTo(target)
]) }
delombok.doLast {
File target = file("${project.projectDir}/src/main/java/module-info.java")
File source = file("${project.projectDir}/src/main/module-info.java")
target.delete()
source.renameTo(target)
} }
// Javadoc configuration
javadoc {
outputs.upToDateWhen { false } // Force task execution
dependsOn(delombok) // Make sure the source is delomboked first
javadoc {
setClasspath(files(project.sourceSets.main.compileClasspath)) // Include dependencies
options {
if (new File(projectDir, "src/main/javadoc/theme.css").exists())
stylesheetFile = new File(projectDir, "src/main/javadoc/theme.css") // Theming is cool :3
setMemberLevel(JavadocMemberLevel.PUBLIC) // Only display public stuff
setOverview("src/main/javadoc/overview.html") // We want a custom overview page to greet the visitor
setLocale("en_US") //
setJFlags([
"-Duser.language=en_US" // See above
])
}
}
}
// Unit testing configuration
test { test {
useJUnitPlatform() useJUnitPlatform()
testLogging { testLogging {

View file

@ -0,0 +1 @@
../../../../../src/main/javadoc/theme.css

View file

@ -17,12 +17,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
// Plugins
plugins { plugins {
id("java") id("java")
id("io.freefair.lombok") version("${pluginLombok}") id("io.freefair.lombok") version("${pluginLombok}")
id("maven-publish") id("maven-publish")
} }
// Dependencies
dependencies { dependencies {
// -> Runtime <- // -> Runtime <-
// Lombok // Lombok
@ -40,23 +42,46 @@ dependencies {
implementation("org.fusesource.jansi:jansi:${dependencyJansi}") // for some reason required or the build fails don"t ask me why implementation("org.fusesource.jansi:jansi:${dependencyJansi}") // for some reason required or the build fails don"t ask me why
} }
javadoc.options { // Fix delombok task
setMemberLevel(JavadocMemberLevel.PUBLIC) delombok.doFirst {
setOverview("src/main/javadoc/overview.html") File target = file("${project.projectDir}/src/main/module-info.java")
setLocale("en_US") File source = file("${project.projectDir}/src/main/java/module-info.java")
setJFlags([
// Force Javadoc to use English translations target.delete()
"-Duser.language=en_US" source.renameTo(target)
]) }
delombok.doLast {
File target = file("${project.projectDir}/src/main/java/module-info.java")
File source = file("${project.projectDir}/src/main/module-info.java")
target.delete()
source.renameTo(target)
} }
test { // Javadoc configuration
useJUnitPlatform() javadoc {
testLogging { outputs.upToDateWhen { false } // Force task execution
events("passed", "skipped", "failed") dependsOn(delombok) // Make sure the source is delomboked first
javadoc {
setClasspath(files(project.sourceSets.main.compileClasspath)) // Include dependencies
options {
if (new File(projectDir, "src/main/javadoc/theme.css").exists())
stylesheetFile = new File(projectDir, "src/main/javadoc/theme.css") // Theming is cool :3
setMemberLevel(JavadocMemberLevel.PUBLIC) // Only display public stuff
setOverview("src/main/javadoc/overview.html") // We want a custom overview page to greet the visitor
setLocale("en_US") //
setJFlags([
"-Duser.language=en_US" // See above
])
}
} }
} }
// Build publishing configuration
// Note: You can safely ignore any errors or warnings thrown by your IDE here
publishing { publishing {
repositories { repositories {
maven { maven {

View file

@ -0,0 +1 @@
../../../../src/main/javadoc/theme.css

View file

@ -0,0 +1 @@

View file

@ -17,6 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
// Plugins
plugins { plugins {
id("java") id("java")
id "application" id "application"
@ -25,6 +26,7 @@ plugins {
id('org.mikeneck.graalvm-native-image') version("${pluginNativeImage}") id('org.mikeneck.graalvm-native-image') version("${pluginNativeImage}")
} }
// Dependencies
dependencies { dependencies {
// -> Runtime <- // -> Runtime <-
// Lombok // Lombok
@ -43,16 +45,23 @@ dependencies {
implementation("org.fusesource.jansi:jansi:${dependencyJansi}") // for some reason required or the build fails don"t ask me why implementation("org.fusesource.jansi:jansi:${dependencyJansi}") // for some reason required or the build fails don"t ask me why
} }
javadoc.options { // Fix delombok task
setMemberLevel(JavadocMemberLevel.PUBLIC) delombok.doFirst {
setOverview("src/main/javadoc/overview.html") File target = file("${project.projectDir}/src/main/module-info.java")
setLocale("en_US") File source = file("${project.projectDir}/src/main/java/module-info.java")
setJFlags([
// Force Javadoc to use English translations target.delete()
"-Duser.language=en_US" source.renameTo(target)
]) }
delombok.doLast {
File target = file("${project.projectDir}/src/main/java/module-info.java")
File source = file("${project.projectDir}/src/main/module-info.java")
target.delete()
source.renameTo(target)
} }
// Configure output jar
jar { jar {
manifest { manifest {
attributes( attributes(
@ -61,9 +70,10 @@ jar {
} }
} }
// Configure application run task
application { application {
mainClass.set("de.staropensource.sosengine.testapp.Main") mainClass.set("de.staropensource.sosengine.testapp.Main")
applicationDefaultJvmArgs = [ applicationDefaultJvmArgs = [ // List of nice development configuration overrides
// Set log level to DIAGNOSTIC // Set log level to DIAGNOSTIC
"-Dsosengine.base.loggerLevel=diagnostic", "-Dsosengine.base.loggerLevel=diagnostic",
@ -75,6 +85,7 @@ application {
] ]
} }
// GraalVM native-image plugin configuration
nativeImage { nativeImage {
graalVmHome = project.hasProperty("graalHome") ? project.property("graalHome") as String : System.getProperty("java.home") graalVmHome = project.hasProperty("graalHome") ? project.property("graalHome") as String : System.getProperty("java.home")
mainClass = "de.staropensource.sosengine.testapp.Main" mainClass = "de.staropensource.sosengine.testapp.Main"
@ -87,6 +98,7 @@ nativeImage {
} }
} }
// Register task for executing the generated binary
tasks.register('runNativeimage', Exec) { tasks.register('runNativeimage', Exec) {
dependsOn(nativeImage) dependsOn(nativeImage)
executable("build/bin/sosengine-testapp") executable("build/bin/sosengine-testapp")