This repository was archived by the owner on Mar 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
117 lines (99 loc) · 3.61 KB
/
build.gradle.kts
File metadata and controls
117 lines (99 loc) · 3.61 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import java.io.ByteArrayOutputStream
plugins {
java
id("maven-publish")
id("com.github.johnrengelman.shadow").version("6.0.0")
}
repositories {
flatDir { dirs("lib") }
maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") }
maven { url = uri("http://maven.enginehub.org/repo/") }
maven { url = uri("https://repo.codemc.org/repository/maven-public") }
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
maven { url = uri("https://repo.aikar.co/content/groups/aikar/") }
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
group = "org.polydev.gaea"
val versionObj = Version("1", "15", "0", false)
version = versionObj
dependencies {
compileOnly("org.jetbrains:annotations:20.1.0") // more recent.
compileOnly("org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT")
implementation("com.googlecode.json-simple:json-simple:1.1")
implementation("commons-io:commons-io:2.4")
implementation("org.apache.commons:commons-rng-core:1.3")
implementation("net.jafama:jafama:2.3.2")
implementation("co.aikar:taskchain-bukkit:3.7.2")
implementation("com.esotericsoftware:reflectasm:1.11.9")
implementation("org.bstats:bstats-bukkit:1.7")
// JUnit.
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0")
testImplementation("org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT")
}
tasks.test {
useJUnitPlatform()
maxHeapSize = "1G"
ignoreFailures = false
failFast = true
maxParallelForks = 12
}
tasks.withType<ShadowJar> {
archiveClassifier.set("")
archiveBaseName.set("Gaea")
setVersion(project.version)
relocate("org.apache.commons", "org.polydev.gaea.libs.commons")
relocate("org.bstats.bukkit", "org.polydev.gaea.libs.bstats")
relocate("co.aikar.taskchain", "org.polydev.gaea.libs.taskchain")
relocate("com.esotericsoftware", "org.polydev.gaea.libs.reflectasm")
relocate("net.jafama", "org.polydev.gaea.libs.jafama")
}
val sourcesJar by tasks.registering(Jar::class) {
classifier = "sources"
from(sourceSets.main.get().allSource)
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
artifact(tasks["sourcesJar"])
artifact(tasks["jar"])
}
}
repositories {
val mavenUrl = "https://repo.codemc.io/repository/maven-releases/"
val mavenSnapshotUrl = "https://repo.codemc.io/repository/maven-snapshots/"
maven((if (versionObj.preRelease) mavenSnapshotUrl else mavenUrl)) {
val mavenUsername: String? by project
val mavenPassword: String? by project
if (mavenUsername != null && mavenPassword != null) {
credentials {
username = mavenUsername
password = mavenPassword
}
}
}
}
}
/**
* Version class that does version stuff.
*/
class Version(val major: String, val minor: String, val revision: String, val preRelease: Boolean = false) {
override fun toString(): String {
return if (preRelease)
"$major.$minor.$revision-BETA+${getGitHash()}"
else //Only use git hash if it's a prerelease.
"$major.$minor.$revision"
}
}
fun getGitHash(): String {
val stdout = ByteArrayOutputStream()
exec {
commandLine = mutableListOf("git", "rev-parse", "--short", "HEAD")
standardOutput = stdout
}
return stdout.toString().trim()
}