neoforged / MDK

The Mod Developer Kit - this is where you start if you want to develop a new mod
https://github.com/NeoForgeMDKs
183 stars 60 forks source link

Respect the archivesName #46

Open uecasm opened 3 months ago

uecasm commented 3 months ago

I'm not a gradle expert, so I'm not sure if there's a better way to do this, but at least with userdev 7.0.97 (as is referenced here), changes to the base.archivesName don't actually do anything without a line like this.

Shadows-of-Fire commented 3 months ago

Default maven path before this change: com\example\examplemod\MDK-main\1.0.0\MDK-main-1.0.0.jar Default maven path after this change: com\example\examplemod\examplemod\1.0.0\examplemod-1.0.0.jar

Shadows-of-Fire commented 3 months ago

I wasn't sure if there would be other implications of fiddling with the project name (does it change the name displayed in an IDE?)

Also, the project name is seldom the modid, rather it is usually the mod name without spaces (due to repository naming schemes).

sciwhiz12 commented 3 months ago

(does it change the name displayed in an IDE?)

It does; if I recall correctly, IDEA displays the folder name and then in parentheses the project name (or was it the other way around?).

Also, the project name is seldom the modid, rather it is usually the mod name without spaces (due to repository naming schemes).

Good point. I think, though, the more pertinent issue (as I've just remembered) is a problem with case-insensitive file-systems, where a case difference between the mod ID and the repository/folder name might cause issues. (I think I remember having experienced this issue on Windows when I used Eclipse, and possibly with IDEA.)

uecasm commented 3 months ago

The motivating case was when I was trying to set the archivesName like so:

base {
    archivesName = "MyModName-${minecraft_version}"
}

This is, I think, fairly typical, where the project id/name is the mod id (or folder name?) but the archive name is set to a capitalized/de-spaced friendly mod name, with Minecraft version included (so that it's part of the filename but not part of the actual mod version). Not sure if the MDK should do that by default too, but a random sampling of curseforge mods suggests it's commonplace.

Side note: the Forge MDK published a sources jar by default, while the NeoForge MDK does not. That's probably not important for most mods but they're nice to have for any mod that gets addons made for it (which are the type to end up published in mavens in the first place), so perhaps also might be helpful by default anyway?

sciwhiz12 commented 3 months ago

I think I can agree with those changes: creating/publishing the sources JAR by default (via java.withSourcesJar()), and adding the Minecraft version to the base archives name.

uecasm commented 3 months ago

How's this look? I changed the archive name to use the project name by default (rather than the mod id, which may or may not be the same), mostly because the mod_name can't be assumed to be space-free. But mod authors can still edit it as needed to get the desired artifact name.