Basic example
See the following minimal example showing how to publish the remapJar
task to Modrinth:
publishMods {
file = remapJar.archiveFile
changelog = "Changelog"
type = STABLE
modLoaders.add("fabric")
modrinth {
accessToken = providers.environmentVariable("MODRINTH_API_KEY")
projectId = "12345678"
minecraftVersions.add("1.20.1")
}
}
You will need to generate a Modrinth PAT token in your account settings here (opens in a new tab), you can set this an environment variable. If you plan to publish from your local machine using a Gradle user property may be more convenient:
You can use the gradle property provider like so:
providers.gradleProperty('CURSEFORGE_API_KEY')
Multiple projects
You can create multiple Modrinth destinations by providing a name like so:
publishMods {
modrinth("modrinthProjectA") {
// Configure Modrinth settings for project A here
}
modrinth("modrinthProjectB") {
// Configure Modrinth settings for project B here
}
}
All options
See the following example showing all the Modrinth specific options:
publishMods {
modrinth {
accessToken = providers.environmentVariable("MODRINTH_API_KEY")
projectId = "12345678"
minecraftVersions.add("1.20.1")
// Optionally set the announcement title used by the discord publisher
announcementTitle = "Download from Modrinth"
// Optionally update the project description after publishing a file
// This can be useful if you want to sync your Github readme with the Modrinth project description
projectDescription = providers.fileContents(layout.projectDirectory.file("readme.md")).asText
// You can specify a range of Minecraft versions like so:
minecraftVersionRange {
start = "1.19.4"
end = "1.20.2" // Set to "latest" to use the latest minecraft version
// Optionally include snapshot versions, defaults to false
includeSnapshots = true
}
// You can specify either the project id OR slug, but not both.
requires {
id = "12345678"
slug = "project-slug"
// You can optionally specify a version id for the dependency
version = "IIJJKKLL"
}
optional {
id = "12345678"
slug = "project-slug"
}
incompatible {
id = "12345678"
slug = "project-slug"
}
embeds {
id = "12345678"
slug = "project-slug"
}
// You can use the shortened method if you only need to specify the slug
requires("project-slug")
optional("project-slug")
incompatible("project-slug")
embeds("project-slug")
}
}