Last active
August 29, 2015 14:04
-
-
Save f2prateek/3fc33c28125cf2824b58 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// This is an aar, we'll ignore resources, and extract clases.jar | |
def outputDirName = "${buildDir}\\unpacked\\dist\\extracted" | |
System.out.println('Start') | |
print(file(outputDirName).list()) | |
def extract = project.tasks.create "jarExtract${it.name.capitalize()}", Copy | |
extract.from it | |
extract.into outputDirName | |
extract.execute() | |
System.out.println('Extracted AAR') | |
print(file(outputDirName).list()) | |
def extractClasses = project.tasks.create "jarExtractClasses${it.name.capitalize()}", Copy | |
extractClasses.from outputDirName + '\\classes.jar' | |
extractClasses.into outputDirName | |
extractClasses.execute() | |
System.out.println(outputDirName + '\\classes.jar') | |
System.out.println('Extracted Classes') | |
print(file(outputDirName).list()) | |
fileTree(outputDirName).matching { | |
exclude 'R.txt' | |
exclude 'AndroidManifest.xml' | |
exclude 'assets/' | |
exclude 'libs/' | |
exclude 'res/' | |
exclude 'aidl/' | |
exclude 'classes.jar' | |
exclude '*.aar' | |
} | |
} |
This file contains hidden or 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
// This is an aar, we'll ignore resources, and extract clases.jar | |
zipTree(it).matching { | |
exclude 'R.txt' | |
exclude 'AndroidManifest.xml' | |
exclude 'assets/' | |
exclude 'res/' | |
exclude 'aidl/' | |
exclude 'libs/' // not sure where these are from, probably being duplicated through javaCompile and configurations.compile | |
}.visit { | |
if (!it.name.endsWith('.jar')) { | |
def extractJar = project.tasks.create "extractJar${it.name.capitalize()}", Copy | |
extractJar.from it | |
System.out.println(packageJar.destinationDir) | |
extractJar.into packageJar.destinationDir | |
extractJar.execute() | |
} | |
} |
This file contains hidden or 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
// This is an aar, we'll ignore resources, and extract clases.jar | |
def outputDirName = "${buildDir}\\unpacked\\dist\\extracted" | |
System.out.println("output directory: " + outputDirName) | |
System.out.println("AAR Package: " + it) | |
System.out.println("AAR Package path: " + it.path) | |
printFiles(new File(outputDirName).list()) | |
// Unzip the AAR, we only need src folders and classes.jar | |
def extract = project.tasks.create "jarExtract${it.name.capitalize()}", Copy | |
extract.from zipTree(new File(it.path)).matching { | |
exclude 'R.txt' | |
exclude 'AndroidManifest.xml' | |
exclude 'assets/' | |
exclude 'libs/' | |
exclude 'res/' | |
exclude 'aidl/' | |
exclude 'classes.jar' | |
exclude 'proguard.txt' | |
} | |
extract.into file(new File(outputDirName)) | |
extract.execute() | |
printFiles(new File(outputDirName).list()) | |
// Unzip the classes.jar | |
def extractClasses = project.tasks.create "jarExtractClasses${it.name.capitalize()}", Copy | |
extractClasses.from file(new File(outputDirName, 'classes.jar')) | |
extractClasses.into file(new File(outputDirName)) | |
extractClasses.execute() | |
printFiles(file(new File(outputDirName)).list()) | |
return fileTree(outputDirName) |
This file contains hidden or 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 tempDir = "${buildDir}\\unpacked\\dist\\extracted" | |
def extractAar = project.tasks.create "jarExtract${it.name.capitalize()}", Copy | |
extractAar.from zipTree(it) | |
extractAar.into file(tempDir) | |
extractAar.execute() | |
// fileTree(tempDir).matching { include '*.jar' }.visit { System.out.println(it) } | |
def extractClassesJar = project.tasks.create "jarExtractClasses${it.name.capitalize()}", | |
Copy | |
extractClassesJar.from zipTree(file(tempDir + "\\classes.jar")) | |
extractClassesJar.into file(tempDir) | |
extractClassesJar.execute() | |
return fileTree(tempDir) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment