Skip to main content
The FileBundle record encapsulates a primary file and optional secondary files for platform uploads. It provides a simple, immutable data structure for file management.

Package

me.hsgamer.mcreleaser.core.file.FileBundle

Record Declaration

public record FileBundle(File primaryFile, List<File> secondaryFiles) {
    public List<File> allFiles() {
        List<File> files = new ArrayList<>();
        files.add(primaryFile);
        files.addAll(secondaryFiles);
        return files;
    }
}

Components

primaryFile

The main file to be uploaded (e.g., the plugin JAR or mod file).
primaryFile
File
required
The primary file for upload
File jar = new File("my-plugin-1.0.0.jar");

secondaryFiles

Additional files to upload alongside the primary file (e.g., source JARs, documentation).
secondaryFiles
List<File>
required
List of secondary files
List<File> secondaries = List.of(
    new File("my-plugin-1.0.0-sources.jar"),
    new File("my-plugin-1.0.0-javadoc.jar")
);

Methods

allFiles

Returns a combined list of the primary file and all secondary files.
files
List<File>
A new ArrayList containing the primary file followed by all secondary files
FileBundle bundle = new FileBundle(primaryJar, secondaryJars);
for (File file : bundle.allFiles()) {
    System.out.println("Uploading: " + file.getName());
}

Usage Examples

Creating a FileBundle with Only Primary File

File primaryJar = new File("build/libs/my-plugin-1.0.0.jar");
FileBundle bundle = new FileBundle(primaryJar, Collections.emptyList());

Creating a FileBundle with Secondary Files

File primaryJar = new File("build/libs/my-plugin-1.0.0.jar");
List<File> secondaryFiles = List.of(
    new File("build/libs/my-plugin-1.0.0-sources.jar"),
    new File("build/libs/my-plugin-1.0.0-javadoc.jar")
);

FileBundle bundle = new FileBundle(primaryJar, secondaryFiles);

Using with Platform Upload

// Create file bundle
FileBundle bundle = new FileBundle(primaryFile, secondaryFiles);

// Create platform and upload
Platform platform = new GithubPlatform();
Optional<BatchRunnable> runnable = platform.createUploadRunnable(bundle);

if (runnable.isPresent()) {
    Thread uploadThread = new Thread(runnable.get());
    uploadThread.start();
}

Iterating Over All Files

FileBundle bundle = getFileBundle();

// Upload all files
for (File file : bundle.allFiles()) {
    release.uploadAsset(file, "application/octet-stream");
    logger.info("Uploaded: {}", file.getName());
}

CLI Integration

The CLI uses glob patterns to create file bundles automatically:
private static FileBundle getFileBundle() {
    String fileGlobs = CLIPropertyKey.FILES.getValue();
    Validate.check(fileGlobs != null, "File globs not found");
    return PathUtil.getFileBundle(Paths.get("."), StringUtil.splitSpace(fileGlobs));
}
Configure file patterns:
export FILES="build/libs/*.jar build/libs/*-sources.jar"

Platform Support

Different platforms handle file bundles differently:
  • GitHub: Uploads all files from allFiles() as release assets
  • Modrinth: Uploads all files, marks primary file explicitly
  • Hangar: Only uploads the primary file
  • Polymart: Only uploads the primary file
  • CurseForge: Only uploads the primary file
  • Platform - Platform interface that consumes FileBundle
  • CLIExecutor - Creates FileBundles from glob patterns

Build docs developers (and LLMs) love