Reorganize build scripts
Some checks failed
build-and-test / build (push) Failing after 37s
build-and-test / generate-javadoc (push) Failing after 39s
build-and-test / test (push) Failing after 44s

This commit is contained in:
JeremyStar™ 2024-10-15 03:36:50 +02:00
parent bed5811b70
commit 6cd38377b2
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
8 changed files with 188 additions and 261 deletions

View file

@ -16,6 +16,7 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* 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 { plugins {
id("java") id("java")
@ -23,9 +24,8 @@ plugins {
id("maven-publish") id("maven-publish")
} }
// Project dependencies // Dependencies
dependencies { dependencies {
// -> Runtime <-
// Lombok // Lombok
compileOnly("org.projectlombok:lombok:${dependencyLombok}") compileOnly("org.projectlombok:lombok:${dependencyLombok}")
annotationProcessor("org.projectlombok:lombok:${dependencyLombok}") annotationProcessor("org.projectlombok:lombok:${dependencyLombok}")
@ -33,36 +33,11 @@ dependencies {
// JetBrains Annotations // JetBrains Annotations
compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}") compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
// ANSI support // Jansi
implementation("org.fusesource.jansi:jansi:${dependencyJansi}") implementation("org.fusesource.jansi:jansi:${dependencyJansi}")
// Project // Project
implementation(project(":base")) implementation(project(":base"))
// -> Testing <-
// Jetbrains Annotations
testCompileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
// JUnit
testImplementation(platform("org.junit:junit-bom:${dependencyJunit}"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
// Fix delombok task
delombok.doFirst {
File target = file("${project.projectDir}/src/main/module-info.java")
File source = file("${project.projectDir}/src/main/java/module-info.java")
target.delete()
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 configuration
@ -88,26 +63,6 @@ javadoc {
} }
} }
// Unit testing configuration
test {
useJUnitPlatform()
// Pass test configuration to test VMs
Map<String, String> testConfiguration = new HashMap<>();
for (String property : project.properties.keySet())
if (property.startsWith("test."))
testConfiguration.put(property, project.properties.get(property).toString())
systemProperties(testConfiguration)
setMaxParallelForks(project.hasProperty("jobs") ? Integer.parseInt((String) project.property("jobs")) : 8)
setForkEvery(1)
setFailFast(true)
testLogging {
events("passed", "skipped", "failed")
}
}
// Include javadoc and source jar during publishing // Include javadoc and source jar during publishing
java { java {
withJavadocJar() withJavadocJar()
@ -139,3 +94,19 @@ publishing {
} }
} }
} }
// Fix delombok task
delombok.doFirst {
File target = file("${project.projectDir}/src/main/module-info.java")
File source = file("${project.projectDir}/src/main/java/module-info.java")
target.delete()
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)
}

View file

