generated from hirosukt/KotlinMinecraftPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
82 lines (67 loc) · 2.14 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
plugins {
kotlin("jvm") version "2.0.0"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("org.jlleitschuh.gradle.ktlint") version "11.3.1"
`maven-publish`
}
group = "love.chihuyu"
version = "1.1.1"
val pluginVersion: String by project.ext
repositories {
mavenCentral()
maven("https://hub.spigotmc.org/nexus/content/repositories/public/")
}
dependencies {
compileOnly("org.bukkit:bukkit:$pluginVersion-R0.1-SNAPSHOT")
compileOnly(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/**")
}
}
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")