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

Work on better include configuration #1080

Merged
merged 13 commits into from
May 4, 2024

Conversation

lukebemish
Copy link
Contributor

@lukebemish lukebemish commented Mar 23, 2024

Currently, the include configuration uses dependency resolution information at runtime; additionally, it works based off of Dependency objects, which is generally speaking a bad way to pass dependency information into a task - we're meant to use the various dependency resolution result types instead. All of this combined means that the system is not very future-proof. This PR is an attempt to modernize the system, while keeping the old behavior.

@lukebemish lukebemish marked this pull request as ready for review March 24, 2024 00:07
@modmuss50 modmuss50 added this to the 1.7 milestone Mar 25, 2024
Copy link
Member

@modmuss50 modmuss50 left a comment

Choose a reason for hiding this comment

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

This looks a lot better, thanks. Just a few minor fixes + questions.

Sorry it took me so long to look at this.

private static final Pattern SEMVER_PATTERN = Pattern.compile(SEMVER_REGEX);

@InputFiles
@PathSensitive(PathSensitivity.NAME_ONLY)
Copy link
Member

Choose a reason for hiding this comment

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

Question: Why name only?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only part of the path to the jar to nest that affects the output is it's name and contents; the relative/absolute path is irrelevant

String version = moduleLocation.version;
String classifier = null;

if (artifact.getFile().getName().startsWith(name + "-" + version + "-")) {
Copy link
Member

Choose a reason for hiding this comment

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

Shame there is no better way to get the classifier, this seems quite fragile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah unfortunately this is the only way to do this (without doing the questionable approach it did before); classifiers are a maven concept that doesn't translate super well into gradle. I'd encourage people to use capability requests and feature variants instead.

All that said -- this was the workaround I found on a relevant gradle issue about the lack of a way to query artifact classifier (I can try to track that down later), and it should actually be pretty stable given that the classifier and extension provided are used only while gradle is resolving which artifact of a module to use; so if something was selected by classifier it should be in the name. At any rate, probably less fragile than the old system still.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See gradle/gradle#23702 -- basically, at the level we're operating at we're in variant aware resolution, and gradle doesn't really care about classifiers at that level because they're a very maven concept, so they're not there

@modmuss50 modmuss50 changed the base branch from dev/1.6 to exp/1.7 May 4, 2024 17:16
@modmuss50 modmuss50 merged commit 63ebc35 into FabricMC:exp/1.7 May 4, 2024
83 checks passed
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.

None yet

2 participants