Integration

Gradle plugin

Run HashGuard as a task of your Gradle build.

The Gradle plugin wraps the obfuscator as a plrObfuscate task. It reads the same configuration file as the CLI and runs as part of your build.

Apply the plugin

The plugin comes with your download. Make it available to your build, then apply it by its id:

plugins {
    id("fr.polargames.plr-obfuscator")
}

Configure the task

The plugin adds a plrObfuscator extension:

plrObfuscator {
    inputJar   = tasks.named<Jar>("jar").flatMap { it.archiveFile }
    configFile = file("obfuscator-config.json")
}
PropertyTypeDefaultDescription
inputJarfilenone, requiredThe compiled jar to protect.
configFilefilenone, requiredThe HashGuard configuration file.
slotCountinteger1Number of jars to produce. Above 1, see below.
outputDirdirectorybuild/plr-obfuscatedWhere the protected jars are written.

The task adds your project’s runtimeClasspath to the libraries of the configuration, so dependencies resolve without listing them by hand. It never counts as up to date and runs every time.

Run it

./gradlew plrObfuscate

With the default slotCount of 1, the task writes the protected jar as client_0.jar into build/plr-obfuscated, next to a keys-manifest.json that only matters for the hardened runtime.

Several slots

A slotCount above 1 produces that many differently keyed jars, up to 100, along with a keys-manifest.json for your delivery pipeline. Those jars only make sense with class encryption, which belongs to the hardened runtime.