This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
generated from hirosukt/KotlinMinecraftPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
125 lines (107 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
118
119
120
121
122
123
124
125
plugins {
kotlin("jvm") version "1.8.20"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("org.jlleitschuh.gradle.ktlint") version "11.3.2"
id("xyz.jpenilla.run-paper") version "2.0.1"
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
`maven-publish`
`java-library`
`kotlin-dsl`
java
idea
}
group = "love.chihuyu"
version = "0.1.0"
val pluginVersion: String by project.ext
repositories {
mavenCentral()
maven("https://repo.codemc.org/repository/maven-public/")
maven("https://repo.hirosuke.me/repository/maven-public/")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://hub.spigotmc.org/nexus/content/repositories/public/")
maven("https://maven.enginehub.org/repo/")
maven("https://maven.citizensnpcs.co/repo")
}
/*
1.7.10~1.8.8: "org.github.paperspigot:paperspigot-api:$pluginVersion-R0.1-SNAPSHOT"
1.9.4~1.16.5: "com.destroystokyo.paper:paper-api:$pluginVersion-R0.1-SNAPSHOT"
1.17~1.19.4: "io.papermc.paper:paper-api:$pluginVersion-R0.1-SNAPSHOT"
*/
dependencies {
compileOnly("org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT")
// compileOnly(files("libs/spigot-1.8.8-R0.1-20190928.224340-1.jar"))
compileOnly("net.citizensnpcs:citizens-main:2.0.31-SNAPSHOT") {
exclude("*", "*")
}
compileOnly("love.chihuyu:TimerAPI:1.2.1-SNAPSHOT")
compileOnly("com.sk89q.worldedit:worldedit-core:6.1.4-SNAPSHOT")
compileOnly("com.sk89q.worldedit:worldedit-bukkit:6.1.4-SNAPSHOT")
implementation(kotlin("stdlib"))
}
ktlint {
ignoreFailures.set(true)
disabledRules.add("no-wildcard-imports")
}
tasks {
test {
useJUnitPlatform()
}
processResources {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from(sourceSets.main.get().resources.srcDirs) {
filter(
org.apache.tools.ant.filters.ReplaceTokens::class,
mapOf(
"tokens" to mapOf(
"version" to project.version.toString(),
"name" to project.name,
"mainPackage" to "love.chihuyu.${project.name.lowercase()}.${project.name}Plugin"
)
)
)
filteringCharset = "UTF-8"
}
}
shadowJar {
val loweredProject = project.name.lowercase()
exclude("org/slf4j/**")
archiveClassifier.set("")
}
runServer {
minecraftVersion(pluginVersion)
}
}
nexusPublishing {
this.repositories {
create("repo") {
nexusUrl.set(uri("https://repo.hirosuke.me/repository/maven-releases/"))
snapshotRepositoryUrl.set(uri("https://repo.hirosuke.me/repository/maven-snapshots/"))
}
}
}
kotlin {
jvmToolchain(8)
}
open class SetupTask : DefaultTask() {
@TaskAction
fun action() {
val projectDir = project.projectDir
projectDir.resolve("renovate.json").deleteOnExit()
val srcDir = projectDir.resolve("src/main/kotlin/love/chihuyu/${project.name.lowercase()}").apply(File::mkdirs)
srcDir.resolve("${project.name}Plugin.kt").writeText(
"""
package love.chihuyu.${project.name.lowercase()}
import org.bukkit.plugin.java.JavaPlugin
class ${project.name}Plugin: JavaPlugin() {
companion object {
lateinit var ${project.name}Plugin: JavaPlugin
}
init {
${project.name}Plugin = this
}
}
""".trimIndent()
)
}
}
task<SetupTask>("setup")