generated from hirosukt/KotlinMinecraftPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
161 lines (143 loc) · 4.95 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
plugins {
kotlin("jvm") version "1.9.10"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("org.jlleitschuh.gradle.ktlint") version "11.5.1"
id("xyz.jpenilla.run-paper") version "2.1.0"
`maven-publish`
`java-library`
`kotlin-dsl`
java
idea
}
group = "love.chihuyu"
version = "0.0.1-SNAPSHOT"
val pluginVersion: String by project.ext
repositories {
mavenCentral()
maven("https://repo.codemc.org/repository/maven-public/")
// maven("https://repo.papermc.io/repository/maven-public/")
maven("https://repo.hirosuke.me/snapshots/")
maven("https://repo.purpurmc.org/snapshots")
}
/*
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.purpurmc.purpur:purpur-api:$pluginVersion-R0.1-SNAPSHOT")
// compileOnly("io.papermc.paper:paper-api:$pluginVersion-R0.1-SNAPSHOT")
// compileOnly("org.spigotmc:spigot-api:$pluginVersion-R0.1-SNAPSHOT")
// compileOnly("org.bukkit:bukkit:$pluginVersion-R0.1-SNAPSHOT")
compileOnly("dev.jorel:commandapi-bukkit-core:9.1.0")
compileOnly("dev.jorel:commandapi-bukkit-kotlin:9.1.0")
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 {
exclude("org/slf4j/**")
}
runServer {
minecraftVersion(pluginVersion)
}
}
publishing {
repositories {
maven {
name = "repo"
credentials(PasswordCredentials::class)
url = uri(
if (project.version.toString().endsWith("SNAPSHOT"))
"https://repo.hirosuke.me/snapshots/"
else
"https://repo.hirosuke.me/releases/"
)
}
}
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
}
}
}
kotlin {
jvmToolchain(17)
}
task("setup") {
doFirst {
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("generateActionsFile") {
doFirst {
val actionFile = projectDir.resolve(".github/workflows").apply(File::mkdirs)
actionFile.resolve("deploy.yml").writeText(
"""
name: Deploy
on:
workflow_dispatch:
push:
branches:
- 'master'
paths-ignore:
- "**.md"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Prepare gradle.properties
run: |
mkdir -p ${ "\$HOME" }/.gradle
echo ${ "repoUsername=\${{ secrets.DEPLOY_USERNAME }} "} >> ${ "\$HOME" }/.gradle/gradle.properties
echo ${ "repoPassword=\${{ secrets.DEPLOY_PASSWORD }}"} >> ${ "\$HOME" }/.gradle/gradle.properties
- name: Deploy
run: |
./gradlew clean test publish
""".trimIndent()
)
}
}