This repository has been archived by the owner on Mar 1, 2023. It is now read-only.
generated from xpdustry/template-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
186 lines (163 loc) · 5.68 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
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import fr.xpdustry.toxopid.dsl.anukenJitpack
import fr.xpdustry.toxopid.dsl.mindustryDependencies
import fr.xpdustry.toxopid.spec.ModMetadata
import fr.xpdustry.toxopid.spec.ModPlatform
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 "3.0.1"
id("com.github.johnrengelman.shadow") version "7.1.2"
id("fr.xpdustry.toxopid") version "3.0.0"
}
val metadata = ModMetadata.fromJson(file("plugin.json").readText())
group = property("props.project-group").toString()
if (indraGit.headTag() == null && property("props.enable-snapshots").toString().toBoolean()) {
metadata.version += "-SNAPSHOT"
}
version = metadata.version
description = metadata.description
toxopid {
compileVersion.set("v140.4")
runtimeVersion.set("v140.4")
platforms.set(setOf(ModPlatform.HEADLESS))
}
repositories {
mavenCentral()
anukenJitpack()
}
dependencies {
mindustryDependencies()
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")
val checker = "3.27.0"
compileOnly("org.checkerframework:checker-qual:$checker")
testImplementation("org.checkerframework:checker-qual:$checker")
// Static analysis
annotationProcessor("com.uber.nullaway:nullaway:0.10.6")
errorprone("com.google.errorprone:error_prone_core:2.17.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", project.property("props.root-package").toString())
option("NullAway:TreatGeneratedAsUnannotated", true)
}
}
}
// Required for the GitHub actions
tasks.register("getArtifactPath") {
doLast { println(tasks.shadowJar.get().archiveFile.get().toString()) }
}
// Relocates dependencies
val relocate = tasks.register<ConfigureShadowRelocation>("relocateShadowJar") {
target = tasks.shadowJar.get()
prefix = project.property("props.root-package").toString() + ".shadow"
}
tasks.shadowJar {
// Makes sure the name of the final jar is (plugin-display-name).jar
archiveFileName.set(metadata.displayName + ".jar")
// Set the classifier to plugin for publication on a maven repository
archiveClassifier.set("plugin")
// Configure the dependencies shading
dependsOn(relocate)
// 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)
}
tasks.runMindustryClient {
mods.setFrom()
}
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")
// 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.fr")
}
developers {
developer {
id.set(metadata.author)
}
}
}
}
}
spotless {
java {
palantirJavaFormat()
formatAnnotations()
importOrderFile(rootProject.file(".spotless/project.importorder"))
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", property("props.project-year").toString())
}