generated from xpdustry/template-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
178 lines (149 loc) · 4.58 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import com.xpdustry.ksr.kotlinRelocate
import com.xpdustry.toxopid.extension.anukeXpdustry
import com.xpdustry.toxopid.spec.ModMetadata
import com.xpdustry.toxopid.spec.ModPlatform
import com.xpdustry.toxopid.task.GithubAssetDownload
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.spotless)
alias(libs.plugins.indra.common)
alias(libs.plugins.indra.git)
alias(libs.plugins.indra.publishing)
alias(libs.plugins.shadow)
alias(libs.plugins.toxopid)
alias(libs.plugins.ksr)
alias(libs.plugins.dokka)
}
val metadata = ModMetadata.fromJson(rootProject.file("plugin.json"))
if (indraGit.headTag() == null) metadata.version += "-SNAPSHOT"
group = "com.xpdustry"
version = metadata.version
description = metadata.description
toxopid {
compileVersion = "v${metadata.minGameVersion}"
platforms = setOf(ModPlatform.SERVER)
}
repositories {
mavenCentral()
anukeXpdustry()
}
dependencies {
compileOnly(kotlin("stdlib-jdk8"))
compileOnly(libs.kotlinx.coroutines.core)
compileOnly(libs.kotlinx.coroutines.jdk8)
compileOnly(libs.kotlinx.serialization.json)
compileOnly(toxopid.dependencies.arcCore)
testImplementation(toxopid.dependencies.arcCore)
compileOnly(toxopid.dependencies.mindustryCore)
testImplementation(toxopid.dependencies.mindustryCore)
compileOnly(libs.slf4j.api)
testImplementation(libs.slf4j.simple)
implementation(libs.okhttp)
implementation(libs.hoplite.core)
implementation(libs.hoplite.yaml)
implementation(libs.guava)
implementation(libs.hikari) {
exclude("org.slf4j")
}
testImplementation(libs.junit.api)
testRuntimeOnly(libs.junit.engine)
}
signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
}
indra {
javaVersions {
target(17)
minimumToolchain(17)
}
publishSnapshotsTo("xpdustry", "https://maven.xpdustry.com/snapshots")
publishReleasesTo("xpdustry", "https://maven.xpdustry.com/releases")
mitLicense()
if (metadata.repository.isNotBlank()) {
val repo = metadata.repository.split("/")
github(repo[0], repo[1]) {
ci(true)
issues(true)
scm(true)
}
}
configurePublications {
pom {
organization {
name = "xpdustry"
url = "https://www.xpdustry.com"
}
}
}
}
spotless {
kotlin {
ktlint()
licenseHeaderFile(rootProject.file("HEADER.txt"))
}
kotlinGradle {
ktlint()
}
}
kotlin {
explicitApi()
}
configurations.runtimeClasspath {
exclude("org.jetbrains.kotlin")
exclude("org.jetbrains.kotlinx")
}
val generateMetadataFile by tasks.registering {
inputs.property("metadata", metadata)
val output = temporaryDir.resolve("plugin.json")
outputs.file(output)
doLast { output.writeText(ModMetadata.toJson(metadata)) }
}
tasks.shadowJar {
archiveFileName = "${metadata.name}.jar"
archiveClassifier = "plugin"
from(generateMetadataFile)
from(rootProject.file("LICENSE.md")) { into("META-INF") }
val shadowPackage = "com.xpdustry.nohorny.shadow"
kotlinRelocate("com.sksamuel.hoplite", "$shadowPackage.hoplite")
kotlinRelocate("okhttp3", "$shadowPackage.okhttp3")
kotlinRelocate("okio", "$shadowPackage.okio")
relocate("org.yaml.snakeyaml", "$shadowPackage.snakeyaml")
relocate("com.google.common", "$shadowPackage.guava")
relocate("com.zaxxer.hikari", "$shadowPackage.hikari")
mergeServiceFiles()
minimize {
exclude(dependency("com.sksamuel.hoplite:hoplite-.*:.*"))
}
}
tasks.javadocJar {
from(tasks.dokkaHtml)
}
tasks.register<Copy>("release") {
dependsOn(tasks.build)
from(tasks.shadowJar)
destinationDir = temporaryDir
}
val downloadSlf4md by tasks.registering(GithubAssetDownload::class) {
owner = "xpdustry"
repo = "slf4md"
asset = "slf4md-simple.jar"
version = "v${libs.versions.slf4md.get()}"
}
val downloadSql4md by tasks.registering(GithubAssetDownload::class) {
owner = "xpdustry"
repo = "sql4md"
asset = "sql4md.jar"
version = "v${libs.versions.sql4md.get()}"
}
val downloadKotlinRuntime by tasks.registering(GithubAssetDownload::class) {
owner = "xpdustry"
repo = "kotlin-runtime"
asset = "kotlin-runtime.jar"
version = "v${libs.versions.kotlin.runtime.get()}-k.${libs.versions.kotlin.core.get()}"
}
tasks.runMindustryServer {
mods.from(downloadSlf4md, downloadSql4md, downloadKotlinRuntime)
}