|
| 1 | +buildscript { |
| 2 | + ext.safeExtGet = {prop, fallback -> |
| 3 | + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback |
| 4 | + } |
| 5 | + |
| 6 | + def kotlin_version = safeExtGet('kotlinVersion', '1.7.0') |
| 7 | + |
| 8 | + repositories { |
| 9 | + google() |
| 10 | + gradlePluginPortal() |
| 11 | + } |
| 12 | + dependencies { |
| 13 | + classpath("com.android.tools.build:gradle:7.2.1") |
| 14 | + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version") |
| 15 | + } |
| 16 | +} |
| 17 | + |
| 18 | +def isNewArchitectureEnabled() { |
| 19 | + return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" |
| 20 | +} |
| 21 | + |
| 22 | +apply plugin: 'com.android.library' |
| 23 | +apply plugin: 'kotlin-android' |
| 24 | + |
| 25 | +if (isNewArchitectureEnabled()) { |
| 26 | + apply plugin: "com.facebook.react" |
| 27 | +} |
| 28 | + |
| 29 | +def supportsNamespace() { |
| 30 | + def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.') |
| 31 | + def major = parsed[0].toInteger() |
| 32 | + def minor = parsed[1].toInteger() |
| 33 | + |
| 34 | + // Namespace support was added in 7.3.0 |
| 35 | + if (major == 7 && minor >= 3) { |
| 36 | + return true |
| 37 | + } |
| 38 | + |
| 39 | + return major >= 8 |
| 40 | +} |
| 41 | + |
| 42 | +android { |
| 43 | + compileSdkVersion safeExtGet('compileSdkVersion', 33) |
| 44 | + |
| 45 | + if (supportsNamespace()) { |
| 46 | + namespace "com.retyui.widgetpicker" |
| 47 | + } |
| 48 | + |
| 49 | + defaultConfig { |
| 50 | + minSdkVersion safeExtGet('minSdkVersion', 21) |
| 51 | + targetSdkVersion safeExtGet('targetSdkVersion', 33) |
| 52 | + buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() |
| 53 | + } |
| 54 | + |
| 55 | + lintOptions { |
| 56 | + disable "GradleCompatible" |
| 57 | + } |
| 58 | + |
| 59 | + buildTypes { |
| 60 | + release { |
| 61 | + minifyEnabled false |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + compileOptions { |
| 66 | + sourceCompatibility JavaVersion.VERSION_1_8 |
| 67 | + targetCompatibility JavaVersion.VERSION_1_8 |
| 68 | + } |
| 69 | + |
| 70 | + sourceSets { |
| 71 | + main { |
| 72 | + if (isNewArchitectureEnabled()) { |
| 73 | + java.srcDirs += ['src/newarch/java', "${project.buildDir}/generated/source/codegen/java"] |
| 74 | + } else { |
| 75 | + java.srcDirs += ['src/oldarch/java'] |
| 76 | + } |
| 77 | + if (!supportsNamespace()) { |
| 78 | + manifest.srcFile "src/main/AndroidManifest.xml" |
| 79 | + } |
| 80 | + } |
| 81 | + } |
| 82 | +} |
| 83 | + |
| 84 | +repositories { |
| 85 | + maven { |
| 86 | + url "$projectDir/../node_modules/react-native/android" |
| 87 | + } |
| 88 | + mavenCentral() |
| 89 | + google() |
| 90 | +} |
| 91 | + |
| 92 | +apply from: "$projectDir/react-native-helpers.gradle" |
| 93 | + |
| 94 | +def kotlin_ver = safeExtGet('kotlinVersion', '1.7.0') |
| 95 | + |
| 96 | +dependencies { |
| 97 | + if (project.ext.shouldConsumeReactNativeFromMavenCentral()) { |
| 98 | + implementation "com.facebook.react:react-android" // Set by the React Native Gradle Plugin |
| 99 | + } else { |
| 100 | + implementation 'com.facebook.react:react-native:+' // From node_modules |
| 101 | + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_ver" |
| 102 | + } |
| 103 | +} |
| 104 | + |
| 105 | +if (isNewArchitectureEnabled()) { |
| 106 | + react { |
| 107 | + jsRootDir = file("../src/") |
| 108 | + libraryName = "WidgetPicker" |
| 109 | + codegenJavaPackageName = "com.retyui.widgetpicker" |
| 110 | + } |
| 111 | +} |
0 commit comments