I'd like to make Gradle substitute the applicationId and package variables with a random string at build time. Here is was I tried:
// build.gradle (project)
class Scrambler {
Random random = new Random()
String getRandomString(int i) {
return random.with {(1..(6 + random.nextInt(i))).collect {(('a'..'z')).join()[ nextInt((('a'..'z')).join().length())]}.join()}
}
}
Scrambler scrambler = new Scrambler()
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.${scrambler.getRandomString(2)}.${scrambler.getRandomString(2)}"
// com.ohukcgn.vpybhkh (example)
...
At this point, all java classes are still bind to the original package name:
com.ohukcgn.vpybhkh/com.original.name.MainActivity // example
And that's legit because I did not change the path for them.
But now, what should I do to have a complete refactoring?
com.ohukcgn.vpybhkh/com.ohukcgn.vpybhkh.MainActivity // goal
I could do a script for that (that would rename directories and so on...), but I'm not sure would be the right thing to do.
Aucun commentaire:
Enregistrer un commentaire