From 2629e940e781ab3e13bfde5b79d71a2982d9b7c0 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Wed, 18 Dec 2024 17:41:53 +0100 Subject: [PATCH] Add git and gradle build information --- base/src/main/resources/.gitignore | 2 + build.gradle.kts | 66 +++++++++++++++---- .../src/main/resources/.gitignore | 2 + testapp/src/main/resources/.gitignore | 2 + testing/src/main/resources/.gitignore | 2 + 5 files changed, 63 insertions(+), 11 deletions(-) create mode 100644 base/src/main/resources/.gitignore create mode 100644 dist/template-subproject/src/main/resources/.gitignore create mode 100644 testapp/src/main/resources/.gitignore create mode 100644 testing/src/main/resources/.gitignore diff --git a/base/src/main/resources/.gitignore b/base/src/main/resources/.gitignore new file mode 100644 index 000000000..c9790e6ce --- /dev/null +++ b/base/src/main/resources/.gitignore @@ -0,0 +1,2 @@ +sosengine-*-git.properties +sosengine-*-gradle.properties diff --git a/build.gradle.kts b/build.gradle.kts index 32426cba8..6d96d0365 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,6 +2,8 @@ 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 @@ -115,6 +117,21 @@ allprojects { jvmTarget = JvmTarget.valueOf("JVM_${property("java") 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 @@ -173,18 +190,45 @@ allprojects { } } - // Unit testing - // -> Configure Gradle to use JUnit - tasks.test { - useJUnitPlatform() + // 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:mmZ" + dateFormatTimeZone = "UTC" + } + // -> Copy task + tasks.register("copyGitProperties") { + dependsOn(tasks.generateGitProperties) - testLogging { - events( - "passed", - "skipped", - "failed" - ) + doLast { + val target: File = file("${project.projectDir}/src/main/resources/sosengine-${project.name.replace(":", "-")}-git.properties") + val source: File = file("${project.projectDir}/build/resources/main/git.properties") + + if (Files.exists(target.toPath(), LinkOption.NOFOLLOW_LINKS)) + Files.delete(target.toPath()) + Files.move(source.toPath(), target.toPath()) } - maxParallelForks = 1 + } + tasks.processResources { + dependsOn(tasks["copyGitProperties"]) + } + + // Gradle properties + // -> Copy task + tasks.register("copyGradleProperties") { + doLast { + val target: File = file("${project.projectDir}/src/main/resources/sosengine-${project.name.replace(":", "-")}-gradle.properties") + val source: File = file("${project(":").projectDir.path}/gradle.properties") + + if (Files.exists(target.toPath(), LinkOption.NOFOLLOW_LINKS)) + Files.delete(target.toPath()) + Files.copy(source.toPath(), target.toPath()) + } + } + tasks.processResources { + dependsOn(tasks["copyGradleProperties"]) } } diff --git a/dist/template-subproject/src/main/resources/.gitignore b/dist/template-subproject/src/main/resources/.gitignore new file mode 100644 index 000000000..c9790e6ce --- /dev/null +++ b/dist/template-subproject/src/main/resources/.gitignore @@ -0,0 +1,2 @@ +sosengine-*-git.properties +sosengine-*-gradle.properties diff --git a/testapp/src/main/resources/.gitignore b/testapp/src/main/resources/.gitignore new file mode 100644 index 000000000..c9790e6ce --- /dev/null +++ b/testapp/src/main/resources/.gitignore @@ -0,0 +1,2 @@ +sosengine-*-git.properties +sosengine-*-gradle.properties diff --git a/testing/src/main/resources/.gitignore b/testing/src/main/resources/.gitignore new file mode 100644 index 000000000..c9790e6ce --- /dev/null +++ b/testing/src/main/resources/.gitignore @@ -0,0 +1,2 @@ +sosengine-*-git.properties +sosengine-*-gradle.properties