generated from xpdustry/template-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
147 lines (128 loc) · 3.9 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
import com.xpdustry.toxopid.extension.anukeXpdustry
import com.xpdustry.toxopid.spec.ModMetadata
import com.xpdustry.toxopid.spec.ModPlatform
import com.xpdustry.toxopid.task.GithubAssetDownload
import net.ltgt.gradle.errorprone.CheckSeverity
import net.ltgt.gradle.errorprone.errorprone
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)
alias(libs.plugins.errorprone.gradle)
}
val metadata = ModMetadata.fromJson(rootProject.file("plugin.json"))
if (indraGit.headTag() == null) metadata.version += "-SNAPSHOT"
group = "com.xpdustry"
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() }
}
maven("https://maven.xpdustry.com/snapshots") {
name = "xpdustry-snapshots"
mavenContent { snapshotsOnly() }
}
}
dependencies {
compileOnly(toxopid.dependencies.arcCore)
compileOnly(toxopid.dependencies.mindustryCore)
compileOnly(libs.distributor.api)
compileOnlyApi(libs.jspecify)
annotationProcessor(libs.nullaway)
errorprone(libs.errorprone.core)
implementation(libs.configurate.yaml)
}
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("", "\\#")
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") }
minimize()
}
tasks.register<Copy>("release") {
dependsOn(tasks.build)
from(tasks.shadowJar)
destinationDir = temporaryDir
}
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.momo")
}
}
val downloadSlf4md by tasks.registering(GithubAssetDownload::class) {
owner = "xpdustry"
repo = "slf4md"
asset = "slf4md-simple.jar"
version = "v${libs.versions.slf4md.get()}"
}
val downloadDistributorCommon by tasks.registering(GithubAssetDownload::class) {
owner = "xpdustry"
repo = "distributor"
asset = "distributor-common.jar"
version = "v${libs.versions.distributor.get()}"
}
tasks.runMindustryServer {
mods.from(downloadSlf4md, files("libs/distributor-common.jar"))
}