Skip to content

Commit fcd6663

Browse files
committed
Move curseforge/modrinth code into common file
1 parent cfd3920 commit fcd6663

File tree

4 files changed

+43
-73
lines changed

4 files changed

+43
-73
lines changed

build.gradle

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
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'
7+
id 'org.ajoberstar.grgit' version '5.2.0'
78
id 'se.bjurr.gitchangelog.git-changelog-gradle-plugin' version '1.79.0'
89
id "com.modrinth.minotaur" version "2.+" apply false
910
id("com.diffplug.spotless") version "6.18.0" apply false
@@ -35,7 +36,7 @@ allprojects {
3536
plusIndex = details.lastTag.length()
3637
}
3738
def baseVersion = details.lastTag.substring(0, plusIndex)
38-
def dirtyMarker = details.isCleanTag ? "" : ".dirty"
39+
def dirtyMarker = grgit.status().clean ? "" : ".dirty"
3940
def commitHashMarker = details.commitDistance > 0 ? ("." + details.gitHash) : ""
4041
def preMarker = (details.commitDistance > 0 || !details.isCleanTag) ? ("-beta." + details.commitDistance) : ""
4142
def versionString = "${baseVersion}${preMarker}+mc${minecraft_version}${commitHashMarker}${dirtyMarker}"
@@ -175,4 +176,44 @@ tasks.register('checkCleanTag') {
175176
throw new GradleException('Not a clean tree.')
176177
}
177178
}
179+
}
180+
181+
configure(subprojects.findAll {it.name == "forge" || it.name == "fabric"}) {
182+
apply plugin: 'com.matthewprenger.cursegradle'
183+
apply plugin: 'com.modrinth.minotaur'
184+
185+
def isBeta = project.version.toString().contains("beta")
186+
187+
curseforge {
188+
if (System.getenv("CURSEFORGE_TOKEN") != null) {
189+
apiKey = System.getenv("CURSEFORGE_TOKEN")
190+
project {
191+
id = "790626"
192+
changelog = file('CHANGELOG.md')
193+
changelogType = "markdown"
194+
releaseType = isBeta ? "beta" : "release"
195+
addGameVersion project.name
196+
gameVersionStrings.addAll(supported_minecraft_versions.tokenize(","))
197+
mainArtifact remapJar
198+
}
199+
}
200+
}
201+
202+
modrinth {
203+
token = System.getenv("MODRINTH_TOKEN")
204+
projectId = "modernfix" // This can be the project ID or the slug. Either will work!
205+
versionType = isBeta ? "beta" : "release" // This is the default -- can also be `beta` or `alpha`
206+
uploadFile = remapJar
207+
gameVersions = supported_minecraft_versions.tokenize(",")
208+
loaders = [project.name]
209+
changelog.set(provider { file("CHANGELOG.md").getText('UTF-8') })
210+
}
211+
212+
tasks.curseforge.dependsOn(rootProject.generateChangelog)
213+
tasks.modrinth.dependsOn(rootProject.generateChangelog)
214+
215+
tasks.register('publishToModSites') {
216+
publishToModSites.dependsOn(tasks.modrinth)
217+
publishToModSites.dependsOn(tasks.curseforge)
218+
}
178219
}

fabric/build.gradle

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ plugins {
22
id "com.github.johnrengelman.shadow" version "7.1.2"
33
}
44

5-
apply plugin: 'com.matthewprenger.cursegradle'
6-
apply plugin: 'com.modrinth.minotaur'
7-
85
architectury {
96
platformSetupLoomIde()
107
fabric()
@@ -95,37 +92,4 @@ publishing {
9592
repositories {
9693
// Add repositories to publish to here.
9794
}
98-
}
99-
100-
curseforge {
101-
if (System.getenv("CURSEFORGE_TOKEN") != null) {
102-
apiKey = System.getenv("CURSEFORGE_TOKEN")
103-
project {
104-
id = "790626"
105-
changelog = file('../CHANGELOG.md')
106-
changelogType = "markdown"
107-
releaseType = "beta"
108-
addGameVersion "Fabric"
109-
addGameVersion minecraft_version
110-
mainArtifact remapJar
111-
}
112-
}
113-
}
114-
115-
modrinth {
116-
token = System.getenv("MODRINTH_TOKEN")
117-
projectId = "modernfix" // This can be the project ID or the slug. Either will work!
118-
versionType = "beta" // This is the default -- can also be `beta` or `alpha`
119-
uploadFile = remapJar
120-
gameVersions = [minecraft_version]
121-
loaders = ["fabric"]
122-
changelog.set(provider { file("../CHANGELOG.md").getText('UTF-8') })
123-
}
124-
125-
tasks.curseforge.dependsOn(rootProject.generateChangelog)
126-
tasks.modrinth.dependsOn(rootProject.generateChangelog)
127-
128-
tasks.register('publishToModSites') {
129-
publishToModSites.dependsOn(tasks.modrinth)
130-
publishToModSites.dependsOn(tasks.curseforge)
13195
}

forge/build.gradle

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ plugins {
22
id "com.github.johnrengelman.shadow" version "7.1.2"
33
}
44

5-
apply plugin: 'com.matthewprenger.cursegradle'
6-
apply plugin: 'com.modrinth.minotaur'
7-
85
architectury {
96
platformSetupLoomIde()
107
forge()
@@ -121,37 +118,4 @@ publishing {
121118
repositories {
122119
// Add repositories to publish to here.
123120
}
124-
}
125-
126-
curseforge {
127-
if (System.getenv("CURSEFORGE_TOKEN") != null) {
128-
apiKey = System.getenv("CURSEFORGE_TOKEN")
129-
project {
130-
id = "790626"
131-
changelog = file('../CHANGELOG.md')
132-
changelogType = "markdown"
133-
releaseType = "release"
134-
addGameVersion "Forge"
135-
addGameVersion minecraft_version
136-
mainArtifact remapJar
137-
}
138-
}
139-
}
140-
141-
modrinth {
142-
token = System.getenv("MODRINTH_TOKEN")
143-
projectId = "modernfix" // This can be the project ID or the slug. Either will work!
144-
versionType = "release" // This is the default -- can also be `beta` or `alpha`
145-
uploadFile = remapJar
146-
gameVersions = [minecraft_version]
147-
loaders = ["forge"]
148-
changelog.set(provider { file("../CHANGELOG.md").getText('UTF-8') })
149-
}
150-
151-
tasks.curseforge.dependsOn(rootProject.generateChangelog)
152-
tasks.modrinth.dependsOn(rootProject.generateChangelog)
153-
154-
tasks.register('publishToModSites') {
155-
publishToModSites.dependsOn(tasks.modrinth)
156-
publishToModSites.dependsOn(tasks.curseforge)
157121
}

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jei_version=7.7.1.153
1212
refined_storage_version=3807951
1313
kubejs_version=1605.3.19-build.299
1414
ctm_version=MC1.16.1-1.1.2.6
15+
supported_minecraft_versions=1.16.4,1.16.5
1516

1617
fabric_loader_version=0.14.18
1718
fabric_api_version=0.42.0+1.16

0 commit comments

Comments
 (0)