This repository has been archived by the owner on Apr 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbuild.gradle.kts
129 lines (115 loc) · 4.28 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
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
118
119
120
121
122
123
124
125
126
127
128
129
import java.io.OutputStream
plugins {
kotlin("jvm") version "1.4.31"
kotlin("plugin.serialization") version "1.4.31"
id("com.github.johnrengelman.shadow") version "5.2.0"
// `maven-publish`
}
val relocate = (findProperty("relocate") as? String)?.toBoolean() ?: true
repositories {
mavenLocal()
mavenCentral()
maven(url = "https://papermc.io/repo/repository/maven-public/")
maven(url = "https://jitpack.io/")
}
dependencies {
compileOnly(kotlin("stdlib"))
compileOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2")
compileOnly("com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT")
implementation("com.github.monun:tap:3.4.0")
implementation("com.github.monun:kommand:0.8.0")
// testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
// testImplementation("org.junit.jupiter:junit-jupiter-engine:5.7.0")
// testImplementation("org.mockito:mockito-core:3.6.28")
// testImplementation("org.spigotmc:spigot:1.16.5-R0.1-SNAPSHOT")
}
tasks {
withType<JavaCompile> {
sourceCompatibility = "11"
targetCompatibility = "11"
}
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
processResources {
filesMatching("**/*.yml") {
expand(project.properties)
}
}
test {
useJUnitPlatform()
doLast {
file("logs").deleteRecursively()
}
}
create<Jar>("sourcesJar") {
from(sourceSets["main"].allSource)
archiveClassifier.set("sources")
}
shadowJar {
archiveBaseName.set(project.property("pluginName").toString())
archiveVersion.set("") // For bukkit plugin update
archiveClassifier.set("") // Remove 'all'
if (relocate) {
relocate("com.github.monun.kommand", "${rootProject.group}.${rootProject.name}.kommand")
relocate("com.github.monun.tap", "${rootProject.group}.${rootProject.name}.tap")
}
doFirst {
println("relocate = $relocate")
}
}
build {
dependsOn(shadowJar)
}
create<Copy>("copyToServer") {
from(shadowJar)
var dest = File(rootDir, ".server/plugins")
// if plugin.jar exists in plugins change dest to plugins/update
if (File(dest, shadowJar.get().archiveFileName.get()).exists()) dest = File(dest, "update")
into(dest)
}
create<DefaultTask>("setupWorkspace") {
doLast {
val versions = arrayOf(
"1.16.5"
)
val buildtoolsDir = file(".buildtools")
val buildtools = File(buildtoolsDir, "BuildTools.jar")
val maven = File(System.getProperty("user.home"), ".m2/repository/org/spigotmc/spigot/")
val repos = maven.listFiles { file: File -> file.isDirectory } ?: emptyArray()
val missingVersions = versions.filter { version ->
repos.find { it.name.startsWith(version) }?.also { println("Skip downloading spigot-$version") } == null
}.also { if (it.isEmpty()) return@doLast }
val download by registering(de.undercouch.gradle.tasks.download.Download::class) {
src("https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar")
dest(buildtools)
}
download.get().download()
runCatching {
for (v in missingVersions) {
println("Downloading spigot-$v...")
javaexec {
workingDir(buildtoolsDir)
main = "-jar"
args = listOf("./${buildtools.name}", "--rev", v)
// Silent
standardOutput = OutputStream.nullOutputStream()
errorOutput = OutputStream.nullOutputStream()
}
}
}.onFailure {
it.printStackTrace()
}
buildtoolsDir.deleteRecursively()
}
}
}
//publishing {
// publications {
// create<MavenPublication>(project.property("pluginName").toString()) {
// artifactId = project.name
// from(components["java"])
// artifact(tasks["sourcesJar"])
// }
// }
//}