Publishing
Maven
The maven-publish plugin is automatically applied and a maven artifact is configured.
within the upload extension, there are a few helper methods to configure repositories commonly used by me.
Everything is also published to mavenLocal by default, there is no need to do the specifically.
upload {
// publishes to https://registry.somethingcatchy.net
// uses the NEXUS_USER and NEXUS_TOKEN variables
nexus()
// publishes to the github packages maven registry
// uses the GITHUB_ACTOR and GITHUB_TOKEN env variables
githubPackages()
repositories {
// additional maven repositories
maven(url = uri("..."))
}
}
Artifact Modifications
There are some modifications that are applied to the artifact's metadata:
- disables module metadata generation. This is an additional file that will be preferred over the POM, but is known to cause issues within mod development setups.
- for forge projects: remove POM dependencies completely, as they are not working transitivily at all in ForgeGradle 6
- for non-forge projects: remove runtime dependencies. These are usually things like JEI that are only used for testing in the dev environment and should not be included transitively by other mods. The table below visualizes the different types of dependencies
The com.possible-triangle.publishing plugin, that is resposible for these modifications also exposes the helper method MavenPublication.removePomDependencies, which can be used to additionally exclude certain dependencies from the POM by group, artifact id, scope (1), or version
- like runtime or compile
Dependency Types
You can read about what dependency configuration to use at what time and which are represented in the POM in the following table:
| Configuration | Description | Examples | Included Transitively |
|---|---|---|---|
| modApi | required dependencies that are needed to complile & run the mod | Blueprint, Registrate, Moonlight Lib | |
| modImplementation | optional dependencies that should be there for compile & runtime | mods to have compatiblity with | |
| modCompileOnly | optional dependencies that are needed only at compile time | mods to have compatiblity with | |
| modCompileOnlyApi | required dependencies that are only needed at compile time | no idea | |
| modRuntimeOnly | optional dependencies that are only needed at runtim | mods to have compatiblity with or help within the dev environment like JEI |
Uploading
When running the publish task, the project will automatically be uploaded to modrinth & curseforge, if the required values are set. These values are described in their individual blocks below.
To overwrite specific values, like the version name, the changelog or define dependencies, you can use the the common API within the upload extension.
To plugin will automatically choose the correct jar artifact. That could be the normal one, or the one including Jar-In-Jar dependencies, if any are configured.
upload {
// if possible, always prefer "forEach" to configure both modrinth & curseforge at the same time
curseforge {
dependencies {
// for curseforge, the second (optional) parameter can be set the concrete project ID
// this is required for some mods like blueprint, because there is also a modpack with the same name
// which will be instead resolved incorrectly if the ID is omitted
required("blueprint", 382216)
}
}
modrinth {
dependencies {
// for modrinth, the slug is unique and will work as an identifier always
required("blueprint")
}
}
forEach {
versionName = "Some Other Version Name ${mod.version.get()}"
}
}
Modrinth
Under the hood the minotaur plugin is used to publish build artifacts to modrinth.
This only happens if the MODRINTH_TOKEN environment variable and the modrinth_project_id gradle property are set.
Curseforge
Under the hood the CurseForgeGradle plugin is used (1) to publish build artifacts to curseforge.
- specifically a fork that fixed a few issues
This only happens if the CURSFORGE_TOKEN environment variable and the curseforge_project_id gradle property are set.