|
1 |
| -import net.fabricmc.loom.api.LoomGradleExtensionAPI |
2 |
| -import net.fabricmc.loom.task.RemapJarTask |
3 |
| - |
4 | 1 | plugins {
|
5 |
| - `kotlin-dsl` |
6 |
| - java |
7 |
| - `maven-publish` |
8 |
| - alias(libs.plugins.loom) apply false |
9 |
| - alias(libs.plugins.architectury) |
10 |
| - alias(libs.plugins.shadow) |
| 2 | + alias(libs.plugins.neogradle) |
11 | 3 | alias(libs.plugins.spotless)
|
12 | 4 | }
|
13 | 5 |
|
14 |
| -val modId: String by project |
15 |
| -val modVersion = (System.getenv("MEGA_VERSION") ?: "v0.0.0").substring(1) |
16 |
| -val minecraftVersion = libs.versions.minecraft.get() |
| 6 | +val modId = "megacells" |
17 | 7 |
|
18 |
| -val platforms by extra { |
19 |
| - property("enabledPlatforms").toString().split(',') |
20 |
| -} |
| 8 | +base.archivesName = modId |
| 9 | +version = System.getenv("MEGA_VERSION") ?: "0.0.0" |
| 10 | +group = "gripe.90" |
21 | 11 |
|
22 |
| -tasks { |
23 |
| - register("releaseInfo") { |
24 |
| - doLast { |
25 |
| - val output = System.getenv("GITHUB_OUTPUT") |
| 12 | +java.toolchain.languageVersion = JavaLanguageVersion.of(17) |
26 | 13 |
|
27 |
| - if (!output.isNullOrEmpty()) { |
28 |
| - val outputFile = File(output) |
29 |
| - outputFile.appendText("MOD_VERSION=$modVersion\n") |
30 |
| - outputFile.appendText("MINECRAFT_VERSION=$minecraftVersion\n") |
31 |
| - } |
| 14 | +repositories { |
| 15 | + mavenLocal() |
| 16 | + mavenCentral() |
| 17 | + |
| 18 | + maven { |
| 19 | + name = "ModMaven (K4U-NL)" |
| 20 | + url = uri("https://modmaven.dev/") |
| 21 | + content { |
| 22 | + includeGroup("appeng") |
32 | 23 | }
|
33 | 24 | }
|
34 | 25 |
|
35 |
| - withType<Jar> { |
36 |
| - enabled = false |
| 26 | + maven { |
| 27 | + name = "Modrinth Maven" |
| 28 | + url = uri("https://api.modrinth.com/maven") |
| 29 | + content { |
| 30 | + includeGroup("maven.modrinth") |
| 31 | + } |
37 | 32 | }
|
38 | 33 | }
|
39 | 34 |
|
40 |
| -subprojects { |
41 |
| - apply(plugin = "java") |
42 |
| - apply(plugin = rootProject.libs.plugins.architectury.get().pluginId) |
43 |
| - apply(plugin = rootProject.libs.plugins.loom.get().pluginId) |
44 |
| - apply(plugin = rootProject.libs.plugins.spotless.get().pluginId) |
45 |
| - |
46 |
| - base.archivesName.set("$modId-${project.name}") |
47 |
| - version = "$modVersion-$minecraftVersion" |
48 |
| - group = property("mavenGroup").toString() |
49 |
| - |
50 |
| - val javaVersion: String by project |
51 |
| - |
52 |
| - java { |
53 |
| - sourceCompatibility = JavaVersion.valueOf("VERSION_$javaVersion") |
54 |
| - targetCompatibility = JavaVersion.valueOf("VERSION_$javaVersion") |
| 35 | +dependencies { |
| 36 | + implementation(libs.neoforge) |
| 37 | + implementation(libs.ae2) |
55 | 38 |
|
56 |
| - withSourcesJar() |
57 |
| - } |
| 39 | + implementation(libs.ae2wtlib) |
| 40 | + runtimeOnly(libs.curios) |
| 41 | +} |
58 | 42 |
|
59 |
| - architectury { |
60 |
| - minecraft = minecraftVersion |
61 |
| - injectInjectables = false |
| 43 | +sourceSets { |
| 44 | + main { |
| 45 | + resources.srcDir(file("src/generated/resources")) |
62 | 46 | }
|
63 |
| - |
64 |
| - configure<LoomGradleExtensionAPI> { |
65 |
| - silentMojangMappingsLicense() |
66 |
| - |
67 |
| - @Suppress("UnstableApiUsage") |
68 |
| - mixin.defaultRefmapName.set("$modId.refmap.json") |
| 47 | + |
| 48 | + create("data") { |
| 49 | + val main = main.get() |
| 50 | + compileClasspath += main.compileClasspath + main.output |
| 51 | + runtimeClasspath += main.runtimeClasspath + main.output |
69 | 52 | }
|
| 53 | +} |
70 | 54 |
|
71 |
| - repositories { |
72 |
| - mavenLocal() |
73 |
| - mavenCentral() |
74 |
| - |
75 |
| - maven { |
76 |
| - name = "ModMaven (K4U-NL)" |
77 |
| - url = uri("https://modmaven.dev/") |
78 |
| - content { |
79 |
| - includeGroup("appeng") |
80 |
| - includeGroup("mezz.jei") |
81 |
| - } |
82 |
| - } |
83 |
| - |
84 |
| - maven { |
85 |
| - name = "BlameJared" |
86 |
| - url = uri("https://maven.blamejared.com") |
87 |
| - content { |
88 |
| - includeGroup("vazkii.botania") |
89 |
| - includeGroup("vazkii.patchouli") |
90 |
| - } |
91 |
| - } |
92 |
| - |
93 |
| - maven { |
94 |
| - name = "Modrinth Maven" |
95 |
| - url = uri("https://api.modrinth.com/maven") |
96 |
| - content { |
97 |
| - includeGroup("maven.modrinth") |
98 |
| - } |
99 |
| - } |
| 55 | +runs { |
| 56 | + configureEach { |
| 57 | + workingDirectory(file("run")) |
| 58 | + systemProperty("forge.logging.console.level", "info") |
| 59 | + |
| 60 | + modSource(sourceSets.main.get()) |
100 | 61 | }
|
101 |
| - |
102 |
| - dependencies { |
103 |
| - "minecraft"(rootProject.libs.minecraft) |
104 |
| - "mappings"(project.extensions.getByName<LoomGradleExtensionAPI>("loom").officialMojangMappings()) |
| 62 | + |
| 63 | + create("client") |
| 64 | + create("server") |
| 65 | + |
| 66 | + create("data") { |
| 67 | + programArguments.addAll( |
| 68 | + "--mod", modId, |
| 69 | + "--all", |
| 70 | + "--output", file("src/generated/resources/").absolutePath, |
| 71 | + "--existing", file("src/main/resources/").absolutePath) |
| 72 | + |
| 73 | + modSource(sourceSets.getByName("data")) |
105 | 74 | }
|
| 75 | +} |
106 | 76 |
|
107 |
| - sourceSets { |
108 |
| - create("data") { |
109 |
| - val main = sourceSets.main.get() |
110 |
| - compileClasspath += main.compileClasspath + main.output |
111 |
| - runtimeClasspath += main.runtimeClasspath + main.output |
| 77 | +tasks { |
| 78 | + jar { |
| 79 | + from(rootProject.file("LICENSE")) { |
| 80 | + rename { "${it}_$modId" } |
112 | 81 | }
|
113 | 82 | }
|
114 | 83 |
|
115 |
| - tasks { |
116 |
| - jar { |
117 |
| - from(rootProject.file("LICENSE")) { |
118 |
| - rename { "${it}_$modId"} |
119 |
| - } |
120 |
| - } |
121 |
| - |
122 |
| - withType<JavaCompile> { |
123 |
| - options.encoding = "UTF-8" |
124 |
| - options.release.set(javaVersion.toInt()) |
125 |
| - } |
| 84 | + withType<JavaCompile> { |
| 85 | + options.encoding = "UTF-8" |
126 | 86 | }
|
127 |
| - |
128 |
| - spotless { |
129 |
| - kotlinGradle { |
130 |
| - target("*.kts") |
131 |
| - diktat() |
132 |
| - } |
133 |
| - |
134 |
| - java { |
135 |
| - target("src/**/java/**/*.java") |
136 |
| - endWithNewline() |
137 |
| - indentWithSpaces(4) |
138 |
| - removeUnusedImports() |
139 |
| - palantirJavaFormat() |
140 |
| - importOrderFile(rootProject.file("codeformat/mega.importorder")) |
141 |
| - |
142 |
| - // courtesy of diffplug/spotless#240 |
143 |
| - // https://github.com/diffplug/spotless/issues/240#issuecomment-385206606 |
144 |
| - custom("noWildcardImports") { |
145 |
| - if (it.contains("*;\n")) { |
146 |
| - throw Error("No wildcard imports allowed") |
147 |
| - } |
148 |
| - |
149 |
| - it |
150 |
| - } |
151 |
| - |
152 |
| - bumpThisNumberIfACustomStepChanges(1) |
153 |
| - } |
154 |
| - |
155 |
| - json { |
156 |
| - target("src/**/resources/**/*.json") |
157 |
| - targetExclude("src/generated/resources/**") |
158 |
| - biome() |
159 |
| - indentWithSpaces(2) |
160 |
| - endWithNewline() |
| 87 | + |
| 88 | + processResources { |
| 89 | + exclude("**/.cache") |
| 90 | + |
| 91 | + val props = mapOf( |
| 92 | + "version" to version, |
| 93 | + "ae2Version" to libs.versions.ae2.get(), |
| 94 | + "ae2VersionEnd" to libs.versions.ae2.get().substringBefore('.').toInt() + 1, |
| 95 | + ) |
| 96 | + |
| 97 | + inputs.properties(props) |
| 98 | + filesMatching("META-INF/mods.toml") { |
| 99 | + expand(props) |
161 | 100 | }
|
162 | 101 | }
|
163 | 102 | }
|
164 | 103 |
|
165 |
| -for (platform in platforms) { |
166 |
| - project(":$platform") { |
167 |
| - apply(plugin = rootProject.libs.plugins.shadow.get().pluginId) |
168 |
| - |
169 |
| - architectury { |
170 |
| - platformSetupLoomIde() |
171 |
| - loader(platform) |
172 |
| - } |
173 |
| - |
174 |
| - fun capitalise(str: String): String { |
175 |
| - return str.replaceFirstChar { |
176 |
| - if (it.isLowerCase()) { |
177 |
| - it.titlecase() |
178 |
| - } else { |
179 |
| - it.toString() |
180 |
| - } |
181 |
| - } |
182 |
| - } |
183 |
| - |
184 |
| - val common: Configuration by configurations.creating |
185 |
| - val shadowCommon: Configuration by configurations.creating |
186 |
| - |
187 |
| - @Suppress("UnstableApiUsage") |
188 |
| - configurations { |
189 |
| - compileClasspath { extendsFrom(common) } |
190 |
| - runtimeClasspath { extendsFrom(common) } |
191 |
| - getByName("development${capitalise(platform)}") { extendsFrom(common) } |
192 |
| - } |
193 |
| - |
194 |
| - dependencies { |
195 |
| - common(project(path = ":common", configuration = "namedElements")) { |
196 |
| - isTransitive = false |
197 |
| - } |
| 104 | +spotless { |
| 105 | + kotlinGradle { |
| 106 | + target("*.kts") |
| 107 | + diktat() |
| 108 | + } |
198 | 109 |
|
199 |
| - shadowCommon(project(path = ":common", configuration = "transformProduction${capitalise(platform)}")) { |
200 |
| - isTransitive = false |
201 |
| - } |
202 |
| - } |
| 110 | + java { |
| 111 | + target("/src/**/java/**/*.java") |
| 112 | + endWithNewline() |
| 113 | + indentWithSpaces(4) |
| 114 | + removeUnusedImports() |
| 115 | + palantirJavaFormat() |
| 116 | + importOrderFile(file("mega.importorder")) |
203 | 117 |
|
204 |
| - sourceSets { |
205 |
| - main { |
206 |
| - resources { |
207 |
| - srcDir(file("src/generated/resources")) |
208 |
| - exclude("**/.cache") |
209 |
| - } |
| 118 | + // courtesy of diffplug/spotless#240 |
| 119 | + // https://github.com/diffplug/spotless/issues/240#issuecomment-385206606 |
| 120 | + custom("noWildcardImports") { |
| 121 | + if (it.contains("*;\n")) { |
| 122 | + throw Error("No wildcard imports allowed") |
210 | 123 | }
|
211 | 124 |
|
212 |
| - getByName("data") { |
213 |
| - val commonData = project(":common").sourceSets.getByName("data") |
214 |
| - compileClasspath += commonData.output |
215 |
| - runtimeClasspath += commonData.output |
216 |
| - } |
| 125 | + it |
217 | 126 | }
|
218 | 127 |
|
219 |
| - tasks { |
220 |
| - processResources { |
221 |
| - val commonProps by extra { mapOf( |
222 |
| - "version" to project.version, |
223 |
| - "minecraftVersion" to minecraftVersion, |
224 |
| - "ae2Version" to rootProject.libs.versions.ae2.get(), |
225 |
| - "ae2wtVersion" to rootProject.libs.versions.ae2wtlib.get(), |
226 |
| - "appbotVersion" to rootProject.libs.versions.appbot.get()) |
227 |
| - } |
228 |
| - |
229 |
| - inputs.properties(commonProps) |
230 |
| - } |
231 |
| - |
232 |
| - shadowJar { |
233 |
| - exclude("architectury.common.json") |
234 |
| - configurations = listOf(shadowCommon) |
235 |
| - archiveClassifier.set("dev-shadow") |
236 |
| - } |
237 |
| - |
238 |
| - withType<RemapJarTask> { |
239 |
| - inputFile.set(shadowJar.get().archiveFile) |
240 |
| - dependsOn(shadowJar) |
241 |
| - archiveClassifier.set(null as String?) |
242 |
| - } |
243 |
| - |
244 |
| - jar { |
245 |
| - archiveClassifier.set("dev") |
246 |
| - } |
247 |
| - |
248 |
| - getByName<Jar>("sourcesJar") { |
249 |
| - val commonSources = project(":common").tasks.getByName<Jar>("sourcesJar") |
250 |
| - dependsOn(commonSources) |
251 |
| - from(commonSources.archiveFile.map { zipTree(it) }) |
252 |
| - } |
253 |
| - } |
| 128 | + bumpThisNumberIfACustomStepChanges(1) |
| 129 | + } |
254 | 130 |
|
255 |
| - val javaComponent = components["java"] as AdhocComponentWithVariants |
256 |
| - javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) { |
257 |
| - skip() |
258 |
| - } |
| 131 | + json { |
| 132 | + target("src/**/resources/**/*.json") |
| 133 | + targetExclude("src/generated/resources/**") |
| 134 | + biome() |
| 135 | + indentWithSpaces(2) |
| 136 | + endWithNewline() |
259 | 137 | }
|
260 | 138 | }
|
0 commit comments