@ -26,9 +26,9 @@ plugins {
id("maven-publish") id("maven-publish")
} }
// Project dependencies // Dependencies
dependencies { dependencies {
// -> Runtime <- // -> Runtime
// Lombok // Lombok
compileOnly("org.projectlombok:lombok:${dependencyLombok}") compileOnly("org.projectlombok:lombok:${dependencyLombok}")
annotationProcessor("org.projectlombok:lombok:${dependencyLombok}") annotationProcessor("org.projectlombok:lombok:${dependencyLombok}")
@ -39,7 +39,7 @@ dependencies {
// Reflections // Reflections
implementation("org.reflections:reflections:${dependencyReflections}") implementation("org.reflections:reflections:${dependencyReflections}")
// -> Testing <- // -> Testing
// Jetbrains Annotations // Jetbrains Annotations
testCompileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}") testCompileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
@ -48,65 +48,10 @@ dependencies {
testImplementation("org.junit.jupiter:junit-jupiter") testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher") testRuntimeOnly("org.junit.platform:junit-platform-launcher")
// -> Project <- // Project
testImplementation(project(":testing")) testImplementation(project(":testing"))
} }
// Fix delombok task
delombok.doFirst {
File target = file("${project.projectDir}/src/main/module-info.java")
File source = file("${project.projectDir}/src/main/java/module-info.java")
target.delete()
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)
}
// Copy gradle.properties file
// for inclusion in final build
tasks.register("copyGradleProperties") {
doFirst {
File target = file("${project.projectDir}/src/main/resources/sosengine-gradle.properties")
File source = file(project(":").projectDir.getPath() + "/gradle.properties")
target.delete()
Files.copy(source.toPath(), target.toPath())
}
outputs.upToDateWhen({ false }) // Force task execution
}
processResources.dependsOn(copyGradleProperties)
// Git properties configuration
// Allows us to embed git commit information in the engine build
gitProperties {
dotGitDirectory = file("${rootProject.rootDir}/.git")
failOnNoGitDirectory = false // Allow continuing if .git directory is missing for the few who use tarballs
extProperty = "gitProps"
dateFormat = "yyyy-MM-dd'T'HH:mmZ"
dateFormatTimeZone = "UTC"
}
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 {
File target = file("${project.projectDir}/src/main/resources/sosengine-git.properties")
File source = file("${project.projectDir}/build/resources/main/git.properties")
target.delete()
source.renameTo(target)
}
outputs.upToDateWhen({ false }) // Force task execution
}
generateGitProperties.outputs.upToDateWhen({ false }) // Force task execution
processResources.dependsOn(writeGitProperties) // Ensure git.properties file is present
// Javadoc configuration // Javadoc configuration
javadoc { javadoc {
outputs.upToDateWhen { false } // Force task execution outputs.upToDateWhen { false } // Force task execution
@ -181,3 +126,58 @@ publishing {
} }
} }
} }
// Copy gradle.properties file
// for inclusion in final build
tasks.register("copyGradleProperties") {
doFirst {
File target = file("${project.projectDir}/src/main/resources/sosengine-gradle.properties")
File source = file(project(":").projectDir.getPath() + "/gradle.properties")
target.delete()
Files.copy(source.toPath(), target.toPath())
}
outputs.upToDateWhen({ false }) // Force task execution
}
processResources.dependsOn(copyGradleProperties)
// Git properties configuration
// Allows us to embed git commit information in the engine build
gitProperties {
dotGitDirectory = file("${rootProject.rootDir}/.git")
failOnNoGitDirectory = false // Allow continuing if .git directory is missing for the few who use tarballs
extProperty = "gitProps"
dateFormat = "yyyy-MM-dd'T'HH:mmZ"
dateFormatTimeZone = "UTC"
}
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 {
File target = file("${project.projectDir}/src/main/resources/sosengine-git.properties")
File source = file("${project.projectDir}/build/resources/main/git.properties")
target.delete()
source.renameTo(target)
}
outputs.upToDateWhen({ false }) // Force task execution
}
generateGitProperties.outputs.upToDateWhen({ false }) // Force task execution
processResources.dependsOn(writeGitProperties) // Ensure git.properties file is present
// Fix delombok task
delombok.doFirst {
File target = file("${project.projectDir}/src/main/module-info.java")
File source = file("${project.projectDir}/src/main/java/module-info.java")
target.delete()
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)
}

View file

@ -26,7 +26,6 @@ plugins {
// Dependencies // Dependencies
dependencies { dependencies {
// -> Runtime <-
// Lombok // Lombok
compileOnly("org.projectlombok:lombok:${dependencyLombok}") compileOnly("org.projectlombok:lombok:${dependencyLombok}")
annotationProcessor("org.projectlombok:lombok:${dependencyLombok}") annotationProcessor("org.projectlombok:lombok:${dependencyLombok}")
@ -34,26 +33,10 @@ dependencies {
// JetBrains Annotations // JetBrains Annotations
compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}") compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
// -> Project <- // Project
implementation(project(":base")) implementation(project(":base"))
} }
// Fix delombok task
delombok.doFirst {
File target = file("${project.projectDir}/src/main/module-info.java")
File source = file("${project.projectDir}/src/main/java/module-info.java")
target.delete()
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 configuration
javadoc { javadoc {
outputs.upToDateWhen { false } // Force task execution outputs.upToDateWhen { false } // Force task execution
@ -108,3 +91,19 @@ publishing {
} }
} }
} }
// Fix delombok task
delombok.doFirst {
File target = file("${project.projectDir}/src/main/module-info.java")
File source = file("${project.projectDir}/src/main/java/module-info.java")
target.delete()
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)
}

View file

@ -26,7 +26,6 @@ plugins {
// Dependencies // Dependencies
dependencies { dependencies {
// -> Runtime <-
// Lombok // Lombok
compileOnly("org.projectlombok:lombok:${dependencyLombok}") compileOnly("org.projectlombok:lombok:${dependencyLombok}")
annotationProcessor("org.projectlombok:lombok:${dependencyLombok}") annotationProcessor("org.projectlombok:lombok:${dependencyLombok}")
@ -37,26 +36,10 @@ dependencies {
// SLF4J // SLF4J
implementation("org.slf4j:slf4j-api:${dependencySlf4j}") implementation("org.slf4j:slf4j-api:${dependencySlf4j}")
// -> Project <- // Project
implementation(project(":base")) implementation(project(":base"))
} }
// Fix delombok task
delombok.doFirst {
File target = file("${project.projectDir}/src/main/module-info.java")
File source = file("${project.projectDir}/src/main/java/module-info.java")
target.delete()
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 configuration
javadoc { javadoc {
outputs.upToDateWhen { false } // Force task execution outputs.upToDateWhen { false } // Force task execution
@ -111,3 +94,19 @@ publishing {
} }
} }
} }
// Fix delombok task
delombok.doFirst {
File target = file("${project.projectDir}/src/main/module-info.java")
File source = file("${project.projectDir}/src/main/java/module-info.java")
target.delete()
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)
}

