UNPKG

4.23 kBPlain TextView Raw
1buildscript {
2 // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3 def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['AppconsentClearReactnative_kotlinVersion']
4
5 repositories {
6 google()
7 mavenCentral()
8 jcenter()
9 maven {
10 url "https://artifactory.datalf.chat/artifactory/app-consent-v2-release"
11 }
12 }
13
14 dependencies {
15 classpath("com.android.tools.build:gradle:7.4.2")
16 // noinspection DifferentKotlinGradleVersion
17 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
18 }
19}
20
21apply plugin: 'com.android.library'
22apply plugin: 'kotlin-android'
23
24def getExtOrDefault(name) {
25 return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['AppconsentClearReactnative_' + name]
26}
27
28def getExtOrIntegerDefault(name) {
29 return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['AppconsentClearReactnative_' + name]).toInteger()
30}
31
32android {
33 defaultConfig {
34 namespace = "com.appconsentclearreactnative"
35 compileSdkVersion = getExtOrIntegerDefault('compileSdkVersion')
36 minSdkVersion = getExtOrIntegerDefault('minSdkVersion')
37 targetSdkVersion = getExtOrIntegerDefault('targetSdkVersion')
38 versionCode = 11
39 versionName = "2.1.7"
40 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
41 }
42
43 buildTypes {
44 release {
45 minifyEnabled = false
46 }
47 }
48 lintOptions {
49 disable 'GradleCompatible'
50 }
51 compileOptions {
52 sourceCompatibility = JavaVersion.VERSION_1_8
53 targetCompatibility = JavaVersion.VERSION_1_8
54 }
55 kotlinOptions {
56 jvmTarget = JavaVersion.VERSION_1_8.toString()
57 }
58 packagingOptions {
59 resources {
60 excludes += ['META-INF/DEPENDENCIES','META-INF/jacoco-agent.properties','jacoco-agent.properties']
61 }
62 }
63 testOptions {
64 unitTests {
65 returnDefaultValues = true
66 includeAndroidResources = true
67 }
68 }
69}
70
71repositories {
72 mavenCentral()
73 jcenter()
74 google()
75
76 maven {
77 url "https://artifactory.datalf.chat/artifactory/app-consent-v2-release"
78 }
79
80
81 def found = false
82 def defaultDir = null
83 def androidSourcesName = 'React Native sources'
84
85 if (rootProject.ext.has('reactNativeAndroidRoot')) {
86 defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
87 } else {
88 defaultDir = new File(
89 projectDir,
90 '/../../../node_modules/react-native/android'
91 )
92 }
93
94 if (defaultDir.exists()) {
95 maven {
96 url defaultDir.toString()
97 name androidSourcesName
98 }
99
100 logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
101 found = true
102 } else {
103 def parentDir = rootProject.projectDir
104
105 1.upto(5, {
106 if (found) return true
107 parentDir = parentDir.parentFile
108
109 def androidSourcesDir = new File(
110 parentDir,
111 'node_modules/react-native'
112 )
113
114 def androidPrebuiltBinaryDir = new File(
115 parentDir,
116 'node_modules/react-native/android'
117 )
118
119 if (androidPrebuiltBinaryDir.exists()) {
120 maven {
121 url androidPrebuiltBinaryDir.toString()
122 name androidSourcesName
123 }
124
125 logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
126 found = true
127 } else if (androidSourcesDir.exists()) {
128 maven {
129 url androidSourcesDir.toString()
130 name androidSourcesName
131 }
132
133 logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
134 found = true
135 }
136 })
137 }
138
139 if (!found) {
140 throw new GradleException(
141 "${project.name}: unable to locate React Native android sources. " +
142 "Ensure you have you installed React Native as a dependency in your project and try again."
143 )
144 }
145}
146
147def kotlin_version = getExtOrDefault('kotlinVersion')
148
149dependencies {
150 // noinspection GradleDynamicVersion
151 api 'com.facebook.react:react-native:+'
152 implementation ('com.sfbx.appconsent:appconsent-ui-v3:5.1.4')
153
154 testImplementation("junit:junit:4.13.2")
155 testImplementation("io.mockk:mockk:1.13.5")
156}