|
1 | 1 | import com.diffplug.gradle.spotless.FormatExtension |
2 | 2 |
|
3 | 3 | plugins { |
| 4 | + `java-gradle-plugin` |
4 | 5 | eclipse |
| 6 | + signing |
5 | 7 | alias(libs.plugins.ideaExt) |
6 | | - alias(libs.plugins.indra) apply false |
7 | | - alias(libs.plugins.indra.publishing) apply false |
8 | | - alias(libs.plugins.indra.git) apply false |
| 8 | + alias(libs.plugins.indra) |
| 9 | + alias(libs.plugins.indra.git) |
9 | 10 | alias(libs.plugins.spotless) |
10 | | - alias(libs.plugins.indra.licenserSpotless) apply false |
11 | | - alias(libs.plugins.eclipseApt) apply false |
| 11 | + alias(libs.plugins.indra.licenserSpotless) |
| 12 | + alias(libs.plugins.gradlePluginPublish) |
| 13 | + alias(libs.plugins.indra.publishing.gradlePlugin) |
| 14 | + alias(libs.plugins.blossom) |
| 15 | + alias(libs.plugins.eclipseApt) |
12 | 16 | } |
13 | 17 |
|
14 | 18 | group = "org.spongepowered" |
15 | 19 | version = "0.3.1-SNAPSHOT" |
16 | 20 |
|
| 21 | +val commonDeps by configurations.creating { |
| 22 | +} |
| 23 | +val jarMerge by sourceSets.creating { |
| 24 | + configurations.named(this.implementationConfigurationName) { extendsFrom(commonDeps) } |
| 25 | +} |
| 26 | +val jarDecompile by sourceSets.creating { |
| 27 | + configurations.named(this.implementationConfigurationName) { extendsFrom(commonDeps) } |
| 28 | +} |
| 29 | +val accessWiden by sourceSets.creating { |
| 30 | + configurations.named(this.implementationConfigurationName) { extendsFrom(commonDeps) } |
| 31 | +} |
| 32 | +val shadow by sourceSets.creating { |
| 33 | + configurations.named(this.implementationConfigurationName) { extendsFrom(commonDeps) } |
| 34 | +} |
17 | 35 |
|
18 | | -spotless { |
19 | | - format("configs") { |
20 | | - target("**/*.yaml", "**/*.yml", "**/*.xml", "**/*.json") |
| 36 | +configurations { |
| 37 | + api { extendsFrom(commonDeps) } |
| 38 | +} |
21 | 39 |
|
22 | | - val excludedTargets = mutableListOf(".idea/**", "build/**", ".gradle/**") |
23 | | - project.subprojects { |
24 | | - excludedTargets.add(projectDir.toRelativeString(rootDir) + "/**") |
25 | | - } |
26 | | - targetExclude(excludedTargets) |
| 40 | +val accessWidenerVersion: String by project |
| 41 | +val asmVersion: String by project |
| 42 | +val checkerVersion: String by project |
| 43 | +val vineFlowerVersion: String by project |
| 44 | +val junitVersion: String by project |
| 45 | +val mergeToolVersion: String by project |
| 46 | +dependencies { |
| 47 | + // All source sets |
| 48 | + commonDeps(gradleApi()) |
| 49 | + commonDeps(libs.asm) |
| 50 | + commonDeps(libs.asm.commons) |
| 51 | + commonDeps(libs.asm.util) |
| 52 | + commonDeps(libs.mammoth) |
| 53 | + |
| 54 | + // Just main |
| 55 | + implementation(libs.gson) |
| 56 | + |
| 57 | + compileOnlyApi(libs.checkerQual) |
| 58 | + annotationProcessor(libs.immutables.value) |
| 59 | + compileOnlyApi(variantOf(libs.immutables.value) { classifier("annotations") }) |
| 60 | + api(libs.immutables.gson) |
| 61 | + |
| 62 | + // IDE support |
| 63 | + implementation(libs.ideaExt) |
| 64 | + |
| 65 | + // Jar merge worker (match with Constants) |
| 66 | + "jarMergeCompileOnly"(libs.mergeTool) { |
| 67 | + exclude("org.ow2.asm") |
| 68 | + } |
| 69 | + implementation(jarMerge.output) |
27 | 70 |
|
28 | | - endWithNewline() |
29 | | - trimTrailingWhitespace() |
| 71 | + // Jar decompile worker (match with Constants) |
| 72 | + "jarDecompileCompileOnly"(libs.vineFlower) |
| 73 | + implementation(jarDecompile.output) |
| 74 | + |
| 75 | + // Access widener worker (match with Constants) |
| 76 | + "accessWidenCompileOnly"(libs.accessWidener) { |
| 77 | + exclude("org.ow2.asm") |
30 | 78 | } |
| 79 | + implementation(accessWiden.output) |
| 80 | + |
| 81 | + "shadowCompileOnly"(libs.shadowPlugin) |
| 82 | + implementation(shadow.output) |
| 83 | + |
| 84 | + testImplementation(platform(libs.junit.bom)) |
| 85 | + testImplementation(libs.junit.api) |
| 86 | + testRuntimeOnly(libs.junit.launcher) |
| 87 | + testRuntimeOnly(libs.junit.engine) |
31 | 88 | } |
32 | 89 |
|
33 | | -subprojects { |
34 | | - apply(plugin="net.kyori.indra") |
35 | | - apply(plugin="net.kyori.indra.licenser.spotless") |
36 | | - apply(plugin="net.kyori.indra.git") |
37 | | - apply(plugin="com.diffplug.eclipse.apt") |
38 | | - apply(plugin="signing") |
| 90 | +sourceSets.main { |
| 91 | + blossom.javaSources { |
| 92 | + properties.putAll(mutableMapOf( |
| 93 | + "asmVersion" to libs.versions.asm.get(), |
| 94 | + "vineFlowerVersion" to libs.versions.vineFlower.get(), |
| 95 | + "mergeToolVersion" to libs.versions.mergeTool.get(), |
| 96 | + "accessWidenerVersion" to libs.versions.accessWidener.get() |
| 97 | + )) |
| 98 | + } |
| 99 | +} |
39 | 100 |
|
40 | | - extensions.configure(net.kyori.indra.IndraExtension::class) { |
41 | | - github("SpongePowered", "VanillaGradle") { |
42 | | - ci(true) |
43 | | - } |
44 | | - mitLicense() |
| 101 | +tasks { |
| 102 | + withType(Jar::class).configureEach { |
| 103 | + // project.extensions.getByType(net.kyori.indra.git.IndraGitExtension::class).applyVcsInformationToManifest(manifest) |
| 104 | + manifest.attributes( |
| 105 | + "Specification-Title" to "VanillaGradle", |
| 106 | + "Specification-Vendor" to "SpongePowered", |
| 107 | + "Specification-Version" to project.version, |
| 108 | + "Implementation-Title" to project.name, |
| 109 | + "Implementation-Version" to project.version, |
| 110 | + "Implementation-Vendor" to "SpongePowered" |
| 111 | + ) |
| 112 | + } |
45 | 113 |
|
46 | | - javaVersions { |
47 | | - target(25) |
48 | | - } |
| 114 | + withType(JavaCompile::class).configureEach { |
| 115 | + options.compilerArgs.addAll(listOf("-Xlint:-processing", "-Xlint:-this-escape")) |
| 116 | + } |
| 117 | + |
| 118 | + jar { |
| 119 | + from(jarMerge.output) |
| 120 | + from(jarDecompile.output) |
| 121 | + from(accessWiden.output) |
| 122 | + from(shadow.output) |
| 123 | + } |
| 124 | + |
| 125 | + publishPlugins { |
| 126 | + onlyIf { net.kyori.indra.util.Versioning.isRelease(project) } |
| 127 | + } |
| 128 | +} |
| 129 | + |
| 130 | +indraPluginPublishing { |
| 131 | + website("https://spongepowered.org") |
| 132 | + bundleTags(listOf("minecraft", "vanilla")) |
| 133 | + plugin( |
| 134 | + /* id = */ "gradle.vanilla", |
| 135 | + /* mainClass = */ "org.spongepowered.gradle.vanilla.VanillaGradle", |
| 136 | + /* displayName = */ "VanillaGradle", |
| 137 | + /* description = */ "Set up a Minecraft workspace for project development" |
| 138 | + ) |
| 139 | +} |
| 140 | + |
| 141 | +extensions.configure(net.kyori.indra.IndraExtension::class) { |
| 142 | + github("SpongePowered", "VanillaGradle") { |
| 143 | + ci(true) |
| 144 | + } |
| 145 | + mitLicense() |
| 146 | + |
| 147 | + javaVersions { |
| 148 | + target(25) |
| 149 | + } |
49 | 150 |
|
50 | | - configurePublications { |
51 | | - pom { |
52 | | - organization { |
53 | | - name.set("SpongePowered") |
54 | | - url.set("https://spongepowered.org") |
55 | | - } |
| 151 | + configurePublications { |
| 152 | + pom { |
| 153 | + organization { |
| 154 | + name.set("SpongePowered") |
| 155 | + url.set("https://spongepowered.org") |
56 | 156 | } |
57 | 157 | } |
| 158 | + } |
58 | 159 |
|
59 | | - signWithKeyFromPrefixedProperties("sponge") |
60 | | - if ( |
61 | | - project.hasProperty("spongeSnapshotRepo") && |
62 | | - project.hasProperty("spongeReleaseRepo") |
63 | | - ) { |
64 | | - publishSnapshotsTo("sponge", project.property("spongeSnapshotRepo") as String) |
65 | | - publishReleasesTo("sponge", project.property("spongeReleaseRepo") as String) |
66 | | - } |
| 160 | + signWithKeyFromPrefixedProperties("sponge") |
| 161 | + if ( |
| 162 | + project.hasProperty("spongeSnapshotRepo") && |
| 163 | + project.hasProperty("spongeReleaseRepo") |
| 164 | + ) { |
| 165 | + publishSnapshotsTo("sponge", project.property("spongeSnapshotRepo") as String) |
| 166 | + publishReleasesTo("sponge", project.property("spongeReleaseRepo") as String) |
67 | 167 | } |
| 168 | +} |
68 | 169 |
|
69 | | - extensions.configure(net.kyori.indra.licenser.spotless.IndraSpotlessLicenserExtension::class) { |
70 | | - val organization: String by project |
71 | | - val projectUrl: String by project |
| 170 | +extensions.configure(net.kyori.indra.licenser.spotless.IndraSpotlessLicenserExtension::class) { |
| 171 | + val organization: String by project |
| 172 | + val projectUrl: String by project |
72 | 173 |
|
73 | | - properties().apply { |
74 | | - put("name", "VanillaGradle") |
75 | | - put("organization", organization) |
76 | | - put("url", projectUrl) |
77 | | - } |
78 | | - licenseHeaderFile(rootProject.file("HEADER.txt")) |
| 174 | + properties().apply { |
| 175 | + put("name", "VanillaGradle") |
| 176 | + put("organization", organization) |
| 177 | + put("url", projectUrl) |
79 | 178 | } |
| 179 | + licenseHeaderFile(rootProject.file("HEADER.txt")) |
| 180 | +} |
80 | 181 |
|
81 | | - spotless { |
82 | | - fun FormatExtension.applyCommonSettings() { |
83 | | - endWithNewline() |
84 | | - indentWithSpaces(4) |
85 | | - trimTrailingWhitespace() |
86 | | - toggleOffOn("@formatter:off", "@formatter:on") |
87 | | - } |
| 182 | +spotless { |
| 183 | + fun FormatExtension.applyCommonSettings() { |
| 184 | + endWithNewline() |
| 185 | + indentWithSpaces(4) |
| 186 | + trimTrailingWhitespace() |
| 187 | + toggleOffOn("@formatter:off", "@formatter:on") |
| 188 | + } |
88 | 189 |
|
89 | | - java { |
90 | | - targetExclude("build/generated/**") |
91 | | - applyCommonSettings() |
92 | | - importOrderFile(rootProject.file(".spotless/sponge.importorder")) |
93 | | - } |
| 190 | + java { |
| 191 | + targetExclude("build/generated/**") |
| 192 | + applyCommonSettings() |
| 193 | + importOrderFile(rootProject.file(".spotless/sponge.importorder")) |
| 194 | + } |
94 | 195 |
|
95 | | - kotlinGradle { |
96 | | - applyCommonSettings() |
97 | | - // ktlint() |
98 | | - // .editorConfigOverride(mapOf("ij_kotlin_imports_layout" to "$*,|,*,|,java.**,|,javax.**")) |
99 | | - } |
| 196 | + kotlinGradle { |
| 197 | + applyCommonSettings() |
| 198 | + // ktlint() |
| 199 | + // .editorConfigOverride(mapOf("ij_kotlin_imports_layout" to "$*,|,*,|,java.**,|,javax.**")) |
100 | 200 | } |
101 | 201 |
|
102 | | - tasks { |
103 | | - withType(Jar::class).configureEach { |
104 | | - // project.extensions.getByType(net.kyori.indra.git.IndraGitExtension::class).applyVcsInformationToManifest(manifest) |
105 | | - manifest.attributes( |
106 | | - "Specification-Title" to "VanillaGradle", |
107 | | - "Specification-Vendor" to "SpongePowered", |
108 | | - "Specification-Version" to project.version, |
109 | | - "Implementation-Title" to project.name, |
110 | | - "Implementation-Version" to project.version, |
111 | | - "Implementation-Vendor" to "SpongePowered" |
112 | | - ) |
113 | | - } |
| 202 | + format("configs") { |
| 203 | + target("**/*.yaml", "**/*.yml", "**/*.xml", "**/*.json") |
| 204 | + targetExclude(".idea/**", "build/**", ".gradle/**", "src/test/**") |
114 | 205 |
|
115 | | - withType(JavaCompile::class).configureEach { |
116 | | - options.compilerArgs.addAll(listOf("-Xlint:-processing", "-Xlint:-this-escape")) |
117 | | - } |
| 206 | + endWithNewline() |
| 207 | + trimTrailingWhitespace() |
118 | 208 | } |
119 | 209 | } |
0 commit comments