Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To sign a JAR file in Gradle, you can follow these steps:

  1. Create a new Gradle task for signing the JAR file by adding the following code to your build.gradle file:
task signJar(type: SignJar) {
    inputs.files jar.archivePath
    outputs.dir temporaryDir
    alias = 'alias'
    storepass = 'password'
    keystore = file('keystore.jks')
}
  1. Configure the SignJar task by specifying the alias and password for your keystore file. Optionally, you may also specify the path for the keystore file itself.

  2. Run the signJar task by executing the following command in your command prompt or terminal:

gradlew signJar
  1. Upon successful execution, the signed JAR file will be located in $buildDir/libs/ directory.

Note: Before signing a JAR file, you need to make sure that you have a valid keystore file that contains your certificate and private key pair.