Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build.gradle file #608

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 6 additions & 48 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,47 +24,6 @@ def isHmsEnabled() {
return (rootProject.hasProperty("airshipHmsEnabled") && rootProject.getProperty("airshipHmsEnabled") == "true") || (rootProject.ext.has("airshipHmsEnabled") && rootProject.ext.get("airshipHmsEnabled") == "true")
}

def resolveReactNativeDirectory() {
def reactNativeLocation = rootProject.hasProperty("reactNativeDir") ? rootProject.getProperty("reactNativeDir") : null

if (reactNativeLocation != null) {
return file(reactNativeLocation)
}

try {
// Resolve React Native location with Node
// This will make sure that we get installation location correctly in monorepos
def reactNativePackageJsonPathStdout = new ByteArrayOutputStream()

exec {
commandLine("node", "-p", "require.resolve('react-native/package.json')")
ignoreExitValue true
standardOutput = reactNativePackageJsonPathStdout
}

def reactNativeFromProjectNodeModules = file(reactNativePackageJsonPathStdout.toString().trim()).getParentFile();

if (reactNativeFromProjectNodeModules.exists()) {
return reactNativeFromProjectNodeModules
}
} catch (e) {
// Ignore
}

throw new Exception(
"react-native-airship: Failed to resolve 'react-native' in the project. " +
"If you have a non-standard project structure, you can specify 'reactNativeDir' with the path to 'react-native' in your 'gradle.properties' file."
)
}


def reactNativeRootDir = resolveReactNativeDirectory()
def reactProperties = new Properties()
file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }

def reactNativeVersion = reactProperties.getProperty("VERSION_NAME")
def (reactNativeMajorVersion, reactNativeMinorVersion) = reactNativeVersion.split("\\.").collect { it.isInteger() ? it.toInteger() : it }


apply plugin: "com.android.library"
apply plugin: "kotlin-android"
Expand All @@ -81,6 +40,7 @@ def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Airship_" + name]).toInteger()
}


android {
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

Expand Down Expand Up @@ -142,14 +102,12 @@ def proxy_version = getExtOrDefault("airshipProxyVersion")
def airship_version = getExtOrDefault("airshipVersion")

dependencies {
if (reactNativeMajorVersion == 0 && reactNativeMinorVersion < 71) {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
} else {
implementation "com.facebook.react:react-android"
}

// For < 0.71, this will be from the local maven repo
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

api "com.urbanairship.android:airship-framework-proxy:$proxy_version"

if (isHmsEnabled()) {
Expand Down
Loading