Do not force Android packaging tasks to re-run on every build.

There where two issues.  The most obvious is that the task name that
merges JNI libraries has evolved; it's now `merge{...}JniLibFolders`.

The second, which really caught me out, is that when both
`main.jniLibs.srcDirs` and `debug.jniLibs.srcDirs` contain the same
path, then the Android source set merger silently fails.  I don't
really understand what's happening here, I just know that using only
`main.jniLibs.srcDirs` solves the issue.

Fixes #2659.
This commit is contained in:
Nick Alexander 2020-02-25 14:55:16 -08:00 коммит произвёл Ryan Kelly
Родитель 8b716c34fe
Коммит 2921db3571
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: FB70C973A037D258
10 изменённых файлов: 9 добавлений и 30 удалений

Просмотреть файл

@ -109,7 +109,7 @@ afterEvaluate {
productFlavor += "${it.name.capitalize()}"
}
def buildType = "${variant.buildType.name.capitalize()}"
tasks["generate${productFlavor}${buildType}Assets"].dependsOn(project(':full-megazord').tasks["cargoBuild"])
tasks["merge${productFlavor}${buildType}JniLibFolders"].dependsOn(project(':full-megazord').tasks["cargoBuild"])
// For unit tests.
tasks["process${productFlavor}${buildType}UnitTestJavaRes"].dependsOn(project(':full-megazord').tasks["cargoBuild"])

Просмотреть файл

@ -125,7 +125,7 @@ afterEvaluate {
productFlavor += "${it.name.capitalize()}"
}
def buildType = "${variant.buildType.name.capitalize()}"
tasks["generate${productFlavor}${buildType}Assets"].dependsOn(project(':full-megazord').tasks["cargoBuild"])
tasks["merge${productFlavor}${buildType}JniLibFolders"].dependsOn(project(':full-megazord').tasks["cargoBuild"])
// For unit tests.
tasks["process${productFlavor}${buildType}UnitTestJavaRes"].dependsOn(project(':full-megazord').tasks["cargoBuild"])

Просмотреть файл

@ -110,7 +110,7 @@ afterEvaluate {
productFlavor += "${it.name.capitalize()}"
}
def buildType = "${variant.buildType.name.capitalize()}"
tasks["generate${productFlavor}${buildType}Assets"].dependsOn(project(':full-megazord').tasks["cargoBuild"])
tasks["merge${productFlavor}${buildType}JniLibFolders"].dependsOn(project(':full-megazord').tasks["cargoBuild"])
// For unit tests.
tasks["process${productFlavor}${buildType}UnitTestJavaRes"].dependsOn(project(':full-megazord').tasks["cargoBuild"])

Просмотреть файл

@ -81,7 +81,7 @@ afterEvaluate {
productFlavor += "${it.name.capitalize()}"
}
def buildType = "${variant.buildType.name.capitalize()}"
tasks["generate${productFlavor}${buildType}Assets"].dependsOn(project(':full-megazord').tasks["cargoBuild"])
tasks["merge${productFlavor}${buildType}JniLibFolders"].dependsOn(project(':full-megazord').tasks["cargoBuild"])
// For unit tests.
tasks["process${productFlavor}${buildType}UnitTestJavaRes"].dependsOn(project(':full-megazord').tasks["cargoBuild"])

Просмотреть файл

@ -109,7 +109,7 @@ afterEvaluate {
productFlavor += "${it.name.capitalize()}"
}
def buildType = "${variant.buildType.name.capitalize()}"
tasks["generate${productFlavor}${buildType}Assets"].dependsOn(project(':full-megazord').tasks["cargoBuild"])
tasks["merge${productFlavor}${buildType}JniLibFolders"].dependsOn(project(':full-megazord').tasks["cargoBuild"])
// For unit tests.
tasks["process${productFlavor}${buildType}UnitTestJavaRes"].dependsOn(project(':full-megazord').tasks["cargoBuild"])

Просмотреть файл

