I was attempting to learn how to automate jar signing for the newly more bothersome Ore. And apparently the way it must be configured is through project properties. And a: you’re high if you think I’m storing my passphrase in plaintext in my gradle.properties file, b: you’re even more high if you think I’m storing my passphrase in my build.gradle file via ext
, and c: you can’t just say -Psigning.password=bukkitsux
very easily in IntelliJ.
There are a couple of ways to request properties at buildtime, but they bloat up a build.gradle file fast and are completely repetitive. So I present to you promptsign
. It’s a small Gradle plugin which can actually be used for any general signing
plugin use, but intended for ease of use of the new required jar signing. Simply add the following code to your build.gradle
:
plugins {
id 'flavor.pie.promptsign' version '1.1.0'
}
Or, if you’re an absolute masochist,
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2'
}
}
dependencies {
classpath 'gradle.plugin.flavor.pie:promptsign:1.1.0'
}
}
apply plugin: 'flavor.pie.promptsign'
And that is the sum total of any sign-related code you need in your build.gradle
.
The plugin does a couple things:
- Enables the
signing
plugin - Adds the
archives
configuration to the list of things that are signed - Upon execution of the
Sign
task, tests for the propertiessigning.keyId
,signing.secretKeyRingFile
, andsigning.password
- Any that are not already present in
ext
are then asked for: - If in GUI mode, such as IntelliJ’s Gradle pane, spawns a popup
- If in CLI mode, asks through
Console.readLine()
(The latest version of Gradle has a bug where some or all of this message may be overwritten by the Gradle info)
All three properties are configurable through this plugin, but the password property is the one I wrote it for. Just a reminder, any properties you want to be hardcoded should either be written into your build.gradle
file in the format ext."<propertyname>" = <value>
, or placed in your gradle.properties file in the format <propertyname>=<value>
(located by default in your platform-specific variant of ~/.gradle/gradle.properties
). I’d recommend setting both keyId
and secretKeyRingFile
in gradle.properties
.