Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect the archivesName #46

Open
wants to merge 5 commits into
base: 1.21
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repositories {
}

base {
archivesName = mod_id
archivesName = "${file_name}-${minecraft_version}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR has set the base archives name to be the name of the published module -- however, you're now publishing the artifact at com.example.examplemod:ExampleMod-1.20.4. By convention, module names are lowercase, so this is not great. The inclusion of the minecraft version in the module name is also not optimal - it means that someone could depend on both ExampleMod-1.20.4 and, say, ExampleMod-1.20.2 and gradle would just pull in both -- whereas publishing every version of a mod under the same module name wouldn't allow this to happen.

The other solution to the latter problem is the use of capabilities but that is way to complicated for the MDK.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost every mod file I've ever seen has published using WordCase names.

Copy link

@lukebemish lukebemish Apr 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and that's fine for CF/MR publishing but a bad pattern for maven publishing (which is all this block is for) because it's the opposite of what is done in the wider gradle and maven world. Let's set a good example instead of propagating a problematic pattern. The use of the MC version in the module name is an even bigger issue, as it can lead to issues during dependency resolution and getting two copies of a module.

}

// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
Expand Down Expand Up @@ -113,7 +113,7 @@ tasks.withType(ProcessResources).configureEach {
minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range,
neo_version : neo_version, neo_version_range: neo_version_range,
loader_version_range: loader_version_range,
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
mod_id : mod_id, mod_name: mod_name, file_name: file_name, mod_license: mod_license, mod_version: mod_version,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to supply the file name as a property to the mods.toml properties expansion. Note that mod_group_id is also not provided as a property here.

mod_authors : mod_authors, mod_description: mod_description,
]
inputs.properties replaceProperties
Expand All @@ -124,9 +124,13 @@ tasks.withType(ProcessResources).configureEach {
}

// Example configuration to allow publishing using the maven-publish plugin
java {
withSourcesJar()
}
Comment on lines +127 to +129
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this above the comment (which is for the publishling block), and add its own comment explaining that this enables the creation of the -sources JAR.

publishing {
publications {
register('mavenJava', MavenPublication) {
artifactId = project.base.archivesName.get()
sciwhiz12 marked this conversation as resolved.
Show resolved Hide resolved
from components.java
}
}
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ loader_version_range=[2,)
mod_id=examplemod
# The human-readable display name for the mod.
mod_name=Example Mod
# The mod filename, usually the mod_id or the mod_name WithoutSpaces
file_name=ExampleMod

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above: the file name can be this for the local file and that's fine, but for the published module (the bit in the publishing block) it should be a normal, conventional module name -- in this case, probably com.example.examplemod:examplemod. A simple way to do this is to set the rootProject.name in the settings.gradle.

# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=All Rights Reserved
# The mod version. See https://semver.org/
Expand All @@ -40,4 +42,4 @@ mod_group_id=com.example.examplemod
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
mod_authors=YourNameHere, OtherNameHere
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
mod_description=Example mod description.\nNewline characters can be used and will be replaced properly.
mod_description=Example mod description.\nNewline characters can be used and will be replaced properly.