11plugins {
22 id " architectury-plugin" version " 3.4-SNAPSHOT"
3- id " dev.architectury.loom" version " 1.2 -SNAPSHOT" apply false
3+ id " dev.architectury.loom" version " 1.3 -SNAPSHOT" apply false
44 id " maven-publish"
55 id ' com.matthewprenger.cursegradle' version ' 1.4.0' apply false
66 id ' com.palantir.git-version' version ' 1.0.0'
77 id ' org.ajoberstar.grgit' version ' 5.2.0'
88 id ' se.bjurr.gitchangelog.git-changelog-gradle-plugin' version ' 1.79.0'
99 id " com.modrinth.minotaur" version " 2.+" apply false
1010 id(" com.diffplug.spotless" ) version " 6.18.0" apply false
11+ id ' modernfix.common-conventions' apply false
1112}
1213
1314architectury {
@@ -16,136 +17,7 @@ architectury {
1617
1718ext. archives_base_name = ' modernfix'
1819
19- allprojects {
20- apply plugin : " java"
21- apply plugin : " architectury-plugin"
22- apply plugin : " maven-publish"
23- apply plugin : " com.diffplug.spotless"
24-
25- spotless {
26- java {
27- removeUnusedImports()
28- }
29- }
30-
31- architectury {
32- compileOnly()
33- }
34-
35- group = ' org.embeddedt'
36- // extract base version from tag, generate other metadata ourselves
37- def details = versionDetails()
38- def plusIndex = details. lastTag. indexOf(" +" )
39- if (plusIndex == -1 ) {
40- plusIndex = details. lastTag. length()
41- }
42- def baseVersion = details. lastTag. substring(0 , plusIndex)
43- def dirtyMarker = grgit. status(). clean ? " " : " .dirty"
44- def commitHashMarker = details. commitDistance > 0 ? (" ." + details. gitHash. substring(0 , Math . min(4 , details. gitHash. length()))) : " "
45- def preMarker = (details. commitDistance > 0 || ! details. isCleanTag) ? (" -beta." + details. commitDistance) : " "
46- if (preMarker. length() > 0 ) {
47- // bump to next patch release
48- def versionParts = baseVersion. tokenize(" ." )
49- baseVersion = " ${ versionParts[0]} .${ versionParts[1]} .${ versionParts[2].toInteger() + 1} "
50- }
51- def versionString = " ${ baseVersion}${ preMarker} +mc${ minecraft_version}${ commitHashMarker}${ dirtyMarker} "
52- version = versionString
53- archivesBaseName = rootProject. archives_base_name + ' -' + project. name
54-
55- sourceCompatibility = targetCompatibility = JavaVersion . VERSION_17
56-
57- repositories {
58- maven { url ' https://modmaven.dev/' }
59- maven {
60- url " https://cursemaven.com"
61- content {
62- includeGroup " curse.maven"
63- }
64- }
65- maven {
66- name = ' ParchmentMC'
67- url = ' https://maven.parchmentmc.org'
68- }
69- maven {
70- // Shedaniel's maven (Architectury API)
71- url = " https://maven.architectury.dev"
72- content {
73- includeGroup " me.shedaniel"
74- }
75- }
76-
77- maven {
78- // saps.dev Maven (KubeJS and Rhino)
79- url = " https://maven.saps.dev/minecraft"
80- content {
81- includeGroup " dev.latvian.mods"
82- }
83- }
84- maven { // CTM
85- url " https://maven.tterrag.com/"
86- }
87- maven { url ' https://maven.blamejared.com' }
88- repositories {
89- maven {
90- name = " Fuzs Mod Resources"
91- url = " https://raw.githubusercontent.com/Fuzss/modresources/main/maven/"
92- }
93- }
94- maven {
95- url ' https://maven.terraformersmc.com/releases'
96- }
97- maven { url = " https://jitpack.io" }
98- }
99- }
100-
101- configure(subprojects. findAll {it. name == " common" || it. name == " forge" || it. name == " fabric" }) {
102- apply plugin : " dev.architectury.loom"
103-
104- loom {
105- silentMojangMappingsLicense()
106- }
107-
108- dependencies {
109- minecraft " com.mojang:minecraft:${ rootProject.minecraft_version} "
110- mappings loom. layered() {
111- officialMojangMappings()
112- if (rootProject. hasProperty(" parchment_version" )) {
113- parchment(" org.parchmentmc.data:parchment-${ minecraft_version} :${ parchment_version} @zip" )
114- }
115- }
116- }
117-
118- processResources {
119- def mixinFileList = []
120- def mixinDirectory = file(" src/main/java/org/embeddedt/modernfix/" + project. name + " /mixin" )
121- fileTree(mixinDirectory). visit { FileVisitDetails details ->
122- if (details. file. isFile()) {
123- def fileName = mixinDirectory. relativePath(details. file). toString(). replaceFirst(/ \. java$/ , " " ). replace(' /' , ' .' )
124- mixinFileList << fileName
125- }
126- }
127-
128- def mixinClassesStringB = new StringBuilder ()
129- for (int i = 0 ; i < mixinFileList. size(); i++ ) {
130- mixinClassesStringB. append(" \" " )
131- mixinClassesStringB. append(mixinFileList. get(i))
132- mixinClassesStringB. append(' "' )
133- if (i < (mixinFileList. size() - 1 ))
134- mixinClassesStringB. append(' ,' )
135- mixinClassesStringB. append(' \n ' )
136- }
137-
138- def replacements = [
139- mixin_classes : mixinClassesStringB. toString()
140- ]
141-
142- inputs. properties replacements
143- def filePattern = " modernfix-" + project. name + " .mixins.json"
144- filesMatching(filePattern) {
145- expand replacements
146- }
147- }
148- }
20+ apply plugin : ' modernfix.common-conventions'
14921
15022tasks. withType(JavaCompile ). configureEach {
15123 // ensure that the encoding is set to UTF-8, no matter what the system default is
@@ -192,74 +64,4 @@ tasks.register('checkCleanTag') {
19264 }
19365}
19466
195- configure(subprojects. findAll {it. name == " forge" || it. name == " fabric" }) {
196- apply plugin : ' com.matthewprenger.cursegradle'
197- apply plugin : ' com.modrinth.minotaur'
198-
199- loom {
200- mods {
201- main { // to match the default mod generated for Forge
202- sourceSet project. sourceSets. main
203- sourceSet project(' :common' ). sourceSets. main
204- }
205- }
206- runs {
207- client {
208- vmArgs " -Xmx1G"
209- vmArgs " -Xms1G"
210- property(" mixin.debug.export" , " true" )
211- }
212- }
213- }
214-
215- def copyJarNameConsistent = tasks. register(' copyJarNameConsistent' , Copy ) {
216- from remapJar // shortcut for createJar.outputs.files
217- into project. file(" build/libs" )
218- rename { name -> " modernfix-" + project. name + " -latest.jar" }
219- }
220-
221- def copyJarToBin = tasks. register(' copyJarToBin' , Copy ) {
222- from remapJar // shortcut for createJar.outputs.files
223- into rootProject. file(" bin" )
224- mustRunAfter " copyJarNameConsistent"
225- }
226-
227- tasks. build. dependsOn(copyJarToBin, copyJarNameConsistent)
228-
229- def isBeta = project. version. toString(). contains(" beta" )
230-
231- curseforge {
232- if (System . getenv(" CURSEFORGE_TOKEN" ) != null ) {
233- apiKey = System . getenv(" CURSEFORGE_TOKEN" )
234- project {
235- id = " 790626"
236- changelog = file(' ../CHANGELOG.md' )
237- changelogType = " markdown"
238- releaseType = isBeta ? " beta" : " release"
239- addGameVersion project. name. capitalize()
240- gameVersionStrings. addAll(supported_minecraft_versions. tokenize(" ," ))
241- mainArtifact remapJar
242- }
243- }
244- }
245-
246- modrinth {
247- token = System . getenv(" MODRINTH_TOKEN" )
248- projectId = " modernfix" // This can be the project ID or the slug. Either will work!
249- versionType = isBeta ? " beta" : " release" // This is the default -- can also be `beta` or `alpha`
250- uploadFile = remapJar
251- gameVersions = supported_minecraft_versions. tokenize(" ," )
252- loaders = [project. name]
253- changelog. set(provider { file(" CHANGELOG.md" ). getText(' UTF-8' ) })
254- }
255-
256- tasks. curseforge. dependsOn(rootProject. generateChangelog)
257- tasks. modrinth. dependsOn(rootProject. generateChangelog)
258-
259- tasks. register(' publishToModSites' ) {
260- publishToModSites. dependsOn(tasks. modrinth)
261- publishToModSites. dependsOn(tasks. curseforge)
262- }
263- }
264-
26567println " ModernFix: " + version
0 commit comments