This repository has been archived by the owner on Nov 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
76 lines (66 loc) · 2.03 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import org.apache.commons.io.output.ByteArrayOutputStream
import org.apache.tools.ant.filters.FixCrLfFilter
import org.apache.tools.ant.filters.ReplaceTokens
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.5.10"
id("com.github.johnrengelman.shadow") version "7.0.0"
id("com.github.gmazzo.buildconfig") version "3.0.0"
}
group = "org.example"
version = "1.0.0"
repositories {
maven(url = "https://papermc.io/repo/repository/maven-public/")
}
val minecraft_version: String by project
dependencies {
// PaperMC Dependency
compileOnly("com.destroystokyo.paper", "paper-api", "$minecraft_version-R0.1-SNAPSHOT")
// Add your dependencies here
// Examples
// implementation("io.ktor", "ktor-client", "1.4.0") // Would be shaded into the final jar
// compileOnly("io.ktor", "ktor-client", "1.4.0") // Only used on compile time
}
buildConfig {
className("BuildConfig")
packageName("$group.$name")
val commit = getGitHash()
val branch = getGitBranch()
buildConfigField("String", "GIT_COMMIT", "\"$commit\"")
buildConfigField("String", "GIT_BRANCH", "\"$branch\"")
}
fun getGitHash(): String {
val stdout = ByteArrayOutputStream()
exec {
commandLine( "git", "rev-parse", "--short", "HEAD")
standardOutput = stdout
}
return stdout.toString("UTF-8").trim()
}
fun getGitBranch(): String {
val stdout = ByteArrayOutputStream()
exec {
commandLine( "git", "rev-parse", "--abbrev-ref", "HEAD")
standardOutput = stdout
}
return stdout.toString("UTF-8").trim()
}
tasks {
processResources {
filter(FixCrLfFilter::class)
filter(ReplaceTokens::class, "tokens" to mapOf("version" to project.version))
filteringCharset = "UTF-8"
}
jar {
// Disabled, because we use the shadowJar task for building our jar
enabled = false
}
build {
dependsOn(shadowJar)
}
withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
}
}