forked from Taraj/PaperMC_Plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
69 lines (60 loc) · 2.25 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
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
java
val kotlinVersion: String by System.getProperties()
kotlin("jvm").version(kotlinVersion)
val shadowVersion: String by System.getProperties()
id("com.github.johnrengelman.shadow").version(shadowVersion)
id("xyz.jpenilla.run-paper") version "2.1.0"
}
val pluginGroup: String by project
group = pluginGroup
val pluginVersion: String by project
version = pluginVersion
repositories {
mavenCentral()
maven("https://papermc.io/repo/repository/maven-public/")
}
dependencies {
val kotlinVersion: String by System.getProperties()
implementation(kotlin("stdlib", kotlinVersion))
val paperAPIVersion: String by project
compileOnly("io.papermc.paper", "paper-api", paperAPIVersion)
}
// This can be slower than manually relocating, if that's going to be an issue manually do so instead.
val autoRelocate by tasks.register<ConfigureShadowRelocation>(
"configureShadowRelocation",
ConfigureShadowRelocation::class
) {
target = tasks.getByName("shadowJar") as ShadowJar?
val packageName = "${project.group}.${project.name.toLowerCase()}"
prefix = "$packageName.shaded"
}
tasks {
val javaVersion = JavaVersion.VERSION_16
withType<JavaCompile> {
options.encoding = "UTF-8"
sourceCompatibility = javaVersion.toString()
targetCompatibility = javaVersion.toString()
options.release.set(javaVersion.toString().toInt())
}
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions { jvmTarget = javaVersion.toString() }
sourceCompatibility = javaVersion.toString()
targetCompatibility = javaVersion.toString()
}
java {
toolchain { languageVersion.set(JavaLanguageVersion.of(javaVersion.toString())) }
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
shadowJar {
archiveClassifier.set("")
project.configurations.implementation.get().isCanBeResolved = true
configurations = listOf(project.configurations.implementation.get())
dependsOn(autoRelocate)
minimize()
}
build { dependsOn(shadowJar) }
}