Skip to content

Commit

Permalink
Bug 1823532 - Remove jnaForTest from project Gradle build files.
Browse files Browse the repository at this point in the history
Also remove the now-unneeded jna dependency inclusion.
  • Loading branch information
rvandermeulen authored and mergify[bot] committed Mar 21, 2023
1 parent 281ee0b commit 92c1b9e
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 85 deletions.
22 changes: 0 additions & 22 deletions android-components/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -245,28 +245,6 @@ subprojects {
}
}

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
// JUnit test runner. The runtime classpath in the built-in JUnit test runner gets the
// dependency from the `implementation`, which is type @aar, and therefore the JNA dependency
// doesn't provide the JNI dispatch libraries in the correct Java resource directories. I think
// what's happening is that @aar type in `implementation` resolves to the @jar type in
// `testImplementation`, and that it wins the dependency resolution battle.
//
// A workaround is to add a new configuration which depends on the @jar type and to reference
// the underlying JAR file directly in `testImplementation`. This JAR file doesn't resolve to
// the @aar type in `implementation`. This works when invoked via `gradle`, but also sets the
// correct runtime classpath when invoked with Android Studio's built-in JUnit test runner.
// Success!
jnaForTest
}

dependencies {
jnaForTest ComponentsDependencies.thirdparty_jna
testImplementation files(configurations.jnaForTest.copyRecursive().files)
}

