bugsnag/bugsnag-js

View on GitHub
packages/react-native/android/build.gradle

Summary

Maintainability
Test Coverage
def isNewArchitectureEnabled() {
    return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}

apply plugin: 'com.android.library'
if (isNewArchitectureEnabled()) {
    apply plugin: 'com.facebook.react'
}

def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

android {
    buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
    compileSdkVersion safeExtGet('compileSdkVersion', 28)

    if (android.hasProperty('namespace')) {
        namespace 'com.bugsnag.reactnative'
    }

    defaultConfig {
        minSdkVersion safeExtGet('minSdkVersion', 16)
        targetSdkVersion safeExtGet('targetSdkVersion', 28)
        versionCode 1
        versionName '7.0.0'
        consumerProguardFiles 'proguard-rules.pro'
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
    }
    lintOptions {
        abortOnError true
        warningsAsErrors true
        baseline file('lint-baseline.xml')
    }

    sourceSets {
        main {
            if (isNewArchitectureEnabled() || safeExtGet('bugsnagdev', false)) {
                java.srcDirs += ['src/newarch/java']
            } else {
                java.srcDirs += ['src/oldarch/java']
            }
        }
    }
}

dependencies {
    api "com.bugsnag:bugsnag-android:5.32.3"
    api "com.bugsnag:bugsnag-plugin-react-native:5.32.3"
    implementation 'com.facebook.react:react-native:+'

    testImplementation "junit:junit:4.12"
    testImplementation "org.mockito:mockito-core:2.28.2"
}

// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
// once released, it should look in the node_modules at the root of the project.
//
// In development, we need to edit this to look at the top-level node_modules of
// the monorepo instead.
def facebookRepo = "$rootDir/../node_modules/react-native/android"

// A copy of bugsnag-android AAR artefacts are stored in @bugsnag/react-native/android,
// as part of a local maven repository. This adds the repository as a source of
// dependencies that Gradle can resolve.
def bugsnagRepo = "$rootDir/../node_modules/@bugsnag/react-native/android"

if (safeExtGet("bugsnagdev", false)) {
    project.logger.lifecycle("Development mode enabled, searching for dependencies at top of monorepo.")
    facebookRepo = "$rootDir/../../../node_modules/react-native/android"
    bugsnagRepo = "$rootDir"
    if (isNewArchitectureEnabled()) {
        react {
            codegenDir = file("$rootDir/../../../node_modules/react-native-codegen")
        }
    }
}

allprojects {
    repositories {
        maven { url facebookRepo }
        maven { url bugsnagRepo }
        mavenCentral()
        google()
    }
}

apply plugin: 'checkstyle'

checkstyle {
    toolVersion = "8.18"
}

task("checkstyle", type: Checkstyle) {
    configFile rootProject.file("config/checkstyle/checkstyle.xml")
    source  "src/"
    include "**/*.java"
    exclude "**/external/**/*.java"
    classpath = files()
}