xref: /expo/android/build.gradle (revision 4c2e121c)
1// Top-level build file where you can add configuration options common to all sub-projects/modules.
2
3buildscript {
4  ext {
5    minSdkVersion = 21
6    targetSdkVersion = 30
7    compileSdkVersion = 30
8
9    dbFlowVersion = '4.2.4'
10    buildToolsVersion = '30.0.5'
11    supportLibVersion = '29.0.0'
12    kotlinVersion = '1.6.10'
13    gradlePluginVersion = '4.1.2'
14    gradleDownloadTaskVersion = '3.4.3'
15    repositoryUrl = "file:${System.env.HOME}/.m2/repository/"
16  }
17  repositories {
18    google()
19    mavenCentral()
20    jcenter()
21  }
22  dependencies {
23    classpath "com.android.tools.build:gradle:${gradlePluginVersion}"
24    classpath 'com.google.gms:google-services:4.3.5'
25    classpath "de.undercouch:gradle-download-task:$gradleDownloadTaskVersion"
26    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
27  }
28}
29
30// WHEN_DISTRIBUTING_REMOVE_FROM_HERE
31// We don't need linter on turtle.
32plugins {
33  id "com.diffplug.spotless" version "5.14.1"
34}
35// WHEN_DISTRIBUTING_REMOVE_TO_HERE
36
37allprojects {
38  repositories {
39    // For non-detach
40    maven {
41      url "$rootDir/maven"
42    }
43    // For old expoviews to work
44    maven {
45      url "$rootDir/versioned-abis/expoview-abi44_0_0/maven"
46    }
47    maven {
48      url "$rootDir/versioned-abis/expoview-abi43_0_0/maven"
49    }
50    maven {
51      url "$rootDir/versioned-abis/expoview-abi42_0_0/maven"
52    }
53    maven {
54      url "$rootDir/versioned-abis/expoview-abi41_0_0/maven"
55    }
56    maven {
57      url "$rootDir/versioned-abis/maven"
58    }
59    google()
60    mavenCentral()
61    jcenter()
62    maven {
63      // Local Maven repo containing AARs with JSC built for Android
64      url "$rootDir/../node_modules/jsc-android/dist"
65    }
66    maven {
67      // Local expo-camera Maven repo containing our slightly modified
68      // Google's cameraview from expo/cameraview.
69      url "$rootDir/../packages/expo-camera/android/maven"
70    }
71    flatDir {
72      dirs 'libs'
73      // dirs project(':expoview').file('libs')
74    }
75    // Using www.jitpack.io instead of plain jitpack.io due to
76    // https://github.com/jitpack/jitpack.io/issues/4002
77    maven { url "https://www.jitpack.io" }
78
79    // Want this last so that we never end up with a stale cache
80    mavenLocal()
81  }
82
83  configurations.all {
84    // WHEN_DISTRIBUTING_REMOVE_FROM_HERE
85    resolutionStrategy.dependencySubstitution {
86      substitute module("com.facebook.react:react-native:+") with project(":ReactAndroid")
87
88      // Gradle needs another hint (apart from plain dependency substitution)
89      // to know that it should first evaluate the replacing project before resolving
90      // classpaths etc. Without this block an error is thrown when running tests
91      // in a project that depends on react-native (eg. expo-updates):
92      //   > No matching configuration of project :ReactAndroid was found.
93      //   > The consumer was configured to find a runtime of a component,
94      //   > as well as attribute 'com.android.build.api.attributes.BuildTypeAttr'
95      //   > with value 'debug' but:
96      //   >   - None of the consumable configurations have attributes.
97      all {
98        if (requested.displayName == "com.facebook.react:react-native:+") {
99          evaluationDependsOn(":ReactAndroid")
100        }
101      }
102    }
103    // WHEN_DISTRIBUTING_REMOVE_TO_HERE
104  }
105}
106
107// This var needs to be defined outside any "remove_from_here" comment blocks
108// because the "*/" in there could affect the resulted code by closing the comment to early.
109def ktlintTarget = '**/*.kt'
110
111// WHEN_DISTRIBUTING_REMOVE_FROM_HERE
112// We don't need linter on turtle.
113subprojects {
114  plugins.apply("com.diffplug.spotless")
115  spotless {
116    format 'gradle', {
117      target '*.gradle'
118      trimTrailingWhitespace()
119      indentWithSpaces()
120      endWithNewline()
121    }
122    kotlin {
123      target(ktlintTarget)
124      ktlint("0.41.0").userData([
125        "disabled_rules"           : "no-wildcard-imports,import-ordering",
126        "charset"                  : "utf-8",
127        "end_of_line"              : "lf",
128        "indent_size"              : "2",
129        "indent_style"             : "space",
130        "insert_final_newline"     : "true",
131        "tab_width"                : "2",
132        "trim_trailing_whitespace" : "true"
133      ])
134      trimTrailingWhitespace()
135      indentWithSpaces()
136      endWithNewline()
137    }
138  }
139}
140// WHEN_DISTRIBUTING_REMOVE_TO_HERE
141