Skip to content

Conversation

ThePandaOliver
Copy link

@ThePandaOliver ThePandaOliver commented Jul 23, 2025

I was writing a new template for future projects, and for testing purposes decided to try Forgix. I tried to get multi-version to work knowing it was experimental, and after a long time of troubleshooting, i found out why it didn't work. It seems you cant set the inputJars variable in Kotlin DSL because it interprets the variable as read only. To fix this i changed the variable type from FileCollection to Property<FileCollection> which allows Kotlin DSL to modify the variable.

I also found it annoying that the multi-version jar used the Forgix config's base name, version, classifier and build destination, so i decided to also add the ability to change those independent of the Forgix config.
I did this because when i build and merge, the jar names will contain both the mod version and the minecraft version, which i dont want the multi-version jar to have, it should only contain the mod version.
I also decided to add the ability to change the base name, classifier and build destination while i was at it.

I don't have much experience with making Gradle plugins, so if anything is wrong feel free to correct it. I also originally thought of making an issue, but since i already fixed the issues myself i decided to just open a pull request.

Summary by CodeRabbit

  • New Features
    • Added new configuration options for multiversion builds, including customizable archive name, classifier, version, and destination directory.
  • Refactor
    • Improved how merge tasks retrieve and use multiversion configuration settings, allowing for more flexible project setup.
  • Bug Fixes
    • Corrected handling of input jar files and archive versioning in the merge process.

…estinationDirectory` to the multiversion configurations and changed `inputJars` to `Property<FileCollection>` instead of `FileCollection` to add proper support for Kotlin DSL
Copy link

coderabbitai bot commented Jul 23, 2025

Walkthrough

The changes update the configuration and usage of multiversion build properties in the Forgix Gradle plugin. MultiversionConfiguration is expanded with new Gradle property fields and conventions based on the root project. The MergeVersionsTask now sources its archive and input jar properties directly from the updated configuration.

Changes

Cohort / File(s) Change Summary
Multiversion Configuration Refactor
src/main/java/io/github/pacifistmc/forgix/plugin/configurations/ForgixConfiguration.java
Expanded MultiversionConfiguration to include new Gradle Property fields for archive naming and output directory, all conventioned from the root project. Getter methods were added and the constructor signature was updated accordingly.
Task Property Sourcing Update
src/main/java/io/github/pacifistmc/forgix/plugin/tasks/MergeVersionsTask.java
Updated the task to source archive and input jar properties directly from the new MultiversionConfiguration properties, removing prior manual property setting and version suffix logic.

Sequence Diagram(s)

sequenceDiagram
    participant GradleBuild
    participant ForgixConfiguration
    participant MultiversionConfiguration
    participant MergeVersionsTask

    GradleBuild->>ForgixConfiguration: Configure plugin
    ForgixConfiguration->>MultiversionConfiguration: Instantiate with rootProject
    MultiversionConfiguration-->>ForgixConfiguration: Provide archive and directory properties

    GradleBuild->>MergeVersionsTask: Execute task
    MergeVersionsTask->>MultiversionConfiguration: Retrieve archive and inputJar properties
    MergeVersionsTask->>MergeVersionsTask: Perform merge using provided properties
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A bunny hopped through lines of code,
Where properties and tasks now flowed.
With archives named and jars in tow,
The build hops forward, smooth and slow.
From root to task, the changes run—
Multiversion magic, coding fun!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 13b94fa and 987387f.

📒 Files selected for processing (1)
  • src/main/java/io/github/pacifistmc/forgix/plugin/tasks/MergeVersionsTask.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/io/github/pacifistmc/forgix/plugin/tasks/MergeVersionsTask.java
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7e8871b and 585d7a1.

📒 Files selected for processing (2)
  • src/main/java/io/github/pacifistmc/forgix/plugin/configurations/ForgixConfiguration.java (2 hunks)
  • src/main/java/io/github/pacifistmc/forgix/plugin/tasks/MergeVersionsTask.java (2 hunks)
🔇 Additional comments (4)
src/main/java/io/github/pacifistmc/forgix/plugin/configurations/ForgixConfiguration.java (3)

281-281: LGTM: Correctly passes rootProject to MultiversionConfiguration constructor.

This change enables the MultiversionConfiguration to access project information for setting up default conventions.


290-307: Well-implemented property-based configuration expansion.

The addition of new archive-related properties and the change from FileCollection to Property<FileCollection> for inputJars correctly addresses the Kotlin DSL compatibility issues mentioned in the PR objectives. All properties are properly initialized using the ObjectFactory.


309-327: Excellent property conventions and Kotlin DSL compatibility fix.

The getter methods provide sensible default conventions:

  • archiveBaseName defaults to project name
  • archiveClassifier defaults to "multi" (appropriate for multiversion jars)
  • archiveVersion defaults to project version
  • destinationDirectory uses a dedicated subdirectory under build

The change of inputJars to return Property<FileCollection> resolves the Kotlin DSL read-only issue mentioned in the PR objectives.

src/main/java/io/github/pacifistmc/forgix/plugin/tasks/MergeVersionsTask.java (1)

45-47: Minor formatting improvement in exception message.

The reformatting of the exception message improves readability while maintaining the same informative content.

@Ran-Mewo
Copy link
Member

Ran-Mewo commented Aug 5, 2025

Sorry, I've been really busy recently. So it'll take me a while before I can get to this.
I'd appreciate if you could apply the suggestion made by CodeRabbit, the lazy evaluation suggestion.

Lazy evaluation is required for configuration caching

@ThePandaOliver
Copy link
Author

Sure i can do that.
Also just take your time, there's no rush especially since multi-version is still experimental.

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