-
-
Save jgcmarins/03904901c12ec14d88c77edcb5ff037a to your computer and use it in GitHub Desktop.
Automated AAR build, move to folder and deJetify. Just add this to to end of your build.gradle file and run `prepareAAR` task
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def manifest = new XmlSlurper().parse(file("./src/main/AndroidManifest.xml")) | |
def packageName = manifest.@package.text() | |
task copyAAR(type: Copy) { | |
from "$projectDir/build/outputs/aar/" | |
include 'android.aar' | |
into "$projectDir/AAR/" | |
rename 'android.aar', "${packageName}.aar" | |
doLast { | |
new File("$projectDir/AAR/build.gradle").text = """ | |
configurations.maybeCreate("default") | |
artifacts.add("default", file('${packageName}.aar')) | |
""" | |
} | |
} | |
task deJetify(type: Exec) { | |
workingDir "$projectDir/AAR/" | |
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) { | |
commandLine 'cmd', '/c', 'npx', 'jetifier-standalone', '-r', '-i', "${packageName}.aar", '-o', "${packageName}-support.aar" | |
} else { | |
commandLine 'npx', 'jetifier-standalone', '-r', '-i', "${packageName}.aar", '-o', "${packageName}-support.aar" | |
} | |
ignoreExitValue true | |
doLast { | |
if(execResult.exitValue != 0) { | |
logger.error("It seems that you don't have jetifier installed. Try installing it by `npm install jetifier` and try again") | |
} | |
} | |
} | |
task prepareAAR(type: GradleBuild) { | |
tasks = ['assemble', 'copyAAR', 'deJetify'] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment