ProGuard Project Dependencies with Plugins

Hello,

In case anyone else sees this, what we ended up doing for are obfuscated build with our test app is we set it up so that it directly used the generated aar files.

So our Debug Dependencies look like:

debugCompile project(path: ‘:plugins:plugin-eventlogger’, configuration:‘dev’)

While our release one looks like:

releaseCompile (name:‘plugin-eventlogger-release’, ext:‘aar’)

AND we include:

flatDir {
    dirs '../generated/releaseLibs'
}

In reality we could have probably just done a dirs for every build output folder, but we avoided that as there are a lot of plugins.

So for our release libraries we have:

task copyReleaseAarFiles {
    copy {
        from ("build/outputs/aar"){
            include(project.name + '-release.aar')
        }
        into "$rootDir/generated/releaseLibs"
    }
    dependsOn ':plugin-eventlogger:assembleRelease'
}

NOTE: I have no idea how good a solution this is. Its one we came up with and it seems to work. Hope it helps anyone else that gets stuck.

Lastly, for the relative path thing, you can pass in a define via -D from the gradle command line, but I was looking for something that was compatible with Android Studio builds as well.

We did the following:

task updateProgaurdProperty << {
    System.properties.setProperty("base.dir", project.projectDir.absolutePath + '/../../')
    println "ProGuard Project Dir:" + project.projectDir
}
preBuild.dependsOn updateProgaurdProperty

Then in our proguard files we can now do:

-applymapping <base.dir>/mapfiles/core-mapping.txt
-printmapping <base.dir>/mapfiles/plugin-eventlogger-mapping.txt