Open rikka0w0 opened 4 months ago
Hi @rikka0w0, when the plugin is used together with mod development plugins (such as Loom, or NeoGradle), preconfigured publications with the appropriate artifacts are created automatically. You can read more about this in the Interoperability section of the README.
In your case, you'll want to change the configuration of your publication too:
curseforge {
publications {
named("fabric") {
projectId = "336554"
artifacts.named("main") {
// No need to add the jar here. It is preconfigured.
// ...
}
}
}
}
Specifically, the section about Loom interop will be of interest to you.
Also, here is an example of how I configure the publication for one of my mods.
Thanks!
This script snippet solves the projectId not available issue. However, if I have the changelog section, it fails with Could not determine the dependencies of task ':publishFabricPublicationToCurseForge'.
. Without it, the script works. My curseforge section now looks like this:
curseforge {
apiToken="SECRETE"
publications {
named("fabric") {
projectId = "336554"
artifacts.named("main") {
displayName = "${project.minecraft_version}-${project.mod_version}-fabric"
releaseType = ReleaseType.BETA
changelog {
format = ChangelogFormat.MARKDOWN
from(file('build/info/CHANGELOG_FULL.md'))
}
}
}
}
}
May I ask one more question? How to specify the dependencies? I read that I need to use "slug" instead of projectId to specify dependencies. How could I find the slug? For example, my mod depends on Fabric API.
Does the Loom integration automatically locate the dependencies? I would like to know how to manually specify the versions of the dependencies.
Thanks in advance!
What's happening here is that you're using the from(...)
function from CurseForgePublicationArtifact
(which is used to specify the artifact file) instead of setting the changelog's content.
I assume you followed an example from the README which is currently wrong (See #38). Instead, you should declare the changelog as follows:
changelog {
format = ...
content = file('build/info/CHANGELOG_FULL.md").readText()
}
I think the Groovy equivalent is content = file('build/info/CHANGELOG_FULL.md').text
.
May I ask one more question? How to specify the dependencies? I read that I need to use "slug" instead of projectId to specify dependencies. How could I find the slug? For example, my mod depends on Fabric API.
The slug is part of the URL of your mods CurseForge page:
https://www.curseforge.com/minecraft/mc-mods/{slug}
For example, for https://www.curseforge.com/minecraft/mc-mods/fabric-api
the slug would be fabric-api
.
Does the Loom integration automatically locate the dependencies
No, this is currently not possible since information about CurseForge publications is not available in mod artifacts.
I would like to know how to manually specify the versions of the dependencies.
CurseForge does not support dependencies on specific versions of a mod.
For example, for https://www.curseforge.com/minecraft/mc-mods/fabric-api the slug would be fabric-api.
Thanks! The dependency part is now working.
However, if I have releaseType = ReleaseType.BETA
or changelog { format = ChangelogFormat.MARKDOWN }
, the same error happens:
* What went wrong:
Could not determine the dependencies of task ':publishFabricPublicationToCurseForge'.
> Could not create domain object 'main' (CurseForgePublicationArtifact)
If I only have changelog { file('build/info/CHANGELOG_FULL.md').text }
, the publish works as expected. I'm pretty sure that releaseType = ReleaseType.BETA
is causing the issue.
This is my current working script.
curseforge {
apiToken="SECRETE"
publications {
named("fabric") {
projectId = "336554"
artifacts.named("main") {
displayName = "${project.minecraft_version}-${project.mod_version}-fabric"
// releaseType = ReleaseType.BETA
changelog {
//format = ChangelogFormat.MARKDOWN
content = file('build/info/CHANGELOG_FULL.md').text
}
relations {
requiredDependency("fabric-api")
}
}
}
}
}
For example, for https://www.curseforge.com/minecraft/mc-mods/fabric-api the slug would be fabric-api.
Thanks! The dependency part is now working.
However, if I have
releaseType = ReleaseType.BETA
orchangelog { format = ChangelogFormat.MARKDOWN }
, the same error happens:* What went wrong: Could not determine the dependencies of task ':publishFabricPublicationToCurseForge'. > Could not create domain object 'main' (CurseForgePublicationArtifact)
If I only have
changelog { file('build/info/CHANGELOG_FULL.md').text }
, the publish works as expected. I'm pretty sure thatreleaseType = ReleaseType.BETA
is causing the issue.This is my current working script.
curseforge { apiToken="SECRETE" publications { named("fabric") { projectId = "336554" artifacts.named("main") { displayName = "${project.minecraft_version}-${project.mod_version}-fabric" // releaseType = ReleaseType.BETA changelog { //format = ChangelogFormat.MARKDOWN content = file('build/info/CHANGELOG_FULL.md').text } relations { requiredDependency("fabric-api") } } } } }
After further testing, I can't reproduce the error you are having. It would be great if you could share more details about your build setup or provide an MCVE.
I'd like to mention I'm also having this issue, where ReleaseType.BETA doesn't seem to work.
After looking at @NyakoFox's project linked in #52, I wonder if you import the required types. When referencing either ChangelogFormat
or ReleaseType
, make sure to add the required import (import io.github.themrmilchmann.gradle.publish.curseforge.*
) add the top of your build scripts.
IDEA seems to struggle a bit with suggesting that in Groovy.
The following is my
build.gradle
:When I run, it get:
The
System.out.println
prints the correct projected, but curseforge-publish cannot recognize it.