2019-10-06 21:56:58 +08:00
|
|
|
int MILLIS_IN_MINUTE = 1000 * 60
|
|
|
|
int minutesSinceEpoch = System.currentTimeMillis() / MILLIS_IN_MINUTE
|
2019-03-30 14:26:56 +08:00
|
|
|
|
|
|
|
def safeExtGet(prop, fallback) {
|
|
|
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
|
|
}
|
|
|
|
|
2023-02-19 18:20:21 +08:00
|
|
|
def isNewArchitectureEnabled() {
|
|
|
|
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
|
|
}
|
|
|
|
|
2023-12-20 10:37:43 +08:00
|
|
|
def supportsNamespace() {
|
|
|
|
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
|
|
def major = parsed[0].toInteger()
|
|
|
|
def minor = parsed[1].toInteger()
|
|
|
|
|
|
|
|
// Namespace support was added in 7.3.0
|
|
|
|
if (major == 7 && minor >= 3) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return major >= 8
|
|
|
|
}
|
|
|
|
|
2016-03-31 16:22:47 +08:00
|
|
|
apply plugin: 'com.android.library'
|
2023-02-19 18:20:21 +08:00
|
|
|
if (isNewArchitectureEnabled()) {
|
|
|
|
apply plugin: 'com.facebook.react'
|
|
|
|
}
|
|
|
|
|
2016-03-31 16:22:47 +08:00
|
|
|
|
|
|
|
android {
|
2023-12-20 10:37:43 +08:00
|
|
|
|
|
|
|
if (supportsNamespace()) {
|
|
|
|
namespace "cn.reactnative.modules.update"
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
main {
|
|
|
|
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-30 14:26:56 +08:00
|
|
|
compileSdkVersion safeExtGet('compileSdkVersion', 28)
|
|
|
|
buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
|
2016-03-31 16:22:47 +08:00
|
|
|
|
|
|
|
defaultConfig {
|
2019-03-30 14:26:56 +08:00
|
|
|
minSdkVersion safeExtGet('minSdkVersion', 16)
|
|
|
|
targetSdkVersion safeExtGet('targetSdkVersion', 27)
|
2016-03-31 16:22:47 +08:00
|
|
|
versionCode 1
|
|
|
|
versionName "1.0"
|
2019-09-18 21:30:52 +08:00
|
|
|
consumerProguardFiles "proguard.pro"
|
2023-02-19 18:20:21 +08:00
|
|
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
2018-07-09 20:40:48 +08:00
|
|
|
}
|
|
|
|
sourceSets {
|
|
|
|
main {
|
|
|
|
// let gradle pack the shared library into apk
|
|
|
|
jniLibs.srcDirs = ['./lib']
|
2023-02-19 18:20:21 +08:00
|
|
|
if (isNewArchitectureEnabled()) {
|
|
|
|
java.srcDirs += ['src/newarch']
|
|
|
|
} else {
|
|
|
|
java.srcDirs += ['src/oldarch']
|
|
|
|
}
|
2016-03-31 22:54:29 +08:00
|
|
|
}
|
2016-03-31 16:22:47 +08:00
|
|
|
}
|
2019-10-06 21:56:58 +08:00
|
|
|
|
|
|
|
buildTypes {
|
|
|
|
release {
|
|
|
|
resValue("string", "pushy_build_time", "${minutesSinceEpoch}")
|
|
|
|
}
|
|
|
|
debug {
|
|
|
|
resValue("string", "pushy_build_time", "0")
|
|
|
|
}
|
|
|
|
}
|
2016-03-31 16:22:47 +08:00
|
|
|
}
|
|
|
|
|
2016-06-27 21:02:47 +08:00
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
2016-06-28 12:08:43 +08:00
|
|
|
url "$rootDir/../node_modules/react-native/android"
|
2016-06-27 21:02:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-31 16:22:47 +08:00
|
|
|
dependencies {
|
2019-03-30 14:26:56 +08:00
|
|
|
implementation 'com.facebook.react:react-native:+'
|
2023-03-15 23:27:25 +08:00
|
|
|
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
|
2016-03-31 16:22:47 +08:00
|
|
|
}
|
2023-02-19 18:20:21 +08:00
|
|
|
if (isNewArchitectureEnabled()) {
|
|
|
|
react {
|
|
|
|
jsRootDir = file("../lib/")
|
|
|
|
libraryName = "update"
|
|
|
|
codegenJavaPackageName = "cn.reactnative.modules.update"
|
|
|
|
}
|
|
|
|
}
|