if (project.hasProperty("coverage") && project.name != "support-test") {
android.buildTypes.all { buildType ->
tasks.withType(Test).configureEach() {
Expand Down
17 changes: 0 additions & 17 deletions android-components/components/service/glean/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,6 @@ android {
namespace 'mozilla.components.service.glean'
}

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
// JUnit test runner. The runtime classpath in the built-in JUnit test runner gets the
// dependency from the `implementation`, which is type @aar, and therefore the JNA dependency
// doesn't provide the JNI dispatch libraries in the correct Java resource directories. I think
// what's happening is that @aar type in `implementation` resolves to the @jar type in
// `testImplementation`, and that it wins the dependency resolution battle.
//
// A workaround is to add a new configuration which depends on the @jar type and to reference
// the underlying JAR file directly in `testImplementation`. This JAR file doesn't resolve to
// the @aar type in `implementation`. This works when invoked via `gradle`, but also sets the
// correct runtime classpath when invoked with Android Studio's built-in JUnit test runner.
// Success!
jnaForTest
}

// Define library names and version constants.
String GLEAN_LIBRARY = "org.mozilla.telemetry:glean:${Versions.mozilla_glean}"
String GLEAN_LIBRARY_FORUNITTESTS = "org.mozilla.telemetry:glean-native-forUnitTests:${Versions.mozilla_glean}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ object Versions {
// zxing 3.4+ requires a minimum API of 24 or higher
const val zxing = "3.3.3"

const val jna = "5.13.0"
const val disklrucache = "2.0.2"
const val leakcanary = "2.10"

Expand Down Expand Up @@ -197,7 +196,6 @@ object ComponentsDependencies {
const val thirdparty_okhttp_urlconnection = "com.squareup.okhttp3:okhttp-urlconnection:${Versions.okhttp}"
const val thirdparty_sentry_latest = "io.sentry:sentry-android:${Versions.sentry_latest}"
const val thirdparty_zxing = "com.google.zxing:core:${Versions.zxing}"
const val thirdparty_jna = "net.java.dev.jna:jna:${Versions.jna}@jar"
const val thirdparty_disklrucache = "com.jakewharton:disklrucache:${Versions.disklrucache}"

const val firebase_messaging = "com.google.firebase:firebase-messaging:${Versions.Firebase.messaging}"
Expand Down
20 changes: 0 additions & 20 deletions fenix/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -458,33 +458,13 @@ nimbus {
experimenterManifest = ".experimenter.yaml"
}

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
// JUnit test runner. The runtime classpath in the built-in JUnit test runner gets the
// dependency from the `implementation`, which is type @aar, and therefore the JNA dependency
// doesn't provide the JNI dispatch libraries in the correct Java resource directories. I think
// what's happening is that @aar type in `implementation` resolves to the @jar type in
// `testImplementation`, and that it wins the dependency resolution battle.
//
// A workaround is to add a new configuration which depends on the @jar type and to reference
// the underlying JAR file directly in `testImplementation`. This JAR file doesn't resolve to
// the @aar type in `implementation`. This works when invoked via `gradle`, but also sets the
// correct runtime classpath when invoked with Android Studio's built-in JUnit test runner.
// Success!
jnaForTest
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
freeCompilerArgs += "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
}
}

dependencies {
jnaForTest FenixDependencies.jna
testImplementation files(configurations.jnaForTest.copyRecursive().files)

implementation project(':browser-engine-gecko')

implementation FenixDependencies.kotlin_coroutines
Expand Down
3 changes: 0 additions & 3 deletions fenix/buildSrc/src/main/java/FenixDependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ object FenixVersions {
const val leakcanary = "2.10"
const val osslicenses_plugin = "0.10.4"
const val detekt = "1.19.0"
const val jna = "5.13.0"

const val androidx_activity = "1.6.1"
const val androidx_compose = "1.3.1"
Expand Down Expand Up @@ -123,8 +122,6 @@ object FenixDependencies {
const val adjust = "com.adjust.sdk:adjust-android:${FenixVersions.adjust}"
const val installreferrer = "com.android.installreferrer:installreferrer:${FenixVersions.installreferrer}"

const val jna = "net.java.dev.jna:jna:${FenixVersions.jna}@jar"

const val junit = "junit:junit:${FenixVersions.junit}"
const val mockk = "io.mockk:mockk:${FenixVersions.mockk}"
const val mockk_android = "io.mockk:mockk-android:${FenixVersions.mockk}"
Expand Down
19 changes: 0 additions & 19 deletions focus-android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -206,23 +206,6 @@ nimbus {
experimenterManifest = ".experimenter.yaml"
}

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
// JUnit test runner. The runtime classpath in the built-in JUnit test runner gets the
// dependency from the `implementation`, which is type @aar, and therefore the JNA dependency
// doesn't provide the JNI dispatch libraries in the correct Java resource directories. I think
// what's happening is that @aar type in `implementation` resolves to the @jar type in
// `testImplementation`, and that it wins the dependency resolution battle.
//
// A workaround is to add a new configuration which depends on the @jar type and to reference
// the underlying JAR file directly in `testImplementation`. This JAR file doesn't resolve to
// the @aar type in `implementation`. This works when invoked via `gradle`, but also sets the
// correct runtime classpath when invoked with Android Studio's built-in JUnit test runner.
// Success!
jnaForTest
}

dependencies {
implementation FocusDependencies.androidx_appcompat
implementation FocusDependencies.androidx_browser
Expand Down Expand Up @@ -319,8 +302,6 @@ dependencies {
focusImplementation FocusDependencies.adjust
focusImplementation FocusDependencies.install_referrer // Required by Adjust

jnaForTest FocusDependencies.jna
testImplementation files(configurations.jnaForTest.copyRecursive().files)
testImplementation "org.mozilla.telemetry:glean-native-forUnitTests:${project.ext.glean_version}"

testImplementation FocusDependencies.testing_junit_api
Expand Down
2 changes: 0 additions & 2 deletions focus-android/buildSrc/src/main/java/FocusDependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ object FocusVersions {
}

object ThirdParty {
const val jna = "5.13.0"
const val leakcanary = "2.10"
const val sentry = "6.15.0"
}
Expand Down Expand Up @@ -112,7 +111,6 @@ object FocusDependencies {
const val google_play = "com.google.android.play:core:${FocusVersions.Google.play}"
const val kotlin_gradle_plugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${FocusVersions.Gradle.kotlin_plugin}"
const val android_gradle_plugin = "com.android.tools.build:gradle:${FocusVersions.Gradle.android_plugin}"
const val jna = "net.java.dev.jna:jna:${FocusVersions.ThirdParty.jna}@jar"
const val leakcanary = "com.squareup.leakcanary:leakcanary-android-core:${FocusVersions.ThirdParty.leakcanary}"
const val sentry = "io.sentry:sentry-android:${FocusVersions.ThirdParty.sentry}"

Expand Down

0 comments on commit 92c1b9e

Please sign in to comment.