The CLIExecutor class provides the main() method that serves as the entry point for MCReleaser’s CLI. It orchestrates platform selection, file bundling, and upload execution.
Package
me.hsgamer.mcreleaser.cli.CLIExecutor
Class Declaration
public class CLIExecutor {
public static void main(String[] args);
}
Methods
main
The application entry point that coordinates the upload process.
Command-line arguments (currently unused)
public static void main(String[] args) {
String platforms = CLIPropertyKey.PLATFORMS.getValue("all");
boolean runSync = CLIPropertyKey.SYNC.asBoolean(false);
BundlePlatform bundlePlatform = new BundlePlatform(platforms, runSync);
if (PropertyKeyUtil.isAbsentAndAnnounce(LoggerFactory.getLogger(CLIExecutor.class),
CommonPropertyKey.NAME,
CommonPropertyKey.VERSION,
CommonPropertyKey.DESCRIPTION)) {
return;
}
FileBundle fileBundle = getFileBundle();
Optional<BatchRunnable> optional = bundlePlatform.createUploadRunnable(fileBundle);
if (optional.isEmpty()) {
throw new RuntimeException("No platform found");
}
Thread thread = new Thread(optional.get());
thread.start();
}
Execution Flow
Reads the platforms property to determine which platforms to upload to:
String platforms = CLIPropertyKey.PLATFORMS.getValue("all");
boolean runSync = CLIPropertyKey.SYNC.asBoolean(false);
BundlePlatform bundlePlatform = new BundlePlatform(platforms, runSync);
Configuration:
export PLATFORMS="github modrinth" # Multiple platforms
export PLATFORMS="all" # All configured platforms
export SYNC="true" # Run platforms sequentially
2. Property Validation
Validates that required common properties are present:
if (PropertyKeyUtil.isAbsentAndAnnounce(logger,
CommonPropertyKey.NAME,
CommonPropertyKey.VERSION,
CommonPropertyKey.DESCRIPTION)) {
return;
}
If any required property is missing, the application logs the missing keys and exits.
3. File Bundle Creation
Creates a file bundle from glob patterns:
FileBundle fileBundle = getFileBundle();
The getFileBundle() method:
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));
}
Configuration:
export FILES="build/libs/*.jar"
4. Upload Execution
Creates and executes the upload runnable:
Optional<BatchRunnable> optional = bundlePlatform.createUploadRunnable(fileBundle);
if (optional.isEmpty()) {
throw new RuntimeException("No platform found");
}
Thread thread = new Thread(optional.get());
thread.start();
Required Properties
The executor requires these common properties to be set:
Release description/changelog
CLI Properties
The executor uses these CLI-specific properties:
Space-separated list of platforms or “all”
Run platforms sequentially instead of in parallel
Space-separated glob patterns for files to upload
Usage Examples
#!/bin/bash
export NAME="MyPlugin v1.0.0"
export VERSION="1.0.0"
export DESCRIPTION="Initial release with awesome features"
export FILES="build/libs/*.jar"
# Platform-specific config
export GITHUB_TOKEN="ghp_..."
export GITHUB_REPOSITORY="user/repo"
export GITHUB_REF="refs/tags/v1.0.0"
export MODRINTH_TOKEN="mrp_..."
export MODRINTH_PROJECT="my-project"
java -jar mcreleaser-cli.jar
export PLATFORMS="github modrinth"
export SYNC="true" # Upload sequentially
java -jar mcreleaser-cli.jar
Multiple File Upload
export FILES="build/libs/my-plugin.jar build/libs/my-plugin-sources.jar"
java -jar mcreleaser-cli.jar
Error Handling
Missing Required Properties
If required properties are missing, the executor logs them and exits:
[ERROR] Missing required properties: NAME, VERSION
Missing Files
If no files match the glob patterns:
Validate.check(fileGlobs != null, "File globs not found");
Throws a validation exception.
If no platforms are properly configured:
if (optional.isEmpty()) {
throw new RuntimeException("No platform found");
}
Gradle Integration
task release(type: JavaExec) {
classpath = configurations.runtimeClasspath
mainClass = 'me.hsgamer.mcreleaser.cli.CLIExecutor'
systemProperty 'name', project.name
systemProperty 'version', project.version
systemProperty 'description', file('CHANGELOG.md').text
systemProperty 'files', 'build/libs/*.jar'
}
Maven Integration
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<mainClass>me.hsgamer.mcreleaser.cli.CLIExecutor</mainClass>
<systemProperties>
<systemProperty>
<key>name</key>
<value>${project.name}</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>