1// Top-level build file where you can add configuration options common to all sub-projects/modules. 2import com.android.build.api.variant.AndroidComponentsExtension 3 4buildscript { 5 ext { 6 minSdkVersion = 21 7 targetSdkVersion = 33 8 compileSdkVersion = 33 9 10 dbFlowVersion = '4.2.4' 11 buildToolsVersion = '33.0.0' 12 kotlinVersion = '1.8.10' 13 gradlePluginVersion = '7.4.1' 14 gradleDownloadTaskVersion = '5.0.1' 15 repositoryUrl = "file:${System.env.HOME}/.m2/repository/" 16 17 // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP. 18 ndkVersion = "23.1.7779620" 19 } 20 repositories { 21 google() 22 mavenCentral() 23 } 24 dependencies { 25 classpath "com.android.tools.build:gradle:${gradlePluginVersion}" 26 classpath 'com.google.gms:google-services:4.3.5' 27 classpath "de.undercouch:gradle-download-task:$gradleDownloadTaskVersion" 28 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" 29 30 // WHEN_DISTRIBUTING_REMOVE_FROM_HERE 31 classpath "com.facebook.react:react-native-gradle-plugin" 32 // WHEN_DISTRIBUTING_REMOVE_TO_HERE 33 } 34} 35 36// WHEN_DISTRIBUTING_REMOVE_FROM_HERE 37// We don't need linter on turtle. 38plugins { 39 id "com.diffplug.spotless" version "5.14.1" 40} 41// WHEN_DISTRIBUTING_REMOVE_TO_HERE 42 43allprojects { 44 repositories { 45 // For non-detach 46 maven { 47 url "$rootDir/maven" 48 } 49 // For old expoviews to work 50 maven { 51 url "$rootDir/versioned-abis/expoview-abi48_0_0/maven" 52 } 53 maven { 54 url "$rootDir/versioned-abis/expoview-abi47_0_0/maven" 55 } 56 maven { 57 url "$rootDir/versioned-abis/expoview-abi46_0_0/maven" 58 } 59 maven { 60 url "$rootDir/versioned-abis/maven" 61 } 62 google() 63 mavenCentral { 64 // We don't want to fetch react-native from Maven Central as there are 65 // older versions over there. 66 content { 67 excludeGroup "com.facebook.react" 68 } 69 } 70 maven { 71 // Local Maven repo containing AARs with JSC built for Android 72 url "$rootDir/../node_modules/jsc-android/dist" 73 } 74 maven { 75 // Local expo-camera Maven repo containing our slightly modified 76 // Google's cameraview from expo/cameraview. 77 url "$rootDir/../packages/expo-camera/android/maven" 78 } 79 flatDir { 80 dirs 'libs' 81 // dirs project(':expoview').file('libs') 82 } 83 maven { url "https://jitpack.io" } 84 85 // Want this last so that we never end up with a stale cache 86 mavenLocal() 87 } 88 89 configurations.all { 90 // WHEN_DISTRIBUTING_REMOVE_FROM_HERE 91 resolutionStrategy.dependencySubstitution { 92 substitute(module("com.facebook.react:react-native")) 93 .using(project(":ReactAndroid")) 94 .because("Building React Native from source") 95 substitute(module("com.facebook.react:react-native:+")) 96 .using(project(":ReactAndroid")) 97 .because("Building React Native from source") 98 substitute(module("com.facebook.react:react-android")) 99 .using(project(":ReactAndroid")) 100 .because("Building React Native from source") 101 } 102 // WHEN_DISTRIBUTING_REMOVE_TO_HERE 103 } 104} 105 106// to prevent duplicated lib error, pick first of libc++_shared.so and libfbjni.so for instrumented tests 107allprojects { subProject -> 108 subProject.afterEvaluate { 109 def androidComponents = subProject.extensions.findByType(AndroidComponentsExtension.class) 110 androidComponents?.with { 111 onVariants(selector().all()) { 112 getAndroidTest()?.packaging?.jniLibs?.pickFirsts?.addAll([ 113 "**/libc++_shared.so", 114 "**/libfbjni.so", 115 ]) 116 } 117 } 118 } 119} 120 121// This var needs to be defined outside any "remove_from_here" comment blocks 122// because the "*/" in there could affect the resulted code by closing the comment to early. 123def ktlintTarget = '**/*.kt' 124 125// WHEN_DISTRIBUTING_REMOVE_FROM_HERE 126// We don't need linter on turtle. 127subprojects { project -> 128 if (project.name == "ReactAndroid") { return; } 129 if (project.name.startsWith("vendored_")) { return; } 130 131 plugins.apply("com.diffplug.spotless") 132 spotless { 133 format 'gradle', { 134 target '*.gradle' 135 trimTrailingWhitespace() 136 indentWithSpaces() 137 endWithNewline() 138 } 139 kotlin { 140 target(ktlintTarget) 141 // TODO: (barthap) Replace this with raw string when dropped shell app macros 142 // The star "*" signs interferes with slash "/" and treated wildcard path as comment ¯\_(ツ)_/¯ 143 targetExclude(["**", "versioned/host/exp/exponent/modules/api", "**", "*.kt"].join("/")) 144 ktlint("0.41.0").userData([ 145 "disabled_rules" : "no-wildcard-imports,import-ordering", 146 "charset" : "utf-8", 147 "end_of_line" : "lf", 148 "indent_size" : "2", 149 "indent_style" : "space", 150 "insert_final_newline" : "true", 151 "tab_width" : "2", 152 "trim_trailing_whitespace" : "true" 153 ]) 154 trimTrailingWhitespace() 155 indentWithSpaces() 156 endWithNewline() 157 } 158 } 159} 160// WHEN_DISTRIBUTING_REMOVE_TO_HERE 161