/* * STAROPENSOURCE ENGINE SOURCE FILE * Copyright (c) 2024 The StarOpenSource Engine Authors * Licensed under the GNU General Public License v3. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.gradle.DokkaTask import org.jetbrains.kotlin.gradle.dsl.JvmTarget import java.net.URI import java.nio.file.Files import java.nio.file.LinkOption /* * STAROPENSOURCE ENGINE SOURCE FILE * Copyright (c) 2024 The StarOpenSource Engine Authors * Licensed under the GNU Affero General Public License v3 * with an exception allowing classpath linking. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ // Plugins plugins { id("java-library") id("maven-publish") // Kotlin support id("org.jetbrains.kotlin.jvm") version("2.0.0") // Dokka id("org.jetbrains.dokka") version("1.9.20") // Git properties id("com.gorylenko.gradle-git-properties") version("2.4.2") } allprojects { // Plugins apply(plugin = "java") apply(plugin = "java-library") apply(plugin = "maven-publish") apply(plugin = "org.jetbrains.kotlin.jvm") apply(plugin = "org.jetbrains.dokka") apply(plugin = "com.gorylenko.gradle-git-properties") // Version version = "${property("versionRelease") as String}-${property("versionType") as String}${property("versionTyperelease") as String}" if (property("versionFork") != "") version = "${version as String}-${property("versionFork") as String}" if (property("versionCompanion") != "") version = "${version as String}+${property("versionCompanion") as String}" // Repositories repositories { mavenLocal() mavenCentral() } // Dependencies dependencies { // Kotlin support kotlin(property("dependencyKotlin_StdIdentifier") as String) kotlin(property("dependencyKotlin_StdLibIdentifier") as String) implementation("${property("dependencyKotlin_ReflectIdentifier") as String}:${property("dependencyKotlinVersion") as String}") implementation("${property("dependencyKotlin_DateTimeIdentifier") as String}:${property("dependencyKotlin_DateTimeVersion") as String}") // Unit testing // -> Kotlin testImplementation(kotlin("test")) // -> JUnit testImplementation(platform("${property("testDependencyJUnit_BOMIdentifier")}:${property("testDependencyJUnitVersion")}")) testImplementation("${property("testDependencyJUnit_JupiterIdentifier")}") testRuntimeOnly("${property("testDependencyJUnit_PlatformIdentifier")}") // -> sos!engine testImplementation(project(":testing")) } // Java java { // Java version sourceCompatibility = JavaVersion.toVersion(property("languageJava") as String) targetCompatibility = JavaVersion.toVersion(property("languageJava") as String) if (!(hasProperty("java.skipToolchainSpecification") && property("java.skipToolchainSpecification") as String == "true")) toolchain { languageVersion = JavaLanguageVersion.of(property("languageJava") as String) } } // Kotlin kotlin.compilerOptions { // Configuration progressiveMode = true allWarningsAsErrors = true verbose = true // Set target metadata jvmTarget = JvmTarget.fromTarget(property("languageJava") as String) } // Unit testing // -> Configure Gradle to use JUnit tasks.test { useJUnitPlatform() testLogging { events( "passed", "skipped", "failed" ) } maxParallelForks = 1 } // Dokka // -> Register jar generation tasks // See https://kotlinlang.org/docs/dokka-gradle.html#build-javadoc-jar tasks.register("dokkaHtmlJar") { dependsOn(tasks.dokkaHtml) from(tasks.dokkaHtml.flatMap { it.outputDirectory }) archiveClassifier.set("html-docs") } tasks.register("dokkaJavadocJar") { dependsOn(tasks.dokkaJavadoc) from(tasks.dokkaJavadoc.flatMap { it.outputDirectory }) archiveClassifier.set("javadoc") } // -> Configure Dokka tasks.withType().configureEach { // Styling val dokkaBaseConfiguration = """ { "_customAssets": ["${file("assets/my-image.png")}"], "_customStyleSheets": ["${file("assets/my-styles.css")}"], "footerMessage": "© 2024 The StarOpenSource Engine Authors. Licensed under the GNU Affero General Public License v3", "_separateInheritedMembers": false, "_templatesDir": "${file("dokka/templates")}", "_mergeImplicitExpectActualDeclarations": false } """ pluginsMapConfiguration = mapOf( "org.jetbrains.dokka.base.DokkaBase" to dokkaBaseConfiguration ) // Configuration moduleName = rootProject.name moduleVersion = "v" + rootProject.version as String failOnWarning = true suppressObviousFunctions = true suppressInheritedMembers = true dokkaSourceSets.configureEach { // Metadata displayName = project.name documentedVisibilities = setOf(DokkaConfiguration.Visibility.PUBLIC, DokkaConfiguration.Visibility.PROTECTED) reportUndocumented = false skipEmptyPackages = false skipDeprecated = false jdkVersion = 21 // Source link sourceLink { localDirectory = projectDir.resolve("src") remoteUrl = URI("https://git.staropensource.de/StarOpenSource/Engine/src/branch/develop/" + project.name.replace(":", "/") + "/src").toURL() remoteLineSuffix = "#L" } } } // Git properties // -> Configure gitProperties { dotGitDirectory = file("${rootProject.rootDir}/.git") failOnNoGitDirectory = false // Allow continuing if .git directory is missing (tarball) extProperty = "git" dateFormat = "yyyy-MM-dd'T'HH:mm:ss.S'Z'" dateFormatTimeZone = "UTC" } // -> Copy task tasks.register("copyGitProperties") { dependsOn(tasks.generateGitProperties) inputs.file("${project.projectDir}/build/resources/main/git.properties") doLast { if (rootProject == project) return@doLast file(inputs.files.first()) .copyTo( file("${project.projectDir}/src/main/resources/sosengine-${project.name.replace(":", "-")}-git.properties"), overwrite = true ) } } tasks.processResources { dependsOn(tasks["copyGitProperties"]) } // Gradle properties // -> Copy task tasks.register("copyGradleProperties") { inputs.file("${project(":").projectDir.path}/gradle.properties") doLast { if (rootProject == project) return@doLast file(inputs.files.first()) .copyTo( file("${project.projectDir}/src/main/resources/sosengine-${project.name.replace(":", "-")}-gradle.properties"), overwrite = true ) } } tasks.processResources { dependsOn(tasks["copyGradleProperties"]) } }