generated from xpdustry/template-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
142 lines (122 loc) · 3.61 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
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.spotless)
alias(libs.plugins.indra.common)
alias(libs.plugins.indra.git)
alias(libs.plugins.indra.publishing)
alias(libs.plugins.shadow)
alias(libs.plugins.toxopid)
}
val metadata = ModMetadata.fromJson(rootProject.file("plugin.json"))
if (indraGit.headTag() == null) metadata.version += "-SNAPSHOT"
group = "com.xpdustry"
val rootPackage = "com.xpdustry.sql4md"
version = metadata.version
description = metadata.description
toxopid {
compileVersion = "v${metadata.minGameVersion}"
platforms = setOf(ModPlatform.SERVER)
}
repositories {
mavenCentral()
anukeXpdustry()
maven("https://maven.xpdustry.com/releases") {
name = "xpdustry-releases"
mavenContent { releasesOnly() }
}
}
dependencies {
compileOnly(toxopid.dependencies.arcCore)
compileOnly(toxopid.dependencies.mindustryCore)
implementation(libs.sqlite)
implementation(libs.h2)
implementation(libs.mysql)
// Up-to-date version of protobuf for mysql
runtimeOnly(libs.protobuf)
implementation(libs.mariadb)
}
configurations.runtimeClasspath {
exclude(group = "org.slf4j")
exclude(group = "com.google.errorprone")
exclude(group = "org.checkerframework")
}
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 {
java {
palantirJavaFormat()
formatAnnotations()
importOrder("", "\\#")
custom("no-wildcard-imports") { it.apply { if (contains("*;\n")) error("No wildcard imports allowed") } }
licenseHeaderFile(rootProject.file("HEADER.txt"))
bumpThisNumberIfACustomStepChanges(1)
}
kotlinGradle {
ktlint()
}
}
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") }
fun ezRelocate(pkg: String) = relocate(pkg, "$rootPackage.shadow.${pkg.split(".").last()}")
ezRelocate("com.github.benmanes.caffeine")
ezRelocate("com.google.protobuf")
ezRelocate("waffle")
ezRelocate("com.sun.jna")
mergeServiceFiles()
}
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()}"
}
tasks.runMindustryServer {
mods.from(downloadSlf4md)
}