Engine/testapp/build.gradle

138 lines
4.5 KiB
Groovy
Raw Normal View History

/*
* STAROPENSOURCE ENGINE SOURCE FILE
* Copyright (c) 2024 The StarOpenSource Engine Authors
* Licensed under the GNU Affero General Public License v3
*
* 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 <https://www.gnu.org/licenses/>.
*/
2024-07-11 16:15:47 +02:00
import org.mikeneck.graalvm.BuildTypeSelector
// Plugins
2024-06-08 15:33:03 +02:00
plugins {
2024-07-08 12:39:04 +02:00
id("java")
id("application")
2024-07-08 12:39:04 +02:00
id("io.freefair.lombok") version("${pluginLombok}")
id("io.github.goooler.shadow") version("${pluginShadow}")
2024-07-08 19:04:57 +02:00
id('org.mikeneck.graalvm-native-image') version("${pluginNativeImage}")
2024-06-08 15:33:03 +02:00
}
// Dependencies
2024-06-08 15:33:03 +02:00
dependencies {
2024-06-09 00:21:01 +02:00
// -> Runtime <-
2024-06-08 15:33:03 +02:00
// Lombok
2024-07-08 12:39:04 +02:00
compileOnly("org.projectlombok:lombok:${dependencyLombok}")
annotationProcessor("org.projectlombok:lombok:${dependencyLombok}")
2024-06-08 15:33:03 +02:00
2024-06-09 00:21:01 +02:00
// JetBrains Annotations
2024-07-08 12:39:04 +02:00
compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
2024-06-08 15:33:03 +02:00
2024-06-09 00:21:01 +02:00
// -> Project <-
2024-07-08 12:39:04 +02:00
implementation(project(":base"))
runtimeOnly(project(":ansi"))
runtimeOnly(project(":slf4j-compat"))
2024-08-20 21:01:39 +02:00
implementation(project(":windowing"))
runtimeOnly(project(":windowing:glfw"))
2024-06-08 15:33:03 +02:00
}
// 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)
2024-06-08 15:33:03 +02:00
}
// Configure output jar
2024-06-08 15:33:03 +02:00
jar {
manifest {
attributes(
"Main-Class": "de.staropensource.engine.testapp.Main"
2024-06-08 15:33:03 +02:00
)
}
}
// Configure application run task
2024-06-08 15:33:03 +02:00
application {
mainClass.set("de.staropensource.engine.testapp.Main")
2024-09-22 13:40:48 +02:00
applicationDefaultJvmArgs = [
// Display GC log
"-Xlog:gc",
2024-06-08 15:33:03 +02:00
// Set log level to DIAGNOSTIC
"-Dsosengine.base.loggerLevel=diagnostic",
// Force writing to standard output
"-Dsosengine.base.loggerForceStandardOutput=true",
// Pass classes which should be included if
// reflective sclasspath scanning is disabled.
"-Dsosengine.base.initialIncludeSubsystemClasses=de.staropensource.engine.ansi.AnsiSubsystem,de.staropensource.engine.slf4j_compat.Slf4jCompatSubsystem,de.staropensource.engine.windowing.glfw.GlfwSubsystem",
2024-06-08 15:33:03 +02:00
// Force Jansi to write escape sequences
"-Djansi.mode=force",
]
}
2024-07-08 15:40:11 +02:00
// GraalVM native-image plugin configuration
2024-07-08 15:40:11 +02:00
nativeImage {
2024-07-11 16:15:47 +02:00
outputs.upToDateWhen { true }
2024-07-08 15:40:11 +02:00
graalVmHome = project.hasProperty("graalHome") ? project.property("graalHome") as String : System.getProperty("java.home")
executableName = "sosengine-testapp"
outputDirectory = file("build/bin")
2024-07-11 16:15:47 +02:00
setClasspath(shadowJar)
buildType { BuildTypeSelector build ->
build.executable {
main = 'de.staropensource.engine.testapp.Main'
2024-07-11 16:15:47 +02:00
}
}
2024-07-11 04:59:45 +02:00
2024-07-08 15:40:11 +02:00
arguments {
2024-07-11 16:15:47 +02:00
add "-H:+UnlockExperimentalVMOptions"
add "--color=always"
add "-march=native"
add "-O3"
add "--no-fallback"
add "--report-unsupported-elements-at-runtime"
add "--enable-http"
add "--enable-https"
add "-H:IncludeResources=.*properties\$"
2024-07-08 15:40:11 +02:00
}
}
// Register task for executing the generated binary
2024-07-11 16:15:47 +02:00
tasks.register('runNativeImage', Exec) {
outputs.upToDateWhen { false }
2024-07-08 15:40:11 +02:00
dependsOn(nativeImage)
2024-07-11 16:15:47 +02:00
args(
2024-09-22 13:40:48 +02:00
"-Xlog:gc",
2024-07-11 16:15:47 +02:00
"-Dsosengine.base.loggerLevel=diagnostic",
"-Dsosengine.base.loggerForceStandardOutput=true",
"-Dsosengine.base.initialForceDisableClasspathScanning=true",
"-Dsosengine.base.initialIncludeSubsystemClasses=de.staropensource.engine.ansi.AnsiSubsystem,de.staropensource.engine.slf4j_compat.Slf4jCompatSubsystem,de.staropensource.engine.windowing.glfw.GlfwSubsystem",
"-Djansi.mode=force",
2024-07-11 16:15:47 +02:00
)
2024-07-08 15:40:11 +02:00
executable("build/bin/sosengine-testapp")
}