View file

@ -30,7 +30,6 @@ plugins {
// Dependencies // Dependencies
dependencies { dependencies {
// -> Runtime <-
// Lombok // Lombok
compileOnly("org.projectlombok:lombok:${dependencyLombok}") compileOnly("org.projectlombok:lombok:${dependencyLombok}")
annotationProcessor("org.projectlombok:lombok:${dependencyLombok}") annotationProcessor("org.projectlombok:lombok:${dependencyLombok}")
@ -38,11 +37,11 @@ dependencies {
// JetBrains Annotations // JetBrains Annotations
compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}") compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
// -> Project <- // Project
implementation(project(":base")) implementation(project(":base"))
implementation(project(":windowing"))
runtimeOnly(project(":ansi")) runtimeOnly(project(":ansi"))
runtimeOnly(project(":slf4j-compat")) runtimeOnly(project(":slf4j-compat"))
implementation(project(":windowing"))
runtimeOnly(project(":windowing:glfw")) runtimeOnly(project(":windowing:glfw"))
} }

View file

@ -16,6 +16,7 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* 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 { plugins {
id("java") id("java")
@ -23,7 +24,7 @@ plugins {
id("maven-publish") id("maven-publish")
} }
// Project dependencies // Dependencies
dependencies { dependencies {
// Lombok // Lombok
compileOnly("org.projectlombok:lombok:${dependencyLombok}") compileOnly("org.projectlombok:lombok:${dependencyLombok}")
@ -36,26 +37,10 @@ dependencies {
implementation(platform("org.junit:junit-bom:${dependencyJunit}")) implementation(platform("org.junit:junit-bom:${dependencyJunit}"))
implementation("org.junit.jupiter:junit-jupiter") implementation("org.junit.jupiter:junit-jupiter")
// -> Project <- // Project
implementation(project(":base")) implementation(project(":base"))
} }
// Fix delombok task
delombok.doFirst {
File target = file("${project.projectDir}/src/main/module-info.java")
File source = file("${project.projectDir}/src/main/java/module-info.java")
target.delete()
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 configuration
javadoc { javadoc {
outputs.upToDateWhen { false } // Force task execution outputs.upToDateWhen { false } // Force task execution
@ -110,3 +95,19 @@ publishing {
} }
} }
} }
// Fix delombok task
delombok.doFirst {
File target = file("${project.projectDir}/src/main/module-info.java")
File source = file("${project.projectDir}/src/main/java/module-info.java")
target.delete()
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)
}

View file

@ -26,7 +26,6 @@ plugins {
// Dependencies // Dependencies
dependencies { dependencies {
// -> Runtime <-
// Lombok // Lombok
compileOnly("org.projectlombok:lombok:${dependencyLombok}") compileOnly("org.projectlombok:lombok:${dependencyLombok}")
annotationProcessor("org.projectlombok:lombok:${dependencyLombok}") annotationProcessor("org.projectlombok:lombok:${dependencyLombok}")
@ -34,35 +33,10 @@ dependencies {
// JetBrains Annotations // JetBrains Annotations
compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}") compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
// -> Testing <- // Project
// Jetbrains Annotations
testCompileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
// JUnit
testImplementation(platform("org.junit:junit-bom:${dependencyJunit}"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
// -> Project <-
implementation(project(":base")) implementation(project(":base"))
} }
// Fix delombok task
delombok.doFirst {
File target = file("${project.projectDir}/src/main/module-info.java")
File source = file("${project.projectDir}/src/main/java/module-info.java")
target.delete()
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 configuration
javadoc { javadoc {
outputs.upToDateWhen { false } // Force task execution outputs.upToDateWhen { false } // Force task execution
@ -86,26 +60,6 @@ javadoc {
} }
} }
// Unit testing configuration
test {
useJUnitPlatform()
// Pass test configuration to test VMs
Map<String, String> testConfiguration = new HashMap<>();
for (String property : project.properties.keySet())
if (property.startsWith("test."))
testConfiguration.put(property, project.properties.get(property).toString())
systemProperties(testConfiguration)
setMaxParallelForks(project.hasProperty("jobs") ? Integer.parseInt((String) project.property("jobs")) : 8)
setForkEvery(1)
setFailFast(true)
testLogging {
events("passed", "skipped", "failed")
}
}
// Include javadoc and source jar during publishing // Include javadoc and source jar during publishing
java { java {
withJavadocJar() withJavadocJar()
@ -137,3 +91,19 @@ publishing {
} }
} }
} }
// Fix delombok task
delombok.doFirst {
File target = file("${project.projectDir}/src/main/module-info.java")
File source = file("${project.projectDir}/src/main/java/module-info.java")
target.delete()
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)
}

