Improve build scripts
Thanks solonovamax! She/he/they helped improve the engine's build scripts and gave a lot of tips when working with Gradle. Website: https://solonovamax.gay Fedi: https://tech.lgbt/@solonovamax GitHub: https://github.com/solonovamax
This commit is contained in:
parent
b133f7e3a7
commit
e2e5040055
3 changed files with 56 additions and 46 deletions
|
@ -44,16 +44,6 @@ import java.nio.file.LinkOption
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Buildscript
|
||||
buildscript {
|
||||
// Repositories
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
// Plugins
|
||||
plugins {
|
||||
id("java-library")
|
||||
|
@ -113,8 +103,8 @@ allprojects {
|
|||
// Java
|
||||
java {
|
||||
// Java version
|
||||
sourceCompatibility = JavaVersion.valueOf("VERSION_${property("languageJava") as String}")
|
||||
targetCompatibility = JavaVersion.valueOf("VERSION_${property("languageJava") as String}")
|
||||
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 {
|
||||
|
@ -130,7 +120,7 @@ allprojects {
|
|||
verbose = true
|
||||
|
||||
// Set target metadata
|
||||
jvmTarget = JvmTarget.valueOf("JVM_${property("languageJava") as String}")
|
||||
jvmTarget = JvmTarget.fromTarget(property("languageJava") as String)
|
||||
}
|
||||
|
||||
// Unit testing
|
||||
|
@ -218,17 +208,17 @@ allprojects {
|
|||
// -> Copy task
|
||||
tasks.register("copyGitProperties") {
|
||||
dependsOn(tasks.generateGitProperties)
|
||||
inputs.file("${project.projectDir}/build/resources/main/git.properties")
|
||||
|
||||
doLast {
|
||||
if (rootProject == project)
|
||||
return@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())
|
||||
file(inputs.files.first())
|
||||
.copyTo(
|
||||
file("${project.projectDir}/src/main/resources/sosengine-${project.name.replace(":", "-")}-git.properties"),
|
||||
overwrite = true
|
||||
)
|
||||
}
|
||||
}
|
||||
tasks.processResources {
|
||||
|
@ -238,16 +228,17 @@ allprojects {
|
|||
// Gradle properties
|
||||
// -> Copy task
|
||||
tasks.register("copyGradleProperties") {
|
||||
inputs.file("${project(":").projectDir.path}/gradle.properties")
|
||||
|
||||
doLast {
|
||||
if (rootProject == project)
|
||||
return@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())
|
||||
file(inputs.files.first())
|
||||
.copyTo(
|
||||
file("${project.projectDir}/src/main/resources/sosengine-${project.name.replace(":", "-")}-gradle.properties"),
|
||||
overwrite = true
|
||||
)
|
||||
}
|
||||
}
|
||||
tasks.processResources {
|
||||
|
|
|
@ -17,13 +17,19 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Plugin management
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
// Project settings
|
||||
rootProject.name = "sos!engine"
|
||||
|
||||
// Subprojects
|
||||
// -> Root
|
||||
include("")
|
||||
|
||||
// -> Base
|
||||
include("base")
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ dependencies {
|
|||
// Configure JAR
|
||||
tasks.withType<Jar> {
|
||||
manifest {
|
||||
attributes.put("Main-Class", "de.staropensource.engine.testapp.Main")
|
||||
attributes["Main-Class"] = "de.staropensource.engine.testapp.Main"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,24 +41,37 @@ application {
|
|||
mainClass = "de.staropensource.engine.testapp.Main"
|
||||
|
||||
// JVM arguments
|
||||
val jvmArgs: MutableList<String> = mutableListOf()
|
||||
// -> JVM
|
||||
jvmArgs.add("-XX:+UnlockDiagnosticVMOptions")
|
||||
applicationDefaultJvmArgs = buildList {
|
||||
// Unlock more VM options
|
||||
add("-XX:+UnlockDiagnosticVMOptions")
|
||||
add("-XX:+UnlockExperimentalVMOptions")
|
||||
|
||||
if (hasProperty("jvm.logGC") && property("jvm.logGC") as String == "true")
|
||||
jvmArgs.add("-Xlog:gc")
|
||||
if (hasProperty("jvm.logJITandAOT") && property("jvm.logJITandAOT") as String == "true") {
|
||||
jvmArgs.add("-XX:+PrintCompilation")
|
||||
jvmArgs.add("-XX:+PrintInlining")
|
||||
// VM settings
|
||||
// -> Log garbage collection
|
||||
if (
|
||||
hasProperty("jvm.logGC")
|
||||
&& property("jvm.logGC") as String == "true"
|
||||
)
|
||||
add("-Xlog:gc")
|
||||
|
||||
// -> Log JIT & AOT
|
||||
if (
|
||||
hasProperty("jvm.logJITandAOT")
|
||||
&& property("jvm.logJITandAOT") as String == "true"
|
||||
) {
|
||||
add("-XX:+PrintCompilation")
|
||||
add("-XX:+PrintInlining")
|
||||
}
|
||||
|
||||
// -> Select garbage collector
|
||||
if (hasProperty("jvm.garbageCollector"))
|
||||
when (property("jvm.garbageCollector")) {
|
||||
"epsilon" -> jvmArgs.add("-XX:+UseEpsilonGC")
|
||||
"serial" -> jvmArgs.add("-XX:+UseSerialGC")
|
||||
"g1" -> jvmArgs.add("-XX:+UseG1GC")
|
||||
"epsilon" -> add("-XX:+UseEpsilonGC")
|
||||
"serial" -> add("-XX:+UseSerialGC")
|
||||
"g1" -> add("-XX:+UseG1GC")
|
||||
}
|
||||
// -> Jansi
|
||||
jvmArgs.add("-Djansi.mode=force")
|
||||
|
||||
applicationDefaultJvmArgs = jvmArgs
|
||||
// Jansi
|
||||
add("-Djansi.mode=force")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue