diff --git a/android/build.gradle b/android/build.gradle index de22598..ac92e26 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,17 +1,29 @@ -buildscript { - // The Android Gradle plugin is only required when opening the android folder stand-alone. - // This avoids unnecessary downloads and potential conflicts when the library is included as a - // module dependency in an application project. - if (project == rootProject) { - repositories { - mavenCentral() - google() - } - def buildGradleVersion = ext.has('buildGradlePluginVersion') ? ext.get('buildGradlePluginVersion') : '4.2.0' +import groovy.json.JsonSlurper + +def computeVersionName() { + // dynamically retrieve version from package.json + def slurper = new JsonSlurper() + def json = slurper.parse(file('../package.json'), "utf-8") + return json.version +} - dependencies { - classpath "com.android.tools.build:gradle:$buildGradleVersion" - } +buildscript { + ext { + buildToolsVersion = "29.0.0" + minSdkVersion = 19 + compileSdkVersion = 28 + targetSdkVersion = 28 + supportLibVersion = "28.0.0" + } + repositories { + google() + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:7.4.2' + classpath 'de.undercouch:gradle-download-task:3.4.3' + classpath 'com.google.gms:google-services:4.3.0' + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' } } @@ -22,47 +34,65 @@ def safeExtGet(prop, fallback) { } android { - compileSdkVersion safeExtGet('compileSdkVersion', 30) - + compileSdkVersion 34 + buildToolsVersion '34.0.0' defaultConfig { - minSdkVersion safeExtGet('minSdkVersion', 16) - targetSdkVersion safeExtGet('targetSdkVersion', 28) - - versionCode 2 - versionName "1.1" + minSdkVersion 19 + targetSdkVersion 34 + versionCode 1 + versionName computeVersionName() } lintOptions { - warning 'InvalidPackage', 'MissingPermission' + abortOnError false + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } - testOptions { - unitTests.returnDefaultValues = true +} + +allprojects { + repositories { + google() + jcenter() + maven { url "$rootDir/../node_modules/react-native/android" } } } repositories { - mavenCentral() google() - maven { - // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - url "$rootDir/../node_modules/react-native/android" - } + mavenCentral() + maven { url 'https://maven.fabric.io/public' } + jcenter() + flatDir { dirs 'libs', '../../node_modules' } } dependencies { - implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}" - implementation "com.android.installreferrer:installreferrer:${safeExtGet('installReferrerVersion', '1.1.2')}" - def firebaseBomVersion = safeExtGet("firebaseBomVersion", null) - def firebaseIidVersion = safeExtGet('firebaseIidVersion', null) - if (firebaseBomVersion) { - implementation platform("com.google.firebase:firebase-bom:${firebaseBomVersion}") - implementation "com.google.firebase:firebase-iid" - } else if(firebaseIidVersion){ - implementation "com.google.firebase:firebase-iid:${firebaseIidVersion}" - }else{ - def iidVersion = safeExtGet('googlePlayServicesIidVersion', safeExtGet('googlePlayServicesVersion', '17.0.0')) - implementation "com.google.android.gms:play-services-iid:$iidVersion" - } + implementation 'com.facebook.react:react-native:0.73.2' + implementation "com.android.installreferrer:installreferrer:${safeExtGet('installReferrerVersion', '1.1.2')}" + api 'com.android.support:support-v4:28.0.0' + api 'com.android.support:appcompat-v7:28.0.0' + api 'com.android.support:exifinterface:28.0.0' + + def firebaseBomVersion = safeExtGet("firebaseBomVersion", null) + def firebaseIidVersion = safeExtGet('firebaseIidVersion', null) + if (firebaseBomVersion) { + implementation platform("com.google.firebase:firebase-bom:${firebaseBomVersion}") + implementation "com.google.firebase:firebase-iid" + } else if(firebaseIidVersion){ + implementation "com.google.firebase:firebase-iid:${firebaseIidVersion}" + }else{ + def iidVersion = safeExtGet('googlePlayServicesIidVersion', safeExtGet('googlePlayServicesVersion', '17.0.0')) + implementation "com.google.android.gms:play-services-iid:$iidVersion" + } + + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0' + testImplementation "org.mockito:mockito-core:3.6.28" +} - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0' - testImplementation "org.mockito:mockito-core:3.6.28" +task jar(type: Jar) { + from android.sourceSets.main.java.srcDirs + archiveBaseName = 'react-native-device-info' + archiveVersion = computeVersionName() } + diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 0000000..11aa459 --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,28 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx10248m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +MOCKITO_CORE_VERSION=1.+ +POWERMOCK_VERSION=1.6.2 +FEST_ASSERT_CORE_VERSION=2.0M10 + +VERSION_NAME=8.4.2-skillz +GROUP=com.skillz.react-native-device-info + +POM_NAME=ReactNativeDeviceInfo +POM_ARTIFACT_ID=react-native-device-info-android +POM_PACKAGING=aar \ No newline at end of file diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 80cf08e..2ec77e5 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/android/release.gradle b/android/release.gradle new file mode 100644 index 0000000..518b026 --- /dev/null +++ b/android/release.gradle @@ -0,0 +1,100 @@ +apply plugin: 'com.github.dcendents.android-maven' +apply plugin: 'signing' + +def configureReactNativePom(def pom) { + pom.artifactId = POM_ARTIFACT_ID + pom.name = GROUP + pom.packaging = POM_PACKAGING + pom.version = VERSION_NAME + pom.groupId = "com.skillz.react-native-device-info" + archivesBaseName='react-native-device-info-android' + + pom.project { + name POM_NAME + + description 'Device information for React Native iOS and Android' + url 'https://github.com/skillz/react-native-device-info' + + scm { + url 'https://github.com/skillz/react-native-device-info.git' + connection 'scm:git:https://github.com/skillz/react-native-device-info.git' + developerConnection 'scm:git:git@github.com:skillz/react-native-device-info.git' + } + + licenses { + license { + name 'Proprietary' + distribution 'repo' + } + } + + developers { + developer { + id 'skillz' + name 'Skillz' + } + } + } +} + +afterEvaluate { project -> + + task androidSourcesJar(type: Jar) { + classifier = 'sources' + from android.sourceSets.main.java.srcDirs + include '**/*.java' + } + + task renameArchive(type: Copy) { + dependsOn 'assembleLiveRelease' + from('build/outputs/aar') + into('build/outputs/aar') + include('android-release.aar') + rename ('android-release.aar', + 'react-native-device-info.aar') + } + + android.libraryVariants.all { variant -> + def name = variant.name.capitalize() + task "jar${name}"(type: Jar, dependsOn: variant.javaCompile) { + from variant.javaCompile.destinationDir + } + } + + version = VERSION_NAME + group = GROUP + + signing { + required { gradle.taskGraph.hasTask('uploadArchives') } + + sign configurations.archives + } + + uploadArchives { + configuration = configurations.archives + + repositories.mavenDeployer { + beforeDeployment { + MavenDeployment deployment -> signing.signPom(deployment) + } + + repository(url: 'http://nexus.skillz.com/content/repositories/thirdparty/') { + authentication(userName: "garbage", password: "garbage") + } + + configureReactNativePom pom + } + } + + task installArchives(type: Upload) { + configuration = configurations.archives + + repositories.mavenDeployer { + + repository url: "file://${projectDir}/../android" + + configureReactNativePom pom + + } + } +} \ No newline at end of file