-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #490 from Adyen/gradle-refactor
Update build.gradle
- Loading branch information
Showing
7 changed files
with
107 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,114 @@ | ||
def safeExtGet(prop, fallback) { | ||
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback | ||
buildscript { | ||
// Buildscript is evaluated before everything else so we can't use getExtOrDefault | ||
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["ComAdyenreactnativesdkModule_kotlinVersion"] | ||
|
||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
classpath "com.android.tools.build:gradle:7.2.1" | ||
// noinspection DifferentKotlinGradleVersion | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
} | ||
} | ||
|
||
buildscript { | ||
apply from: 'dependencies.gradle' | ||
def reactNativeArchitectures() { | ||
def value = rootProject.getProperties().get("reactNativeArchitectures") | ||
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] | ||
} | ||
|
||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
def isNewArchitectureEnabled() { | ||
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true" | ||
} | ||
|
||
dependencies { | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
} | ||
apply plugin: "com.android.library" | ||
apply plugin: "kotlin-android" | ||
apply from: "jacoco.gradle" | ||
apply from: 'dependencies.gradle' | ||
|
||
if (isNewArchitectureEnabled()) { | ||
apply plugin: "com.facebook.react" | ||
} | ||
|
||
def getExtOrDefault(name) { | ||
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["ComAdyenreactnativesdkModule_" + name] | ||
} | ||
|
||
def getExtOrIntegerDefault(name) { | ||
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ComAdyenreactnativesdkModule_" + name]).toInteger() | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
apply from: 'jacoco.gradle' | ||
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 | ||
return (major == 7 && minor >= 3) || major >= 8 | ||
} | ||
|
||
android { | ||
if (supportsNamespace()) { | ||
namespace "com.adyenreactnativesdk" | ||
compileSdk safeExtGet('compileSdkVersion', 34) | ||
defaultConfig { | ||
minSdkVersion safeExtGet('minSdkVersion', 21) | ||
targetSdkVersion safeExtGet('targetSdkVersion', 34) | ||
versionCode 1 | ||
versionName "1.0" | ||
buildConfigField "String", "CHECKOUT_VERSION", "\"{SDK_VERSION}\"" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
} | ||
} | ||
lintOptions { | ||
disable 'GradleCompatible' | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
sourceSets { | ||
main { | ||
manifest.srcFile "src/main/AndroidManifestNew.xml" | ||
} | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
|
||
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion") | ||
|
||
defaultConfig { | ||
minSdkVersion getExtOrIntegerDefault("minSdkVersion") | ||
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion") | ||
buildConfigField "String", "CHECKOUT_VERSION", "\"{SDK_VERSION}\"" | ||
} | ||
|
||
buildFeatures { | ||
buildConfig true | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
} | ||
} | ||
|
||
lintOptions { | ||
disable "GradleCompatible" | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
maven { | ||
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm | ||
url("$rootDir/../node_modules/react-native/android") | ||
} | ||
google() | ||
mavenCentral() | ||
jcenter() | ||
mavenCentral() | ||
google() | ||
} | ||
|
||
def kotlin_version = getExtOrDefault("kotlinVersion") | ||
|
||
dependencies { | ||
//noinspection GradleDynamicVersion | ||
api "com.facebook.react:react-native:+" // From node_modules | ||
implementation("com.adyen.checkout:drop-in:$adyen_version") { | ||
// 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" | ||
implementation("com.adyen.checkout:drop-in:$adyen_version") { | ||
exclude group:'androidx.lifecycle' | ||
} | ||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" | ||
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version" | ||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" | ||
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version" | ||
|
||
//Tests | ||
testImplementation testLibraries.json | ||
testImplementation testLibraries.junit5 | ||
testImplementation testLibraries.mockito | ||
} | ||
//Tests | ||
testImplementation testLibraries.json | ||
testImplementation testLibraries.junit5 | ||
testImplementation testLibraries.mockito | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ComAdyenreactnativesdkModule_kotlinVersion=1.9.24 | ||
ComAdyenreactnativesdkModule_minSdkVersion=21 | ||
ComAdyenreactnativesdkModule_targetSdkVersion=34 | ||
ComAdyenreactnativesdkModule_compileSdkVersion=34 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<manifest | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application> | ||
<service android:name="com.adyenreactnativesdk.component.dropin.AdvancedCheckoutService" android:exported="false" /> | ||
<service android:name="com.adyenreactnativesdk.component.dropin.SessionCheckoutService" android:exported="false" /> | ||
</application> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters