Skip to content

Commit

Permalink
build: update publishing plugin
Browse files Browse the repository at this point in the history
To https://github.com/modmuss50/mod-publish-plugin

Because minotaur plugin doesn't support the config cache.
  • Loading branch information
raoulvdberge committed Sep 10, 2024
1 parent c434b6f commit f0738f7
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 52 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ jobs:
- name: Setup Java
uses: refinedmods/refinedarchitect/.github/actions/setup-java@develop
- name: Deploy to CurseForge
run: ./gradlew publishCurseForge
run: ./gradlew publishCurseforge

deploy-modrinth:
name: Deploy to Modrinth
Expand All @@ -179,7 +179,7 @@ jobs:
- name: Setup Java
uses: refinedmods/refinedarchitect/.github/actions/setup-java@develop
- name: Deploy to Modrinth
run: ./gradlew modrinth
run: ./gradlew publishModrinth

announce-discord:
name: Announce to Discord
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Support for the Gradle config cache.

### Changed

- The CurseForge and Modrinth publishing has been updated to use modmuss' mod-publish-plugin.

## [0.18.0] - 2024-09-09

### Fixed
Expand Down
4 changes: 1 addition & 3 deletions refinedarchitect-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ dependencies {
implementation("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:1.1.8")
implementation("info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.15.0")
implementation("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:4.4.1.3373")
implementation("net.darkhax.curseforgegradle:CurseForgeGradle:1.1.18")
implementation("com.modrinth.minotaur:Minotaur:2.8.7")
implementation("me.modmuss50:mod-publish-plugin:0.7.3")
}

publishing {
Expand All @@ -44,6 +43,5 @@ publishing {
password = System.getenv("GITHUB_TOKEN")
}
}
mavenLocal()
}
}
98 changes: 52 additions & 46 deletions refinedarchitect-plugin/src/main/kotlin/BaseExtension.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import com.modrinth.minotaur.Minotaur
import com.modrinth.minotaur.ModrinthExtension
import info.solidsoft.gradle.pitest.PitestPlugin
import info.solidsoft.gradle.pitest.PitestPluginExtension
import net.darkhax.curseforgegradle.TaskPublishCurseForge
import me.modmuss50.mpp.ModPublishExtension
import me.modmuss50.mpp.MppPlugin
import me.modmuss50.mpp.ReleaseType
import net.fabricmc.loom.task.RemapJarTask
import org.gradle.api.Action
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.testing.Test
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.*
import org.sonarqube.gradle.SonarExtension
import org.sonarqube.gradle.SonarQubePlugin
Expand All @@ -25,49 +27,50 @@ open class BaseExtension(private val project: Project) {
if (options.maven == true) {
enableMavenPublishing()
}
options.curseForge?.let { enableCurseForgePublishing(it) }
options.modrinth?.let { enableModrinthPublishing(it) }
}

private fun enableCurseForgePublishing(projectId: String) {
project.tasks.register<TaskPublishCurseForge>("publishCurseForge") {
apiToken = System.getenv("CURSEFORGE_TOKEN")
val isNeoForge = project.pluginManager.hasPlugin("net.neoforged.moddev")
val mainFile = upload(projectId, project.tasks.getByName(if (isNeoForge) "jar" else "remapJar"))
mainFile.releaseType = if (project.version.toString().contains("beta")) "beta" else if (project.version.toString().contains("alpha")) "alpha" else "release"
mainFile.changelog = System.getenv("RELEASE_CHANGELOG")
mainFile.changelogType = "markdown"
mainFile.displayName = "v" + project.version.toString()
mainFile.addGameVersion(mcVersion)
// https://github.com/refinedmods/refinedarchitect/issues/149
if (isNeoForge) {
mainFile.addModLoader("NeoForge")
} else {
mainFile.addRequirement("fabric-api")
}
}
}

private fun enableModrinthPublishing(projId: String) {
project.plugins.apply(Minotaur::class.java)
val isNeoForge = project.pluginManager.hasPlugin("net.neoforged.moddev")
project.extensions.getByType<ModrinthExtension>().apply {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set(projId)
uploadFile = project.tasks.getByName(if (isNeoForge) "jar" else "remapJar")
versionType.set(if (project.version.toString().contains("beta")) "beta" else if (project.version.toString().contains("alpha")) "alpha" else "release")
versionNumber.set(project.version.toString())
versionName.set("v" + project.version)
// https://github.com/refinedmods/refinedarchitect/issues/149
if (isNeoForge) {
loaders.add("neoforge")
gameVersions.add(mcVersion)
} else {
dependencies.apply {
required.project("fabric-api")
if (options.curseForge != null || options.modrinth != null) {
project.plugins.apply(MppPlugin::class)
project.extensions.getByType(ModPublishExtension::class).apply {
val isNeoForge = project.pluginManager.hasPlugin("net.neoforged.moddev")
if (isNeoForge) {
val jar by project.tasks.getting(Jar::class)
file.set(jar.archiveFile)
modLoaders.add("NeoForge")
} else {
val remapJar by project.tasks.getting(RemapJarTask::class)
file.set(remapJar.archiveFile)
modLoaders.add("Fabric")
}
type.set(
if (project.version.toString()
.contains("beta")
) ReleaseType.BETA else if (project.version.toString()
.contains("alpha")
) ReleaseType.ALPHA else ReleaseType.STABLE
)
changelog.set(System.getenv("RELEASE_CHANGELOG"))
displayName.set("v" + project.version.toString())
options.curseForge?.let {
curseforge {
accessToken.set(System.getenv("CURSEFORGE_TOKEN"))
minecraftVersions.add(mcVersion)
changelogType.set("markdown")
projectId.set(it)
if (!isNeoForge) {
requires("fabric-api")
}
}
}
options.modrinth?.let {
modrinth {
accessToken.set(System.getenv("MODRINTH_TOKEN"))
projectId.set(it)
minecraftVersions.add(mcVersion)
if (!isNeoForge) {
requires("fabric-api")
}
}
}
}
changelog.set(System.getenv("RELEASE_CHANGELOG"))
}
}

Expand All @@ -81,7 +84,7 @@ open class BaseExtension(private val project: Project) {
coverageThreshold.set(80)
}
project.dependencies.add("testRuntimeOnly", "org.junit.platform:junit-platform-launcher")
?.because("required for pitest")
?.because("required for pitest")
}

fun testing() {
Expand Down Expand Up @@ -131,7 +134,10 @@ open class BaseExtension(private val project: Project) {
property("sonar.projectKey", projectKey)
property("sonar.organization", organization)
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.coverage.jacoco.xmlReportPaths", "${project.layout.buildDirectory.get()}/reports/jacoco/codeCoverageReportAggregate/codeCoverageReportAggregate.xml")
property(
"sonar.coverage.jacoco.xmlReportPaths",
"${project.layout.buildDirectory.get()}/reports/jacoco/codeCoverageReportAggregate/codeCoverageReportAggregate.xml"
)
}
}
}
Expand Down
1 change: 0 additions & 1 deletion refinedarchitect-versioning/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ publishing {
password = System.getenv("GITHUB_TOKEN")
}
}
mavenLocal()
}
publications {
create<MavenPublication>("maven") {
Expand Down

0 comments on commit f0738f7

Please sign in to comment.