-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.gradle.kts
169 lines (145 loc) · 5.87 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
import com.diffplug.gradle.spotless.FormatExtension
import com.diffplug.gradle.spotless.SpotlessExtension
import net.kyori.indra.IndraExtension
import net.kyori.indra.crossdoc.CrossdocExtension
import net.kyori.indra.gradle.IndraPluginPublishingExtension
import net.kyori.indra.licenser.spotless.IndraSpotlessLicenserExtension
plugins {
alias(libs.plugins.gradlePluginPublish) apply false
alias(libs.plugins.indra) apply false
alias(libs.plugins.spotless) apply false
alias(libs.plugins.indra.crossdoc) apply false
alias(libs.plugins.indra.licenserSpotless) apply false
alias(libs.plugins.indra.gradlePlugin) apply false
}
group = "org.spongepowered"
version = "2.2.1-SNAPSHOT"
subprojects {
apply(plugin = "net.kyori.indra")
apply(plugin = "net.kyori.indra.licenser.spotless")
apply(plugin = "net.kyori.indra.git")
val indra = extensions.getByType(IndraExtension::class)
val testTargets = listOf(11, 17, 21)
if (project.name != "spongegradle-testlib") {
plugins.apply(JavaGradlePluginPlugin::class)
apply(plugin = "com.gradle.plugin-publish")
apply(plugin = "net.kyori.indra.publishing.gradle-plugin")
apply(plugin = "net.kyori.indra.crossdoc")
tasks.named("publishPlugins") {
onlyIf { net.kyori.indra.util.Versioning.isRelease(project) }
}
extensions.configure(TestingExtension::class) {
suites.withType(JvmTestSuite::class).configureEach {
useJUnitJupiter(rootProject.libs.versions.junit.get())
}
val functionalTest = suites.register("functionalTest", JvmTestSuite::class) {
dependencies {
implementation(project())
implementation(project(":spongegradle-testlib"))
}
testType.set(TestSuiteType.FUNCTIONAL_TEST)
targets {
testTargets.forEach { runtimeVersion ->
register("functionalTestJava$runtimeVersion") {
testTask.configure {
javaLauncher = project.extensions.getByType(JavaToolchainService::class).launcherFor { languageVersion = JavaLanguageVersion.of(runtimeVersion) }
onlyIf { JavaVersion.current().ordinal + 1 != runtimeVersion && indra.javaVersions().strictVersions().get() }
}
}
}
}
}
tasks.named("check") {
dependsOn(functionalTest)
}
extensions.getByType(GradlePluginDevelopmentExtension::class).testSourceSets(functionalTest.get().sources)
}
}
dependencies {
"compileOnlyApi"(rootProject.libs.jetbrainsAnnotations)
}
val indraGit = extensions.getByType(net.kyori.indra.git.IndraGitExtension::class)
tasks.withType(Jar::class).configureEach {
indraGit.applyVcsInformationToManifest(manifest)
manifest.attributes(
"Specification-Title" to project.name,
"Specification-Vendor" to "SpongePowered",
"Specification-Version" to project.version,
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
"Implementation-Vendor" to "SpongePowered"
)
}
with(indra) {
github("SpongePowered", "SpongeGradle") {
ci(true)
publishing(true)
}
mitLicense()
javaVersions {
testWith().addAll(testTargets)
}
configurePublications {
pom {
developers {
developer {
name.set("SpongePowered Team")
email.set("[email protected]")
}
}
}
}
signWithKeyFromPrefixedProperties("sponge")
val spongeSnapshotRepo = project.findProperty("spongeSnapshotRepo") as String?
val spongeReleaseRepo = project.findProperty("spongeReleaseRepo") as String?
if (spongeReleaseRepo != null && spongeSnapshotRepo != null) {
publishSnapshotsTo("sponge", spongeSnapshotRepo)
publishReleasesTo("sponge", spongeReleaseRepo)
}
}
extensions.configure(SpotlessExtension::class) {
fun FormatExtension.standardOptions() {
endWithNewline()
indentWithSpaces(4)
trimTrailingWhitespace()
this.toggleOffOn("@formatter:off", "@formatter:on")
}
java {
target("src/*/java/**/*.java", "src/*/groovy/**/*.java")
standardOptions()
formatAnnotations()
importOrderFile(rootProject.file(".spotless/sponge.importorder"))
removeUnusedImports()
}
project.plugins.withId("groovy") {
groovy {
standardOptions()
excludeJava()
importOrderFile(rootProject.file(".spotless/sponge.importorder"))
}
}
kotlinGradle {
standardOptions()
}
}
extensions.configure(IndraSpotlessLicenserExtension::class) {
val name: String by project
val organization: String by project
val projectUrl: String by project
licenseHeaderFile(rootProject.file("HEADER.txt"))
property("name", name)
property("organization", organization)
property("url", projectUrl)
}
extensions.findByType(IndraPluginPublishingExtension::class)?.apply {
pluginIdBase("$group.gradle")
website("https://spongepowered.org/")
}
extensions.findByType(CrossdocExtension::class)?.apply {
baseUrl(providers.gradleProperty("javadocLinkRoot"))
nameBasedDocumentationUrlProvider {
projectNamePrefix.set("spongegradle-")
lowercaseProjectName.set(true)
}
}
}