The FILES Property
TheFILES environment variable (or -Dfiles property for CLI) accepts glob patterns to select which files to upload.
From CLIPropertyKey.java:8:
CLIExecutor.java:38-40:
File globs are required. MCReleaser will fail if no files pattern is provided.
Glob Pattern Basics
Glob patterns are file path matching patterns similar to shell wildcards:| Pattern | Matches | Example |
|---|---|---|
* | Any characters except / | *.jar matches mod.jar but not subdir/mod.jar |
** | Any characters including / | **/*.jar matches all .jar files recursively |
? | Single character | mod-?.jar matches mod-1.jar |
[abc] | One character from set | mod-[123].jar matches mod-1.jar, mod-2.jar |
{a,b} | Alternatives | *.{jar,zip} matches both .jar and .zip files |
Primary vs Secondary Files
MCReleaser distinguishes between primary and secondary files:- Primary file: The main artifact (e.g., your mod JAR)
- Secondary files: Additional files (e.g., sources, javadocs, dependencies)
FileBundle.java:7-14:
How Files Are Selected
FromPathUtil.java:54-69:
First Glob Pattern
The first glob pattern selects the primary file. If multiple files match, the most recent one is chosen.
Additional Glob Patterns
Any additional glob patterns select secondary files (all matches are included).
Common File Selection Patterns
Single JAR File
Select a single JAR file from the build directory:Exclude Specific Files
Select JAR files but exclude sources and javadocs:Primary JAR with Sources
Upload the main JAR as primary and sources as secondary:- Use
*-[0-9]*.jarto find the primary file (e.g.,mod-1.0.0.jar) - Use
*-sources.jarto find secondary files (e.g.,mod-1.0.0-sources.jar)
Multiple File Types
Include JARs and ZIP files:Recursive Search
Find files in nested directories:The
** pattern searches recursively through all subdirectories.Practical Examples
Gradle Multi-Module Project
For a multi-module Gradle project with Fabric and Forge subprojects:- Primary: First matching JAR from
fabric/build/libs/ - Secondary: All matching JARs from
forge/build/libs/
Maven Project
For a Maven project with target directory:Shadow JAR Only
If you build both regular and shadow (fat) JARs:Complete Build Artifacts
Upload main JAR, sources, and javadocs:File Selection Algorithm
Here’s how MCReleaser selects files (fromPathUtil.java:18-52):
Select Most Recent Primary
If multiple files match the primary pattern, the most recent (by modified time) is chosen
Match Against Secondary Patterns
All files matching secondary patterns are added to the secondary file list
PathUtil.java:29-35:
Files are sorted in reverse order before matching, ensuring the most recent file is selected as primary.
Docker and Environment Variables
When using Docker, file patterns work the same way:CI/CD File Patterns
GitHub Actions
GitLab CI
Troubleshooting
No Files Found
Problem: MCReleaser fails with “Primary file not found” Solutions:- Verify the file actually exists:
ls -la build/libs/ - Test your glob pattern:
find . -name "your-pattern" - Check the working directory: MCReleaser searches from
.(current directory) - Use absolute paths or ensure you’re in the correct directory
Wrong File Selected as Primary
Problem: Secondary file is selected as primary Solution: Ensure your first glob pattern is the most specific one for your primary fileToo Many Files Matched
Problem: Unwanted files are included Solution: Make your glob patterns more specificAdvanced Patterns
Version-Specific Pattern
Match files with semantic version numbers:mod-1.0.0.jar, mod-2.1.3.jarExcludes:
mod-sources.jar, mod-dev.jar
Platform-Specific Files
Match loader-specific builds:Character Class Exclusion
Exclude files with specific characters:mod-dev.jarIncludes:
mod-1.0.0.jar, mod-release.jar
Best Practices
- Be Specific: Use precise patterns to avoid accidentally uploading wrong files
- Test Locally: Run
find . -name "your-pattern"to verify your glob works - Version in Filename: Include version numbers in filenames for clarity
- Consistent Naming: Use consistent file naming conventions across builds
- Exclude Build Artifacts: Don’t upload intermediate build files or non-release JARs
Next Steps
Publishing to Single Platform
Learn platform-specific publishing strategies
CI/CD Integration
Automate file uploads in your CI/CD pipeline