Skip to content

Instantly share code, notes, and snippets.

@AbrarSyed
Last active August 29, 2015 13:58
Show Gist options
  • Save AbrarSyed/9978513 to your computer and use it in GitHub Desktop.
Save AbrarSyed/9978513 to your computer and use it in GitHub Desktop.
A quick gist for how you partially sign a jar
jar {
from(sourceSets.main.output) {
include 'myPackages/**'
}
// set temp location
destinationDir = file("build/tmp")
archiveName = "signed.jar"
// sign it.
doLast {
// your ant info...
//I am going to assume you already know how to get this without hardcoding it.
ant.signjar(jar: getArchivePath(),
alias: project.sign_alias,
keystore: project.sign_keystore,
storepass: project.sign_password,
keypass: project.sign_password)
}
}
task signedJar(type: zip, dependsOn: 'classes') {
dependsOn project.tasks.signedJart
extension = "jar" // cheating
// from the signed jar
from (zipTree(project.tasks.signedJar.getArchivePath())) {
include "**" // ensure this doesnt get excluded by the later include line
}
// the other stuff
// this is task is already pulling from the classes dir, so we dont have to re-specify that..
from(sourceSets.main.output) {
include 'otherPackages/**'
}
// ignore new duplicate files.. just in case
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
reobf {
obfOutput.clear(); // clear the default jar out
reobf tasks.signedJar { spec ->
spec.classpath = project.sourceSets.main.compileClasspath
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment