-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
117 lines (98 loc) · 3.65 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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
import java.util.*
plugins {
idea
alias(libs.plugins.kotlin)
alias(libs.plugins.paperweight)
alias(libs.plugins.shadow)
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
repositories {
mavenCentral()
mavenLocal()
gradlePluginPortal()
maven("https://jitpack.io/")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
}
dependencies {
implementation(kotlin("stdlib"))
implementation(kotlin("reflect"))
paperweight.paperDevBundle(libs.versions.paper)
compileOnly("dev.jorel:commandapi-bukkit-core:9.5.0")
compileOnly("me.clip:placeholderapi:2.11.6")
compileOnly("com.github.Xiao-MoMi:Custom-Crops:3.6.18")
implementation("com.github.stefvanschie.inventoryframework:IF:0.10.17")
}
extra.apply {
set("pluginName", project.name.split('-').joinToString("") {
it.replaceFirstChar { char ->
if (char.isLowerCase()) char.titlecase(Locale.getDefault()) else char.toString()
}
})
set("packageName", project.name.replace("-", ""))
set("kotlinVersion", libs.versions.kotlin)
set("paperVersion", libs.versions.paper.get().split('.').take(2).joinToString("."))
val pluginLibraries = LinkedHashSet<String>()
configurations.findByName("implementation")?.allDependencies?.forEach { dependency ->
val group = dependency.group ?: error("group is null")
var name = dependency.name ?: error("name is null")
var version = dependency.version
if (group == "org.jetbrains.kotlin" && version == null) {
version = getKotlinPluginVersion()
} else if (group == "io.github.monun.tap" && name.endsWith("-api")) {
name = name.removeSuffix("api") + "core"
}
requireNotNull(version) { "version is null" }
require(version != "latest.release") { "version is latest.release" }
pluginLibraries += "$group:$name:$version"
set("pluginLibraries", pluginLibraries.joinToString("\n ") { "- $it" })
}
}
tasks {
processResources {
filesMatching("*.yml") {
expand(project.properties)
expand(extra.properties)
}
}
fun registerJar(name: String, bundle: Boolean) {
val taskName = name + "Jar"
register<ShadowJar>(taskName) {
outputs.upToDateWhen { false }
from(sourceSets["main"].output)
if (bundle) {
configurations = listOf(
project.configurations.runtimeClasspath.get()
)
exclude("clip-plugin.yml")
rename("bundle-plugin.yml", "plugin.yml")
} else {
exclude("bundle-plugin.yml")
rename("clip-plugin.yml", "plugin.yml")
}
doLast {
// 플러그인 폴더 및 업데이트 폴더 경로 설정
val plugins = file("Y:\\minecaft\\plugins")
val update = plugins.resolve("update")
// 복사 작업
copy {
from(archiveFile)
if (plugins.resolve(archiveFileName.get()).exists())
into(update)
else
into(plugins)
}
// 업데이트 폴더의 UPDATE 파일 삭제 예약
update.resolve("UPDATE").deleteOnExit()
}
}
}
registerJar("clip", false)
registerJar("bundle", true)
}