diff --git a/base/src/main/resources/.gitignore b/base/src/main/resources/.gitignore new file mode 100644 index 0000000..c9790e6 --- /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 32426cb..6d96d03 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 0000000..c9790e6 --- /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 0000000..c9790e6 --- /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 0000000..c9790e6 --- /dev/null +++ b/testing/src/main/resources/.gitignore @@ -0,0 +1,2 @@ +sosengine-*-git.properties +sosengine-*-gradle.properties