generated from xpdustry/template-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
185 lines (160 loc) · 4.84 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
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import fr.xpdustry.toxopid.spec.ModPlatform
import fr.xpdustry.toxopid.task.GithubArtifactDownload
import fr.xpdustry.toxopid.spec.ModMetadata
import fr.xpdustry.toxopid.dsl.anukenJitpack
import fr.xpdustry.toxopid.dsl.mindustryDependencies
import net.ltgt.gradle.errorprone.CheckSeverity
import net.ltgt.gradle.errorprone.errorprone
plugins {
id("com.diffplug.spotless") version "6.11.0"
id("net.kyori.indra") version "3.0.1"
id("net.kyori.indra.publishing") version "3.0.1"
id("net.kyori.indra.git") version "3.0.1"
id("net.kyori.indra.licenser.spotless") version "3.0.1"
id("net.ltgt.errorprone") version "2.0.2"
id("com.github.johnrengelman.shadow") version "7.1.2"
id("fr.xpdustry.toxopid") version "3.1.0"
}
val metadata = ModMetadata.fromJson(file("plugin.json").readText())
if (indraGit.headTag() == null) {
metadata.version += "-SNAPSHOT"
}
group = "fr.xpdustry"
version = metadata.version
description = metadata.description
toxopid {
compileVersion.set("v" + metadata.minGameVersion)
platforms.add(ModPlatform.HEADLESS)
}
repositories {
mavenCentral()
anukenJitpack()
maven("https://maven.xpdustry.fr/releases") {
name = "xpdustry-releases"
mavenContent { releasesOnly() }
}
maven("https://maven.xpdustry.fr/snapshots") {
name = "xpdustry-snapshots"
mavenContent { snapshotsOnly() }
}
}
dependencies {
mindustryDependencies()
compileOnly("fr.xpdustry:distributor-api:3.0.0-SNAPSHOT")
val junit = "5.9.0"
testImplementation("org.junit.jupiter:junit-jupiter-params:$junit")
testImplementation("org.junit.jupiter:junit-jupiter-api:$junit")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junit")
// Static analysis
annotationProcessor("com.uber.nullaway:nullaway:0.10.10")
errorprone("com.google.errorprone:error_prone_core:2.18.0")
}
tasks.withType(JavaCompile::class.java).configureEach {
options.errorprone {
disableWarningsInGeneratedCode.set(true)
disable(
"MissingSummary",
"FutureReturnValueIgnored",
"InlineMeSuggester",
"EmptyCatch"
)
if (!name.contains("test", true)) {
check("NullAway", CheckSeverity.ERROR)
option("NullAway:AnnotatedPackages", "fr.xpdustry.router")
option("NullAway:TreatGeneratedAsUnannotated", true)
}
}
}
/*
val downloadDistributor = tasks.register<GithubArtifactDownload>("downloadDistributor") {
user.set("Xpdustry")
repo.set("Distributor")
name.set("Distributor.jar")
version.set("v3.0.0-rc.3")
}
*/
tasks.runMindustryServer {
mods.setFrom(tasks.shadowJar, files("libs/DistributorCore.jar"))
}
// It does not need the plugin
tasks.runMindustryClient {
mods.setFrom()
}
// Required by the GitHub actions
tasks.register("getArtifactPath") {
doLast { println(tasks.shadowJar.get().archiveFile.get().toString()) }
}
val relocate = tasks.create<ConfigureShadowRelocation>("relocateShadowJar") {
target = tasks.shadowJar.get()
prefix = "fr.xpdustry.router.shadow"
}
tasks.shadowJar {
dependsOn(relocate)
minimize()
doFirst {
val temp = temporaryDir.resolve("plugin.json")
temp.writeText(metadata.toJson(true))
from(temp)
}
from(rootProject.file("LICENSE.md")) {
into("META-INF")
}
archiveFileName.set("RouterPlugin.jar")
}
tasks.build {
dependsOn(tasks.shadowJar)
}
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.fr/snapshots")
publishReleasesTo("xpdustry", "https://maven.xpdustry.fr/releases")
gpl3OnlyLicense()
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.fr")
}
developers {
developer {
id.set("Phinner")
timezone.set("Europe/Brussels")
}
developer {
id.set("Router")
}
}
}
}
}
spotless {
java {
palantirJavaFormat()
formatAnnotations()
custom("noWildcardImports") {
if (it.contains("*;\n")) {
throw Error("No wildcard imports allowed")
}
it
}
bumpThisNumberIfACustomStepChanges(1)
}
}
indraSpotlessLicenser {
licenseHeaderFile(rootProject.file("LICENSE_HEADER.md"))
}