generated from xpdustry/template-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
170 lines (147 loc) · 5.5 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
import com.diffplug.gradle.spotless.SpotlessExtension
import com.diffplug.gradle.spotless.SpotlessPlugin
import com.diffplug.spotless.FormatterFunc
import com.github.jengelman.gradle.plugins.shadow.ShadowJavaPlugin
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.xpdustry.toxopid.ToxopidExtension
import com.xpdustry.toxopid.extension.anukeXpdustry
import com.xpdustry.toxopid.plugin.ToxopidPlugin
import com.xpdustry.toxopid.spec.ModMetadata
import com.xpdustry.toxopid.spec.ModPlatform
import net.kyori.indra.IndraExtension
import net.kyori.indra.IndraPlugin
import net.ltgt.gradle.errorprone.CheckSeverity
import net.ltgt.gradle.errorprone.ErrorPronePlugin
import net.ltgt.gradle.errorprone.errorprone
plugins {
alias(libs.plugins.spotless) apply false
alias(libs.plugins.indra.common) apply false
alias(libs.plugins.indra.git)
// alias(libs.plugins.indra.publishing) apply false
alias(libs.plugins.shadow) apply false
alias(libs.plugins.toxopid) apply false
alias(libs.plugins.errorprone.gradle) apply false
}
version = "1.0.2" + if (indraGit.headTag() == null) "-SNAPSHOT" else ""
group = "com.xpdustry"
description = "A SLF4J implementation for Mindustry servers."
val release by tasks.registering(Copy::class) {
destinationDir = temporaryDir
}
allprojects {
apply<SpotlessPlugin>()
repositories {
mavenCentral()
anukeXpdustry()
}
with(extensions.getByType<SpotlessExtension>()) {
plugins.withType<JavaPlugin> {
java {
palantirJavaFormat()
importOrder("", "\\#")
// I will kill someone
custom(
"no-wildcard-imports",
object : FormatterFunc, java.io.Serializable {
override fun apply(input: String) = input.apply { if (contains("*;\n")) error("No wildcard imports allowed") }
},
)
licenseHeaderFile(rootProject.file("HEADER.txt"))
bumpThisNumberIfACustomStepChanges(1)
}
}
kotlinGradle {
ktlint()
}
}
}
subprojects {
apply<IndraPlugin>()
// apply<IndraPublishingPlugin>()
apply<ShadowPlugin>()
apply<ToxopidPlugin>()
apply<ErrorPronePlugin>()
val metadata = ModMetadata.fromJson(rootProject.file("plugin.json"))
val local = ModMetadata.fromJson(file("plugin.json"))
metadata.displayName = local.displayName
metadata.description = local.description
metadata.mainClass = local.mainClass
metadata.version = rootProject.version.toString()
val toxopid = extensions.getByType<ToxopidExtension>()
toxopid.compileVersion = "v${metadata.minGameVersion}"
toxopid.platforms = setOf(ModPlatform.SERVER)
dependencies {
val compileOnly by configurations
val compileOnlyApi by configurations
val annotationProcessor by configurations
val errorprone by configurations
val api by configurations
api(rootProject.libs.slf4j.api)
api(rootProject.libs.slf4j.from.jul)
compileOnly(toxopid.dependencies.mindustryCore)
compileOnly(toxopid.dependencies.arcCore)
compileOnlyApi(rootProject.libs.checker.qual)
annotationProcessor(rootProject.libs.nullaway)
errorprone(rootProject.libs.errorprone.core)
}
// val signing = extensions.getByType<SigningExtension>()
// val signingKey: String? by project
// val signingPassword: String? by project
// signing.useInMemoryPgpKeys(signingKey, signingPassword)
with(extensions.getByType<IndraExtension>()) {
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"
}
developers {
developer {
id = "phinner"
timezone = "Europe/Brussels"
}
}
}
}
}
val generateResources by tasks.registering {
outputs.files(fileTree(temporaryDir))
doLast {
temporaryDir.resolve("plugin.json").writeText(ModMetadata.toJson(metadata))
}
}
val shadowJar =
tasks.named<ShadowJar>(ShadowJavaPlugin.SHADOW_JAR_TASK_NAME) {
archiveFileName = "${project.name}.jar"
archiveClassifier = "plugin"
from(generateResources)
from(rootProject.file("LICENSE.md")) { into("META-INF") }
}
tasks.withType<JavaCompile> {
options.errorprone {
disableWarningsInGeneratedCode = true
disable("MissingSummary", "InlineMeSuggester")
check("NullAway", if (name.contains("test", ignoreCase = true)) CheckSeverity.OFF else CheckSeverity.ERROR)
option("NullAway:AnnotatedPackages", "com.xpdustry.slf4md")
}
}
release.configure {
from(shadowJar)
}
}