Overview
MCReleaser supports configuration through both environment variables and Java system properties via a unified property key system. Understanding the conversion mechanism is essential for proper configuration.
Property Key System
All configuration in MCReleaser uses the PropertyKey class, which automatically handles:
- Environment variable lookup
- System property fallback
- CamelCase to CONSTANT_CASE conversion
Naming Convention
CamelCase to CONSTANT_CASE
MCReleaser automatically converts camelCase property names to CONSTANT_CASE for environment variables:
// From PropertyKey.java:18-27
private static String camelToConstant(String camel) {
StringBuilder constant = new StringBuilder();
for (char c : camel.toCharArray()) {
if (Character.isUpperCase(c)) {
constant.append('_');
}
constant.append(Character.toUpperCase(c));
}
return constant.toString();
}
Conversion Examples
| Property Key (camelCase) | Environment Variable (CONSTANT_CASE) |
|---|
name | NAME |
version | VERSION |
gameVersions | GAME_VERSIONS |
gameVersionType | GAME_VERSION_TYPE |
announceMissingKey | ANNOUNCE_MISSING_KEY |
sync | SYNC |
Configuration Priority
MCReleaser follows this resolution order:
- Environment Variable (checked first)
- System Property (fallback)
// From PropertyKey.java:45-51
public String getValue() {
String value = System.getenv(env); // 1. Check environment variable
if (value == null) {
value = System.getProperty(key); // 2. Fallback to system property
}
return value;
}
Example Priority
# Environment variable takes precedence
export VERSION=2.0.0
java -Dversion=1.0.0 -jar mcreleaser.jar
# Result: VERSION=2.0.0 (from environment)
# System property used when env var is absent
java -Dversion=1.0.0 -jar mcreleaser.jar
# Result: VERSION=1.0.0 (from system property)
Common Properties
Core Properties
Defined in CommonPropertyKey.java:
| Property | Environment Variable | Description |
|---|
name | NAME | Project/artifact name |
version | VERSION | Release version |
description | DESCRIPTION | Release description |
gameVersions | GAME_VERSIONS | Minecraft versions (comma/space-separated) |
gameVersionType | GAME_VERSION_TYPE | Version type filter (release, snapshot, all) |
announceMissingKey | ANNOUNCE_MISSING_KEY | Show missing property warnings (boolean) |
CLI Properties
Defined in CLIPropertyKey.java:
| Property | Environment Variable | Description |
|---|
platforms | PLATFORMS | Platforms to upload to (comma/space-separated) |
sync | SYNC | Sequential upload mode (boolean) |
files | FILES | File globs to upload |
Property Prefixes
Platform-specific properties use the PropertyPrefix system, which adds a platform prefix to property keys:
// From PropertyPrefix.java:12-16
public PropertyKey key(String key) {
key = key.substring(0, 1).toUpperCase() + key.substring(1);
return new PropertyKey(prefix + key);
}
Modrinth Properties
| Property | Environment Variable | Example Value |
|---|
modrinthToken | MODRINTH_TOKEN | mrp_xxxxx |
modrinthProject | MODRINTH_PROJECT | my-mod |
modrinthVersionType | MODRINTH_VERSION_TYPE | release |
modrinthGameVersions | MODRINTH_GAME_VERSIONS | 1.20.1,1.20.2 |
modrinthLoaders | MODRINTH_LOADERS | fabric,forge |
modrinthFeatured | MODRINTH_FEATURED | true |
modrinthDependencies | MODRINTH_DEPENDENCIES | fabric-api:required |
modrinthEndpoint | MODRINTH_ENDPOINT | https://api.modrinth.com |
GitHub Properties
| Property | Environment Variable | Example Value |
|---|
githubToken | GITHUB_TOKEN | ghp_xxxxx |
githubRepository | GITHUB_REPOSITORY | owner/repo |
githubRef | GITHUB_REF | main |
githubDraft | GITHUB_DRAFT | false |
githubPrerelease | GITHUB_PRERELEASE | false |
CurseForge Properties
| Property | Environment Variable |
|---|
curseforgeToken | CURSEFORGE_TOKEN |
curseforgeProject | CURSEFORGE_PROJECT |
curseforgeGameVersions | CURSEFORGE_GAME_VERSIONS |
curseforgeReleaseType | CURSEFORGE_RELEASE_TYPE |
Hangar Properties
| Property | Environment Variable |
|---|
hangarToken | HANGAR_TOKEN |
hangarProject | HANGAR_PROJECT |
hangarChannel | HANGAR_CHANNEL |
Polymart Properties
| Property | Environment Variable |
|---|
polymartToken | POLYMART_TOKEN |
polymartProject | POLYMART_PROJECT |
Configuration Methods
Method 1: Environment Variables
Recommended for CI/CD
export NAME="My Mod"
export VERSION="1.0.0"
export DESCRIPTION="A cool Minecraft mod"
export PLATFORMS="modrinth,curseforge"
export MODRINTH_TOKEN="mrp_xxxxx"
export MODRINTH_PROJECT="my-mod"
export CURSEFORGE_TOKEN="xxxxx"
export CURSEFORGE_PROJECT="123456"
java -jar mcreleaser.jar
Method 2: System Properties
Recommended for local development
java -Dname="My Mod" \
-Dversion="1.0.0" \
-Ddescription="A cool Minecraft mod" \
-Dplatforms="modrinth,curseforge" \
-DmodrinthToken="mrp_xxxxx" \
-DmodrinthProject="my-mod" \
-DcurseforgeToken="xxxxx" \
-DcurseforgeProject="123456" \
-jar mcreleaser.jar
Method 3: Mixed Configuration
Combine both for flexibility
# Secrets via environment (secure)
export MODRINTH_TOKEN="mrp_xxxxx"
export CURSEFORGE_TOKEN="xxxxx"
# Public config via system properties (visible)
java -Dname="My Mod" \
-Dversion="1.0.0" \
-Dplatforms="modrinth,curseforge" \
-jar mcreleaser.jar
Type Conversion
MCReleaser automatically converts property values to appropriate types:
Boolean Properties
// From PropertyKey.java:75-78
public boolean asBoolean(boolean defaultValue) {
String value = getValue();
return value == null ? defaultValue : Boolean.parseBoolean(value);
}
Valid boolean values: true, false (case-insensitive)
export SYNC=true
export GITHUB_DRAFT=false
export MODRINTH_FEATURED=TRUE # Also valid
Number Properties
// From PropertyKey.java:66-73
public Number asNumber(Number defaultValue) {
String value = getValue();
try {
return value == null ? defaultValue : Double.parseDouble(value);
} catch (NumberFormatException e) {
return defaultValue;
}
}
export TIMEOUT=30
export RETRY_COUNT=3
String Properties
No conversion needed - used directly:
export NAME="My Mod"
export VERSION="1.0.0"
Missing Properties
MCReleaser can announce missing required properties:
export ANNOUNCE_MISSING_KEY=true
java -jar mcreleaser.jar
Output:
ERROR: The following keys are missing: name, version, description
Required properties like name, version, and description must be set, or MCReleaser will exit early.
Best Practices
1. Use Environment Variables for Secrets
# Good: Secrets in environment
export MODRINTH_TOKEN="mrp_xxxxx"
export GITHUB_TOKEN="ghp_xxxxx"
# Bad: Secrets in command line (visible in process list)
java -DmodrinthToken="mrp_xxxxx" -jar mcreleaser.jar
2. Document Required Properties
Create a .env.example file:
# Required
NAME=
VERSION=
DESCRIPTION=
FILES=
# Platform selection
PLATFORMS=modrinth,curseforge
# Modrinth
MODRINTH_TOKEN=
MODRINTH_PROJECT=
# CurseForge
CURSEFORGE_TOKEN=
CURSEFORGE_PROJECT=
3. Use Consistent Naming
Always use either camelCase (system properties) or CONSTANT_CASE (environment variables):
# Good: Consistent
export MODRINTH_TOKEN="mrp_xxxxx"
java -DmodrinthToken="mrp_xxxxx" -jar mcreleaser.jar
# Bad: Mixed case (won't work)
export modrinth_token="mrp_xxxxx"
4. Validate Configuration
Enable missing key announcements during development:
export ANNOUNCE_MISSING_KEY=true
Programmatic Access
If extending MCReleaser, access properties via PropertyKey:
// Define property
PropertyKey MY_PROPERTY = new PropertyKey("myProperty");
// Read value
String value = MY_PROPERTY.getValue();
String valueWithDefault = MY_PROPERTY.getValue("default");
boolean boolValue = MY_PROPERTY.asBoolean(false);
// Set value (updates system property only)
MY_PROPERTY.setValue("newValue");
// Check presence
if (MY_PROPERTY.isPresent()) {
// Property is set
}
When creating custom platform integrations, follow the existing naming conventions: use PropertyPrefix for platform-specific properties and camelCase for property keys.