Merge pull request #12 from solonovamax/auto-version

Automatically update the Terra version on build.
This commit is contained in:
dfsek 2020-11-13 13:22:02 -07:00 committed by GitHub
commit 979fce5856
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 23 deletions

View File

@ -35,8 +35,9 @@ val versionObj = Version("1", "3", "1", true)
version = versionObj
dependencies {
// compileOnly("org.polydev.gaea:gaea:1.14.2-github-actions+9d59b49")
compileOnly(name = "Gaea-1.14.2", group = "")
val geaVersion = "1.14.2"
compileOnly(name = "Gaea-${geaVersion}", group = "")
testImplementation(name = "Gaea-${geaVersion}", group = "")
compileOnly("org.spigotmc:spigot-api:1.16.2-R0.1-SNAPSHOT")
compileOnly("org.jetbrains:annotations:20.1.0")
@ -51,12 +52,26 @@ dependencies {
// JUnit.
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0")
testImplementation(name = "Gaea-1.14.2", group = "")
}
val compileJava: JavaCompile by tasks
val mainSourceSet: SourceSet = sourceSets["main"]
val tokenizeJavaSources = task<Copy>(name = "tokenizeJavaSources") {
from(mainSourceSet.allSource) {
include("**/plugin.yml")
val tokens = mapOf("VERSION" to versionObj.toString())
filter(org.apache.tools.ant.filters.ReplaceTokens::class, "tokens" to tokens)
}
into("build/tokenizedSources")
includeEmptyDirs = false
}
compileJava.apply {
dependsOn(tokenizeJavaSources)
options.encoding = "UTF-8"
doFirst {
options.compilerArgs = mutableListOf("-Xlint:all")
@ -72,6 +87,24 @@ tasks.test {
maxParallelForks = 12
}
tasks.named<ShadowJar>("shadowJar") {
from(tokenizeJavaSources.destinationDir)
archiveClassifier.set("")
archiveBaseName.set("Terra")
setVersion(project.version)
relocate("org.apache.commons", "com.dfsek.terra.lib.commons")
relocate("org.bstats.bukkit", "com.dfsek.terra.lib.bstats")
relocate("parsii", "com.dfsek.terra.lib.parsii")
relocate("io.papermc.lib", "com.dfsek.terra.lib.paperlib")
}
tasks.build {
dependsOn(tasks.shadowJar)
// dependsOn(testWithPaper)
// testWithPaper.mustRunAfter(tasks.shadowJar)
}
val testDir = "target/server/"
val setupServer = tasks.create("setupServer") {
@ -150,24 +183,6 @@ val testWithPaper = task<JavaExec>(name = "testWithPaper") {
classpath = files("${testDir}/paper.jar")
}
tasks.named<ShadowJar>("shadowJar") {
archiveClassifier.set("")
archiveBaseName.set("Terra")
setVersion(project.version)
relocate("org.apache.commons", "com.dfsek.terra.lib.commons")
relocate("org.bstats.bukkit", "com.dfsek.terra.lib.bstats")
relocate("parsii", "com.dfsek.terra.lib.parsii")
relocate("io.papermc.lib", "com.dfsek.terra.lib.paperlib")
}
tasks.build {
dependsOn(tasks.test)
dependsOn(tasks.shadowJar)
// dependsOn(testWithPaper)
tasks.shadowJar.get().mustRunAfter(tasks.test)
// testWithPaper.mustRunAfter(tasks.shadowJar)
}
/**
* Version class that does version stuff.

View File

@ -1,7 +1,7 @@
name: "Terra"
depend: [ "Gaea" ]
main: "com.dfsek.terra.Terra"
version: "1.3.0-BETA"
version: "@VERSION@"
load: "STARTUP"
api-version: "1.16"
description: "An insanely powerful free & open-source data-driven world generator."