@ -108,7 +108,7 @@ afterEvaluate {
productFlavor += "${it.name.capitalize()}"
}
def buildType = "${variant.buildType.name.capitalize()}"
tasks["generate${productFlavor}${buildType}Assets"].dependsOn(project(':full-megazord').tasks["cargoBuild"])
tasks["merge${productFlavor}${buildType}JniLibFolders"].dependsOn(project(':full-megazord').tasks["cargoBuild"])
// For unit tests.
tasks["process${productFlavor}${buildType}UnitTestJavaRes"].dependsOn(project(':full-megazord').tasks["cargoBuild"])

Просмотреть файл

@ -111,7 +111,7 @@ afterEvaluate {
productFlavor += "${it.name.capitalize()}"
}
def buildType = "${variant.buildType.name.capitalize()}"
tasks["generate${productFlavor}${buildType}Assets"].dependsOn(project(':full-megazord').tasks["cargoBuild"])
tasks["merge${productFlavor}${buildType}JniLibFolders"].dependsOn(project(':full-megazord').tasks["cargoBuild"])
// For unit tests.
tasks["process${productFlavor}${buildType}UnitTestJavaRes"].dependsOn(project(':full-megazord').tasks["cargoBuild"])

Просмотреть файл

@ -30,11 +30,6 @@ android {
// packagingOptions { doNotStrip "**/*.so" }
}
afterEvaluate {
android.sourceSets.debug.jniLibs.srcDirs = android.sourceSets.main.jniLibs.srcDirs
android.sourceSets.release.jniLibs.srcDirs = android.sourceSets.main.jniLibs.srcDirs
}
configurations {
// There's an interaction between Gradle's resolution of dependencies with different types
// (@jar, @aar) for `implementation` and `testImplementation` and with Android Studio's built-in
@ -95,7 +90,7 @@ afterEvaluate {
productFlavor += "${it.name.capitalize()}"
}
def buildType = "${variant.buildType.name.capitalize()}"
tasks["generate${productFlavor}${buildType}Assets"].dependsOn(tasks["cargoBuild"])
tasks["merge${productFlavor}${buildType}JniLibFolders"].dependsOn(tasks["cargoBuild"])
}
}

Просмотреть файл

@ -30,11 +30,6 @@ android {
// packagingOptions { doNotStrip "**/*.so" }
}
afterEvaluate {
android.sourceSets.debug.jniLibs.srcDirs = android.sourceSets.main.jniLibs.srcDirs
android.sourceSets.release.jniLibs.srcDirs = android.sourceSets.main.jniLibs.srcDirs
}
configurations {
// There's an interaction between Gradle's resolution of dependencies with different types
// (@jar, @aar) for `implementation` and `testImplementation` and with Android Studio's built-in
@ -91,7 +86,7 @@ afterEvaluate {
productFlavor += "${it.name.capitalize()}"
}
def buildType = "${variant.buildType.name.capitalize()}"
tasks["generate${productFlavor}${buildType}Assets"].dependsOn(tasks["cargoBuild"])
tasks["merge${productFlavor}${buildType}JniLibFolders"].dependsOn(tasks["cargoBuild"])
}
}

Просмотреть файл

@ -68,17 +68,6 @@ ext.configurePublish = { jnaForTestConfiguration = null ->
project.afterEvaluate {
forUnitTestsJarTask.dependsOn(tasks["cargoBuild"])
}
// For inscrutable reasons, the various android packaging gradle tasks do
// not get re-run when the underlying rust code changes. Something is not
// correctly configuring gradle's up-to-date checks, but I've reached the
// limit of how much time I'm willing to spend on figuring it out. Deleting
// these intermediate files forces re-execution of the task.
// Ref https://github.com/mozilla/application-services/issues/2659
task forceGradleToRefreshPackagedLibsWhenTheRustCodeChanges(type: Delete) {
delete "$buildDir/intermediates/merged_jni_libs"
}
preBuild.dependsOn(forceGradleToRefreshPackagedLibsWhenTheRustCodeChanges)
}
task sourcesJar(type: Jar) {