generated from xpdustry/template-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
206 lines (182 loc) · 6.77 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
import fr.xpdustry.toxopid.dsl.mindustryDependencies
import fr.xpdustry.toxopid.spec.ModMetadata
import fr.xpdustry.toxopid.spec.ModPlatform
import fr.xpdustry.toxopid.task.GithubArtifactDownload
import net.ltgt.gradle.errorprone.CheckSeverity
import net.ltgt.gradle.errorprone.errorprone
plugins {
id("com.diffplug.spotless") version "6.23.3"
id("net.kyori.indra") version "3.1.3"
id("net.kyori.indra.publishing") version "3.1.3"
id("net.kyori.indra.git") version "3.1.3"
id("net.kyori.indra.licenser.spotless") version "3.1.3"
id("net.ltgt.errorprone") version "3.1.0"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("fr.xpdustry.toxopid") version "3.2.0"
id("com.github.ben-manes.versions") version "0.50.0"
}
val metadata =
ModMetadata(
name = "hexed-reloaded",
displayName = "HexedPluginReloaded",
author = "Xpdustry",
description = "A reimplementation of the hexed gamemode, with more features and better performances.",
version = "1.0.0",
minGameVersion = "146",
hidden = true,
java = true,
main = "com.xpdustry.hexed.HexedPluginReloaded",
repo = "xpdustry/hexed-reloaded",
dependencies = mutableListOf("distributor-core"),
)
// Remove the following line if you don't want snapshot versions
if (indraGit.headTag() == null) {
metadata.version += "-SNAPSHOT"
}
group = "com.xpdustry"
val rootPackage = "com.xpdustry.template"
version = metadata.version
description = metadata.description
toxopid {
compileVersion.set("v${metadata.minGameVersion}")
platforms.set(setOf(ModPlatform.HEADLESS))
}
repositories {
mavenCentral()
// This repository provides mindustry artifacts built by xpdustry
maven("https://maven.xpdustry.com/mindustry")
// This repository provides xpdustry libraries, such as the distributor-api
maven("https://maven.xpdustry.com/releases")
}
dependencies {
mindustryDependencies()
compileOnly("fr.xpdustry:distributor-api:3.2.1")
val junit = "5.10.1"
testImplementation("org.junit.jupiter:junit-jupiter-params:$junit")
testImplementation("org.junit.jupiter:junit-jupiter-api:$junit")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junit")
val checker = "3.41.0"
compileOnly("org.checkerframework:checker-qual:$checker")
testImplementation("org.checkerframework:checker-qual:$checker")
// Static analysis
annotationProcessor("com.uber.nullaway:nullaway:0.10.18")
errorprone("com.google.errorprone:error_prone_core:2.23.0")
}
indra {
javaVersions {
target(17)
minimumToolchain(17)
}
publishSnapshotsTo("xpdustry", "https://maven.xpdustry.com/snapshots")
publishReleasesTo("xpdustry", "https://maven.xpdustry.com/releases")
// The license of your project, kyori has already functions for the most common licenses
// such as gpl3OnlyLicense() for GPLv3, apache2License() for Apache 2.0, etc.
// You can still specify your own license using the license { } builder function.
mitLicense()
if (metadata.repo.isNotBlank()) {
val repo = metadata.repo.split("/")
github(repo[0], repo[1]) {
ci(true)
issues(true)
scm(true)
}
}
configurePublications {
pom {
organization {
name.set("xpdustry")
url.set("https://www.xpdustry.com")
}
}
}
}
signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
}
spotless {
java {
// Palantir is an excellent java linter, balanced between google codestyle and regular java codestyle
palantirJavaFormat()
formatAnnotations()
// Makes sure static imports are after normal imports
importOrderFile(rootProject.file(".spotless/project.importorder"))
// Makes sure there is no wildcard imports.
// If you want to allow them,
// remove the following line and the bumpThisNumberIfACustomStepChanges(1)
custom("noWildcardImports") {
if (it.contains("*;\n")) {
throw Error("No wildcard imports allowed")
}
it
}
bumpThisNumberIfACustomStepChanges(1)
}
kotlinGradle {
ktlint()
}
}
indraSpotlessLicenser {
licenseHeaderFile(rootProject.file("LICENSE_HEADER.md"))
// Some properties to make updating the licence header easier
property("NAME", metadata.displayName)
property("DESCRIPTION", metadata.description)
property("AUTHOR", metadata.author)
property("YEAR", "2023")
}
tasks.withType<JavaCompile> {
options.errorprone {
disableWarningsInGeneratedCode.set(true)
disable("MissingSummary", "InlineMeSuggester", "FutureReturnValueIgnored")
if (!name.contains("test", ignoreCase = true)) {
check("NullAway", CheckSeverity.ERROR)
option("NullAway:AnnotatedPackages", rootPackage)
option("NullAway:TreatGeneratedAsUnannotated", true)
}
}
}
// Required for the GitHub actions
tasks.register("getArtifactPath") {
doLast { println(tasks.shadowJar.get().archiveFile.get().toString()) }
}
tasks.shadowJar {
// Makes sure the name of the final jar is (plugin-name).jar
archiveFileName.set("${metadata.name}.jar")
// Set the classifier to plugin for publication on a maven repository
archiveClassifier.set("plugin")
// Configure the dependencies shading.
// WARNING: SQL drivers do not play well with shading,
// the best solution would be to load them in an isolated classloader.
// If it's too difficult, you can disable relocation but be aware this can conflict with other plugins.
isEnableRelocation = true
relocationPrefix = "$rootPackage.shadow"
// Reduce shadow jar size by removing unused classes.
// Warning, if one of your dependencies use service loaders or reflection, add to the exclude list
// such as "minimize { exclude(dependency("some.group:some-dependency:.*")) }"
minimize()
// Include the plugin.json file with the modified version
doFirst {
val temp = temporaryDir.resolve("plugin.json")
temp.writeText(metadata.toJson(true))
from(temp)
}
// Include the license of your project
from(rootProject.file("LICENSE.md")) {
into("META-INF")
}
}
tasks.build {
// Make sure the shadow jar is built during the build task
dependsOn(tasks.shadowJar)
}
val downloadDistributorCore =
tasks.register<GithubArtifactDownload>("downloadDistributorCore") {
user.set("xpdustry")
repo.set("distributor")
version.set("v3.2.1")
name.set("distributor-core.jar")
}
tasks.runMindustryServer {
mods.setFrom(tasks.shadowJar, downloadDistributorCore)
}