Add file types for Modrinth - #119
Conversation
Currently just detects types automatically without ability to manually set. Manually setting is a bit difficult, as additional files are a common option, while file types are specific to Modrinth. A solution is to just have our own defined file types then map them to platform-specific ones. This also means changing additional files to accepting a custom object containing both the file type and file path (default "unknown" type).
There was a problem hiding this comment.
Pull request overview
Adds Modrinth “file types” support for additional files by including file_types in the create-version metadata and populating it automatically from common filename suffixes (sources/javadoc/dev/signature), with new integration tests validating the mapping.
Changes:
- Add optional
file_typesfield toModrinthApi.CreateVersionpayload. - Populate and send
file_typesfor Modrinth additional uploads based on filename suffix detection. - Add integration tests covering expected Modrinth file type mappings (sources/javadoc/dev/signature/unknown).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/test/kotlin/me/modmuss50/mpp/test/modrinth/ModrinthTest.kt | Adds integration tests asserting file_types mappings for additional files. |
| src/main/kotlin/me/modmuss50/mpp/platforms/modrinth/ModrinthApi.kt | Extends the Modrinth create-version request model to include file_types. |
| src/main/kotlin/me/modmuss50/mpp/platforms/modrinth/Modrinth.kt | Builds file_types map for additional files and includes it in version creation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
This works with my testing (https://repo.srnyx.com/#/snapshots/me/modmuss50/mod-publish-plugin) |
To make sure additional files aren't duplicated when specifying them in both publishMods {} and modrinth {} (for file types)
|
Please update the docs to include this. Have some practical examples such as including the sources jar. |
modmuss50
left a comment
There was a problem hiding this comment.
Im going to make some changes to this PR so it can be merged.
Currently just detects types automatically without ability to manually set.
Manually setting is a bit difficult, as additional files are a common option, while file types are specific to Modrinth.
A solution is to just have our own defined file types then map them to platform-specific ones. This also means changing additional files to accepting a custom object containing both the file type and file path (default to "unknown" type). The existing additional files option can remain (doesn't need to be deprecated either) and just use the default "unknown" file type.
But for now, this PR is ready as-is for a good start with automatic type associations. Manual setting can always be added later!
Resolves #114