Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. def manifest = new XmlSlurper().parse(file("./src/main/AndroidManifest.xml"))
  2. def packageName = manifest.@package.text()
  3.  
  4. task copyAAR(type: Copy) {
  5. from "$projectDir/build/outputs/aar/"
  6. include 'android.aar'
  7. into "$projectDir/AAR/"
  8. rename 'android.aar', "${packageName}.aar"
  9. doLast {
  10. new File("$projectDir/AAR/build.gradle").text = """
  11. configurations.maybeCreate("default")
  12. artifacts.add("default", file('${packageName}.aar'))
  13. """
  14. }
  15. }
  16.  
  17. task deJetify(type: Exec) {
  18. workingDir "$projectDir/AAR/"
  19. if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
  20. commandLine 'cmd', '/c', 'npx', 'jetifier-standalone', '-r', '-i', "${packageName}.aar", '-o', "${packageName}-support.aar"
  21. } else {
  22. commandLine 'npx', 'jetifier-standalone', '-r', '-i', "${packageName}.aar", '-o', "${packageName}-support.aar"
  23. }
  24. ignoreExitValue true
  25.  
  26. doLast {
  27. if(execResult.exitValue != 0) {
  28. logger.error("It seems that you don't have jetifier installed. Try installing it by `npm install jetifier` and try again")
  29. }
  30. }
  31. }
  32.  
  33. task prepareAAR(type: GradleBuild) {
  34. tasks = ['assemble', 'copyAAR', 'deJetify']
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement