1

Using Android gradle plugin of version 3.0.1.

I have the application module :app and the library module :lib included in :app module: implementation(project(':lib')). Module :lib has native code. So, it has :lib:externalNativeBuildRelease task. I need to make this task dependent on the Proguard task of the root module :app.

I need it due to native code obfuscation. I do not use standard approach of keeping java code called from native. I obfuscate it as well, replacing code in native. So, to process native code correctly, I need mapping.txt, generated by Proguard, before start of native build.

fastholf
  • 11
  • 3

1 Answers1

0

Well, no answer so far. I've found solution, that I do not like, but it works. In the :app build.gradle:

android.applicationVariants.matching {
    it.buildType.name == android.buildTypes.release.name
}.whenObjectAdded {
    Task nativeBuildTask = tasks.getByName('externalNativeBuildRelease')
    Task libNativeBuildTask = project(':lib')
            .getTasksByName('externalNativeBuildRelease', true)
            .first()
    tasks.matching { Task task ->
        task.name.contains('Proguard') 
                && task.name.contains('Release')
    }.all { Task proguardTask ->
        nativeBuildTask.dependsOn proguardTask
        libNativeBuildTask.dependsOn proguardTask
    }
}

Hope someone will find better way.

fastholf
  • 11
  • 3