View file

@ -26,32 +26,8 @@ plugins {
id("maven-publish") id("maven-publish")
} }
// Determine operating system and architecture
switch (OperatingSystem.current()) {
case OperatingSystem.LINUX:
project.dependencyLwjglNatives = "natives-linux"
def osArch = System.getProperty("os.arch")
if (osArch.startsWith("arm") || osArch.startsWith("aarch64"))
project.dependencyLwjglNatives += osArch.contains("64") || osArch.startsWith("armv8") ? "-arm64" : "-arm32"
else if (osArch.startsWith("ppc"))
project.dependencyLwjglNatives += "-ppc64le"
else if (osArch.startsWith("riscv"))
project.dependencyLwjglNatives += "-riscv64"
break
case OperatingSystem.MAC_OS:
project.dependencyLwjglNatives = System.getProperty("os.arch").startsWith("aarch64") ? "natives-macos-arm64" : "natives-macos"
break
case OperatingSystem.WINDOWS:
def osArch = System.getProperty("os.arch")
project.dependencyLwjglNatives = osArch.contains("64")
? "natives-windows${osArch.startsWith("aarch64") ? "-arm64" : ""}"
: "natives-windows-x86"
break
}
// Dependencies // Dependencies
dependencies { dependencies {
// -> Runtime <-
// Lombok // Lombok
compileOnly("org.projectlombok:lombok:${dependencyLombok}") compileOnly("org.projectlombok:lombok:${dependencyLombok}")
annotationProcessor("org.projectlombok:lombok:${dependencyLombok}") annotationProcessor("org.projectlombok:lombok:${dependencyLombok}")
@ -69,36 +45,11 @@ dependencies {
runtimeOnly("org.lwjgl:lwjgl-stb::${dependencyLwjglNatives}") runtimeOnly("org.lwjgl:lwjgl-stb::${dependencyLwjglNatives}")
if (project.dependencyLwjglNatives == "natives-macos" || project.dependencyLwjglNatives == "natives-macos-arm64") runtimeOnly("org.lwjgl:lwjgl-vulkan::${dependencyLwjglNatives}") if (project.dependencyLwjglNatives == "natives-macos" || project.dependencyLwjglNatives == "natives-macos-arm64") runtimeOnly("org.lwjgl:lwjgl-vulkan::${dependencyLwjglNatives}")
// -> Testing <- // Project
// Jetbrains Annotations
testCompileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
// JUnit
testImplementation(platform("org.junit:junit-bom:${dependencyJunit}"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
// -> Project <-
implementation(project(":base")) implementation(project(":base"))
implementation(project(":windowing")) implementation(project(":windowing"))
} }
// Fix delombok task
delombok.doFirst {
File target = file("${project.projectDir}/src/main/module-info.java")
File source = file("${project.projectDir}/src/main/java/module-info.java")
target.delete()
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 configuration
javadoc { javadoc {
outputs.upToDateWhen { false } // Force task execution outputs.upToDateWhen { false } // Force task execution
@ -173,3 +124,40 @@ publishing {
} }
} }
} }
// Determine operating system and architecture
switch (OperatingSystem.current()) {
case OperatingSystem.LINUX -> {
project.dependencyLwjglNatives = "natives-linux"
def osArch = System.getProperty("os.arch")
if (osArch.startsWith("arm") || osArch.startsWith("aarch64"))
project.dependencyLwjglNatives += osArch.contains("64") || osArch.startsWith("armv8") ? "-arm64" : "-arm32"
else if (osArch.startsWith("ppc"))
project.dependencyLwjglNatives += "-ppc64le"
else if (osArch.startsWith("riscv"))
project.dependencyLwjglNatives += "-riscv64"
}
case OperatingSystem.MAC_OS -> project.dependencyLwjglNatives = System.getProperty("os.arch").startsWith("aarch64") ? "natives-macos-arm64" : "natives-macos"
case OperatingSystem.WINDOWS -> {
def osArch = System.getProperty("os.arch")
project.dependencyLwjglNatives = osArch.contains("64")
? "natives-windows${osArch.startsWith("aarch64") ? "-arm64" : ""}"
: "natives-windows-x86"
}
}
// Fix delombok task
delombok.doFirst {
File target = file("${project.projectDir}/src/main/module-info.java")
File source = file("${project.projectDir}/src/main/java/module-info.java")
target.delete()
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)
}