Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge #4620
Browse files Browse the repository at this point in the history
4620: Migrate the Glean SDK to the Rust implementation r=Dexterp37 a=Dexterp37

This completely removes the Kotlin implementation of the Glean SDK from this repository. It introduces aliases that are used instead.

Please note that integration tests keep living in this repository as part of the [Glean sample app](https://github.com/mozilla-mobile/android-components/tree/master/samples/glean/src/androidTest/java/org/mozilla/samples/glean).

**Note: this is a massive PR with deletion, mostly. I'd recommend reviewing it commit-by-commit**

**TODO**

- [x] remove the glean binary;
- [x] depend on the maven version of the Glean SDK.



Co-authored-by: Alessio Placitelli <[email protected]>
  • Loading branch information
MozLando and Dexterp37 committed Oct 24, 2019
2 parents 321d499 + 12163f1 commit 7b25cd7
Show file tree
Hide file tree
Showing 113 changed files with 141 additions and 16,981 deletions.
4 changes: 4 additions & 0 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ object Versions {

const val mozilla_appservices = "0.42.0"

const val mozilla_glean = "19.0.0"

const val material = "1.0.0"

object AndroidX {
Expand Down Expand Up @@ -120,6 +122,8 @@ object Dependencies {

const val mozilla_fxa = "org.mozilla.appservices:fxaclient:${Versions.mozilla_appservices}"

const val mozilla_glean_forUnitTests = "org.mozilla.telemetry:glean-forUnitTests:${Versions.mozilla_glean}"

const val mozilla_sync_logins = "org.mozilla.appservices:logins:${Versions.mozilla_appservices}"
const val mozilla_places = "org.mozilla.appservices:places:${Versions.mozilla_appservices}"
const val mozilla_sync_manager = "org.mozilla.appservices:syncmanager:${Versions.mozilla_appservices}"
Expand Down
1 change: 1 addition & 0 deletions components/lib/crash/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dependencies {
testImplementation Dependencies.testing_mockito
testImplementation Dependencies.testing_coroutines
testImplementation Dependencies.testing_mockwebserver
testImplementation Dependencies.mozilla_glean_forUnitTests
}

ext.gleanGenerateMarkdownDocs = true
Expand Down
1 change: 1 addition & 0 deletions components/service/experiments/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dependencies {
testImplementation Dependencies.kotlin_reflect
testImplementation Dependencies.androidx_work_testing
testImplementation Dependencies.androidx_espresso_core
testImplementation Dependencies.mozilla_glean_forUnitTests

testImplementation project(':support-test')
testImplementation project(':lib-fetch-httpurlconnection')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.work.testing.WorkManagerTestInitHelper
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import mozilla.components.service.glean.Glean
import mozilla.components.service.glean.testing.GleanTestRule
import mozilla.components.support.test.any
import mozilla.components.support.test.eq
import mozilla.components.support.test.mock
Expand All @@ -25,6 +26,7 @@ import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.assertNotNull
import org.junit.Rule
import org.mockito.ArgumentMatchers.anyBoolean
import org.mockito.ArgumentMatchers.anyInt
import org.mockito.ArgumentMatchers.anyString
Expand All @@ -49,6 +51,9 @@ class ExperimentsTest {

private val EXAMPLE_CLIENT_ID = "c641eacf-c30c-4171-b403-f077724e848a"

@get:Rule
val gleanRule = GleanTestRule(context)

private val experimentsList = listOf(
createDefaultExperiment(
id = "first-id",
Expand Down
51 changes: 25 additions & 26 deletions components/service/glean/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,15 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

plugins {
id "com.jetbrains.python.envs" version "0.0.26"
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

/*
* This defines the location of the JSON schema used to validate the pings
* created during unit testing.
* This uses a specific version of the schema identified by a git commit hash.
*/
String GLEAN_PING_SCHEMA_GIT_HASH = "c566160"
String GLEAN_PING_SCHEMA_URL = "https://raw.githubusercontent.com/mozilla-services/mozilla-pipeline-schemas/$GLEAN_PING_SCHEMA_GIT_HASH/schemas/glean/baseline/baseline.1.schema.json"

android {
compileSdkVersion config.compileSdkVersion

defaultConfig {
minSdkVersion config.minSdkVersion
targetSdkVersion config.targetSdkVersion

buildConfigField("String", "LIBRARY_VERSION", "\"" + config.componentsVersion + "\"")
buildConfigField("String", "GLEAN_PING_SCHEMA_URL", "\"" + GLEAN_PING_SCHEMA_URL + "\"")
}

buildTypes {
Expand All @@ -36,27 +21,41 @@ android {
}
}

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-forUnitTests:${Versions.mozilla_glean}"

dependencies {
implementation Dependencies.kotlin_stdlib
implementation Dependencies.kotlin_coroutines
implementation Dependencies.androidx_lifecycle_extensions
implementation Dependencies.androidx_work_runtime

api GLEAN_LIBRARY

implementation project(':support-ktx')
implementation project(':support-base')
implementation project(':concept-fetch')
implementation project(':lib-fetch-httpurlconnection')
implementation project(':support-utils')

// We need a compileOnly dependency on the following block of testing
// libraries in order to expose the GleanTestRule to applications/libraries
// using the Glean SDK.
// We can't simply create a separate package otherwise we would need
// to provide a public API for the testing package to access the
// Glean internals, which is something we would not want to do.
compileOnly Dependencies.testing_junit
compileOnly Dependencies.androidx_work_testing

testImplementation Dependencies.androidx_test_core

testImplementation Dependencies.testing_junit
Expand All @@ -67,9 +66,9 @@ dependencies {

testImplementation project(':support-test')
testImplementation project(':lib-fetch-okhttp')

testImplementation GLEAN_LIBRARY_FORUNITTESTS
}

apply from: '../../../publish.gradle'
ext.configurePublish(config.componentsGroupId, archivesBaseName, project.ext.description)

apply from: './scripts/sdk_generator.gradle'
243 changes: 0 additions & 243 deletions components/service/glean/metrics.yaml

This file was deleted.

Loading

0 comments on commit 7b25cd7

Please sign in to comment.