Skip to content

Commit

Permalink
Merge pull request #32 from adwiv/fix-compile-dependencies
Browse files Browse the repository at this point in the history
2.2 Support - Fixes issue 30, Secondary dependencies
  • Loading branch information
adwiv committed Sep 28, 2016
2 parents b0cd272 + fa27f8b commit 65cf9f7
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions fat-aar.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ dependencies {
compile configurations.embedded
}

ext.libraryPaths = new ArrayList<String>()
ext.embeddedAarDirs = new ArrayList<String>()
ext.build_dir = "build";

Expand All @@ -81,7 +82,6 @@ ext.pree_r2x_dir = "build/fat-aar/release/pre-r2x";
ext.post_r2x_dir = "build/fat-aar/release/post-r2x";

afterEvaluate {

// the list of dependency must be reversed to use the right overlay order.
def dependencies = new ArrayList(configurations.embedded.resolvedConfiguration.firstLevelModuleDependencies)
dependencies.reverseEach {
Expand All @@ -91,6 +91,14 @@ afterEvaluate {
}
}

dependencies.each {
collectDependencies(it)
}

libraryPaths.each {
println "Compile Dependency: $it";
}

// Merge Assets
generateReleaseAssets.dependsOn embedAssets

Expand Down Expand Up @@ -128,6 +136,28 @@ afterEvaluate {
bundleRelease.dependsOn embedJavaJars
}

public void collectDependencies(ResolvedDependency it) {
it.moduleArtifacts.each {
artifact ->
if (artifact.type == 'aar') {
def aarPath = "${exploded_aar_dir}/${it.moduleGroup}/${it.moduleName}/${it.moduleVersion}"
if (!embeddedAarDirs.contains(aarPath) && !libraryPaths.contains(aarPath))
libraryPaths.add(aarPath)
} else if (artifact.type == 'jar') {
def artifactPath = artifact.file
if (!libraryPaths.contains(artifactPath))
libraryPaths.add(artifactPath)
} else {
throw new Exception("Unhandled Artifact of type ${artifact.type}")
}
}

it.children.each {
child ->
collectDependencies(child)
}
}

task embedLibraryResources << {
def oldInputResourceSet = packageReleaseResources.inputResourceSets
packageReleaseResources.conventionMapping.map("inputResourceSets") {
Expand Down Expand Up @@ -275,11 +305,12 @@ task generateRClass(type: JavaCompile, dependsOn: generateRJava) {

task generateXClass(type: ProGuardTask, dependsOn: generateRClass) {
delete(post_r2x_dir)
println generateXClass

injars pree_r2x_dir, filter: '!**/R.java'
outjars post_r2x_dir
libraryjars android.getBootClasspath()
libraryjars classs_release_dir
libraryjars libraryPaths
dontshrink
dontoptimize
dontpreverify
Expand Down Expand Up @@ -334,17 +365,14 @@ task embedManifests << {
File origManifest = file("$bundle_release_dir/AndroidManifest.xml")
File copyManifest = file("$bundle_release_dir/AndroidManifest.orig.xml")
File aaptManifest = file("$manifest_aaapt_dir/AndroidManifest.xml")

copy {
from origManifest.parentFile
into copyManifest.parentFile
include origManifest.name
rename(origManifest.name, copyManifest.name)
}

String outManifestLocation = origManifest.absolutePath
String outAaptSafeManifestLocation = aaptManifest.absolutePath

try {
Invoker manifestMergerInvoker = ManifestMerger2.newMerger(copyManifest, mLogger, MergeType.APPLICATION)

Expand Down

0 comments on commit 65cf9f7

Please sign in to comment.