Skip to content

Don't set artifactId manually for publishing - #121

Open
IThundxr wants to merge 1 commit into
jaredlll08:26.1.2from
IThundxr:feat/26.1.2-no-artifact-id
Open

Don't set artifactId manually for publishing#121
IThundxr wants to merge 1 commit into
jaredlll08:26.1.2from
IThundxr:feat/26.1.2-no-artifact-id

Conversation

@IThundxr

Copy link
Copy Markdown
Contributor

Setting artifactId manually is bad practice, the name of the projects should be changed instead.

Reference: https://lukebemish.dev/2026/02/22/gradle-shorts-1-publication-coordinates.html

@jaredlll08

Copy link
Copy Markdown
Owner

As discussed on discord, this is a major change in how artifacts will be published to maven, while I understand what the template is doing may not be best practices, I am hesitant to change publishing coordinates.

@IThundxr

Copy link
Copy Markdown
Contributor Author

As discussed on discord, this is a major change in how artifacts will be published to maven, while I understand what the template is doing may not be best practices, I am hesitant to change publishing coordinates.

Changing the group back to what it was previously and adding the minecraft version to the subproject name would keep the coords the same as they were before, i could go ahead and make that change if you'd like

@jaredlll08

Copy link
Copy Markdown
Owner

adding the minecraft version to the subproject name

Just out of curiosity, how would that look?

I'm going to do a proper review of this PR before you make those changes though

Comment thread settings.gradle
&& (new File(it, "build.gradle").exists() || new File(it, "build.gradle.kts").exists())
}.forEach {
String relativePath = rootDir.toPath().relativize(it.toPath()).toString()
String projectName = ":$modId-$relativePath"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Is there a specific benefit to naming the projects modid-?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is there a specific benefit to naming the projects modid-?

Yes, this means that whenever something in gradle builds maven coords, it'll create something along the lines of "com.examplemod:$modId-$relativePath:version", which fixes the issue with having to set artifactId manually to get the coords to be correct

Comment thread settings.gradle

rootDir.listFiles().findAll {
it.isDirectory()
&& it.name != "buildSrc"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Since I merged PRs out of order, this would now need to be changed to build-logic

Suggested change
&& it.name != "buildSrc"
&& it.name != "build-logic"

Comment thread build.gradle
Comment on lines +8 to +9
group = property("group")
version = property("version") No newline at end of file

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

What is the purpose of this? as far as I'm aware setting group and version in gradle.properties sets the properties already

Comment thread settings.gradle
Comment on lines +27 to +37
rootDir.listFiles().findAll {
it.isDirectory()
&& it.name != "buildSrc"
&& (new File(it, "build.gradle").exists() || new File(it, "build.gradle.kts").exists())
}.forEach {
String relativePath = rootDir.toPath().relativize(it.toPath()).toString()
String projectName = ":$modId-$relativePath"

include(projectName)
project(projectName).projectDir = it
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Is this code worth it? isn't this adding a bunch of io checks every time a gradle command is ran?

This also doesn't let people temporarily disable projects, for example, if fabric has ported to a new MC version but neoforge has not, they can't just temporarily disable neoforge.

This also makes the readme outdated for removing projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants