Problem:
How to sign jar file
in gradle , same like jarsigner command line tool ?
Solution:
we can make use of AntBuilder of Gradle (which
is inherited from AntBuilder <- Groovy).
Gradle supports all
ant tasks in build file with ease.
You can add task
extension to jar task like this.
jar.doLast {
new
File('build/sign').mkdirs();
ant.signjar(
destDir:
'build/sign',
jar:
'build/libs/*.jar',
alias:"anyAlias",
storetype:"jks",
keystore:"keystore.jks",
storepass:"keystore_password",
preservelastmodified:"true")
}
Now if run below
command u will see singed jar file in build/sign directory, but you have to
create keystore before running gradle command and copy to root project
directory.
>gradle
clean jar
No comments:
Post a Comment
Please comment here