Reputation: 51
I have encrypted a file(API key,passwords etc), added in codebase. I need to add a custom task(task encIt) to decrypt the file(will call decrypt.sh to decrypt).This task is added in build.gradle file.
I have tested this by calling "gradle encIt" from terminal and it works fine(decrypting the file as expected), But I need this to be happened every time I build the gradle; how to do that?
This is the task:
task encIt(type:Exec) {
println("WORKING")
commandLine "./decrypt.sh"
println("WORKING")
}
This is the script file :
#!/usr/bin/env sh
echo "inside working"
openssl enc -aes-256-cbc -d -in ../encrypted.key -out key.txt -pass pass:Abcdk5551
echo "inside working"
I have tested this
senario 1:gradle encIt
result : WORKING
inside working
inside working
WORKING
The file is decrypted
senario 1:gradle/gradlew (no arguments)
result : WORKING
WORKING
The file is not getting decrypted
please help!
using gradle version 5.4.1 macbook pro android studio 3.4.1
Upvotes: 2
Views: 314
Reputation: 145
editapp/build.gradle
,add below code
task encIt(type:Exec) {
println("WORKING")
commandLine "./decrypt.sh"
println("WORKING")
}
afterEvaluate {
assembleDebug.dependsOn encIt
assembleRelease.dependsOn encIt
}
It's worked with:
run
button which on Android Studio./gradlew build
./gradlew assemble
./gradlew assembleDebug
./gradlew assembleRelease
Upvotes: 2