Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
257 lines (233 loc) · 11.8 KB
/
Copy pathbuild.gradle
File metadata and controls
257 lines (233 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
def compileSdk = 37
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:${ANDROID_GRADLE_PLUGIN_VERSION}"
classpath "com.vanniktech:gradle-maven-publish-plugin:${MAVEN_PUBLISH_PLUGIN}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${KOTLIN_VERSION}"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:${DOKKA_VERSION}"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply plugin: 'com.vanniktech.maven.publish'
allprojects {
repositories {
google()
mavenCentral()
}
tasks.withType(Javadoc).all {
options.addStringOption('Xdoclint:none', '-quiet')
}
// Disabled until there's a workaround/fix for https://github.com/Kotlin/dokka/issues/2472
tasks.withType(com.android.build.gradle.tasks.JavaDocGenerationTask).all {
enabled = false
}
configurations.all {
// The POMs of com.facebook.fresco:vito reference modules that were never published to Maven
// Central, so resolution fails unless they are excluded.
exclude group: 'com.facebook.fresco', module: 'vito-core-common-impl'
exclude group: 'com.facebook.fresco', module: 'vito-core-java-impl'
exclude group: 'com.facebook.fresco', module: 'vito-native'
// These are to prevent upgrade problems where second-party dependencies like Fresco may be
// depending on a specific, older version of Litho causing dex merging conflicts.
resolutionStrategy.dependencySubstitution {
substitute module('com.facebook.litho:litho-annotations') using project(':litho-annotations')
substitute module('com.facebook.litho:litho-core') using project(':litho-core')
substitute module('com.facebook.litho:litho-widget') using project(':litho-widget')
}
}
}
subprojects {
tasks.withType(Javadoc).all {
enabled = false
}
tasks.withType(org.jetbrains.dokka.gradle.DokkaTaskPartial).configureEach {
dokkaSourceSets {
configureEach {
def module_docs_file = 'module-docs.md'
if (file(module_docs_file).exists()) {
includes.from(module_docs_file)
}
}
}
dependsOn(tasks.withType(org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask))
}
// Buck runs Robolectric tests on SDK 33, and text metrics differ on later SDKs.
['com.android.library', 'com.android.application'].each { pluginId ->
plugins.withId(pluginId) {
android.sourceSets.test.resources.srcDir("${rootDir}/gradle/robolectric")
}
}
tasks.withType(Test) {
// Robolectric needs Java 21 for the tests that ask for SDK 35+; the code itself still targets Java 17.
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(21)
}
// EquivalenceUtils reflects into JDK classes when comparing render units.
jvmArgs '--add-opens', 'java.base/java.lang=ALL-UNNAMED', '--add-opens', 'java.base/java.util=ALL-UNNAMED'
testLogging {
exceptionFormat = 'full'
showStackTraces = true
}
}
tasks.matching { it.name == 'testReleaseUnitTest' }.configureEach {
enabled = false
}
plugins.withType(org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin) {
kotlin {
jvmToolchain(17)
}
}
// Same lambda and SAM codegen as the internal build, which Redex needs and some tests assert on.
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
compilerOptions.freeCompilerArgs.addAll('-Xjvm-default=all', '-Xlambdas=class', '-Xsam-conversions=class')
}
// Internally every Kotlin target can use @DataClassGenerate; only the annotation is needed here.
plugins.withType(org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin) {
dependencies {
compileOnly deps.dataClassGenerateAnnotation
testCompileOnly deps.dataClassGenerateAnnotation
}
}
// Mirrors litho_hook_identity_decorator: Kotlin code that calls Litho hooks has to be built with
// the Litho compiler plugin, and opting in to @Hook is how a module says it is.
def withoutHookPlugin = [':yoga', ':systrace', ':range-manager']
plugins.withId('org.jetbrains.kotlin.android') {
if (path in withoutHookPlugin || name.startsWith('litho-rendercore') || name.startsWith('litho-primitive-')) {
return
}
dependencies {
kotlinCompilerPluginClasspath project(':litho-compiler-plugin')
if (path != ':litho-annotations') {
compileOnly project(':litho-annotations')
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
compilerOptions.optIn.add('com.facebook.litho.annotations.Hook')
}
}
afterEvaluate {
tasks.withType(Test) {
def offlineDepsDir = System.getProperty('robolectric.dependency.dir')
if (offlineDepsDir != null) {
systemProperty 'robolectric.dependency.dir', "${rootDir}/$offlineDepsDir"
}
}
}
}
apply plugin: 'org.jetbrains.dokka'
tasks.withType(org.jetbrains.dokka.gradle.DokkaMultiModuleTask).configureEach {
outputDirectory = file("${rootDir}/website/static/reference")
moduleName = "Litho"
}
ext {
// FB Lite, the internal app with the lowest minSdk that ships Litho, requires libraries to support 23.
minSdkVersion = 23
targetSdkVersion = 36
compileSdkVersion = compileSdk
buildToolsVersion = '35.0.0'
ndkVersion = '27.1.12297006'
sourceCompatibilityVersion = JavaVersion.VERSION_17
targetCompatibilityVersion = JavaVersion.VERSION_17
}
// Mirrors Buck friend_paths: lets a module use `internal` declarations of another module.
ext.addKotlinFriend = { Project target, String friendPath ->
target.tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { task ->
def variant = task.name.replace('compile', '').replace('UnitTest', '').replace('Kotlin', '')
task.friendPaths.from(
target.project(friendPath).layout.buildDirectory.file(
"intermediates/compile_library_classes_jar/${variant.uncapitalize()}/bundleLibCompileToJar${variant}/classes.jar"))
}
}
ext.forceReleaseBuild = project.hasProperty('forceReleaseBuild')
ext.isRelease = { forceReleaseBuild ||
['publish', 'publishToMavenLocal', 'publishToMavenCentral', 'publishAndReleaseToMavenCentral'].any { gradle.startParameter.taskNames.contains(it) } }
ext.isSnapshot = { VERSION_NAME.endsWith('-SNAPSHOT') }
ext.isDokkaBuild = getGradle().getStartParameter().getTaskNames().toString().toLowerCase().contains("dokka")
ext.deps = [
// Android support
supportAnnotations : 'androidx.annotation:annotation:1.8.1',
supportAppCompat : 'androidx.appcompat:appcompat:1.7.1',
supportCollection : 'androidx.collection:collection:1.5.0',
supportCore : 'androidx.core:core-ktx:1.16.0',
supportFragment : 'androidx.fragment:fragment:1.8.9',
supportCustomView : 'androidx.customview:customview:1.1.0',
supportRecyclerView: 'androidx.recyclerview:recyclerview:1.4.0',
supportEspresso : 'androidx.test.espresso:espresso-core:3.1.1',
supportEspressoIntents : 'androidx.test.espresso:espresso-intents:3.1.1',
supportTestCore : 'androidx.test:core:1.4.0',
supportTestRunner : 'androidx.test:runner:1.1.1',
supportTestRules : 'androidx.test:rules:1.1.1',
supportTestJunit : 'androidx.test.ext:junit:1.1.2',
supportViewPager : 'androidx.viewpager:viewpager:1.1.0',
supportViewPager2 : 'androidx.viewpager2:viewpager2:1.1.0',
supportMaterial : 'com.google.android.material:material:1.2.0',
supportTransition : 'androidx.transition:transition:1.6.0',
supportSwipeRefresh: 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0',
supportDynamicAnimations : 'androidx.dynamicanimation:dynamicanimation:1.1.0',
// lifecycle
activity : 'androidx.activity:activity:1.10.1',
lifecycle : 'androidx.lifecycle:lifecycle-runtime:2.9.4',
lifecycleCommon : 'androidx.lifecycle:lifecycle-common:2.9.4',
savedState : 'androidx.savedstate:savedstate:1.3.2',
lifecycleKtx : 'androidx.lifecycle:lifecycle-runtime-ktx:2.9.4',
viewModel : 'androidx.lifecycle:lifecycle-viewmodel:2.9.4',
liveData : 'androidx.lifecycle:lifecycle-livedata:2.9.4',
lifecycleService : 'androidx.lifecycle:lifecycle-service:2.9.4',
// First-party
fresco : 'com.facebook.fresco:fresco:3.9.0',
frescoVito : 'com.facebook.fresco:vito:3.9.0',
frescoVitoLitho : 'com.facebook.fresco:vito-litho:3.9.0',
frescoVitoOptions : 'com.facebook.fresco:vito-options:3.9.0',
frescoVitoSource : 'com.facebook.fresco:vito-source:3.9.0',
soloader : 'com.facebook.soloader:soloader:0.12.1',
textlayoutbuilder : 'com.facebook.fbui.textlayoutbuilder:textlayoutbuilder:1.7.0',
rebound : 'com.facebook.rebound:rebound:0.3.8',
screenshot : 'com.facebook.testing.screenshot:core:0.5.0',
flipper : 'com.facebook.flipper:flipper:0.258.0',
flipperLithoPlugin : 'com.facebook.flipper:flipper-litho-plugin:0.258.0',
// Annotations
dataClassGenerateAnnotation : "com.facebook.kotlin.compilerplugins.dataclassgenerate:annotation:${DATA_CLASS_GENERATE_VERSION}",
javaxInject : 'javax.inject:javax.inject:1',
jsr305 : 'com.google.code.findbugs:jsr305:3.0.1',
inferAnnotations : 'com.facebook.infer.annotation:infer-annotation:0.18.0',
// Debugging and testing
guava : 'com.google.guava:guava:33.4.0-android',
robolectric : 'org.robolectric:robolectric:4.16.1',
junit : 'junit:junit:4.13.2',
hamcrestLibrary : 'org.hamcrest:hamcrest-library:1.3',
mockitoCore : 'org.mockito:mockito-core:4.11.0',
assertjCore : 'org.assertj:assertj-core:3.27.7',
compileTesting : 'com.google.testing.compile:compile-testing:0.14',
mockitokotlin : 'org.mockito.kotlin:mockito-kotlin:4.1.0',
// Proguard annotations (published through Yoga)
proguardAnnotations: 'com.facebook.yoga:proguard-annotations:1.14.1',
// Processor
javapoet : 'com.squareup:javapoet:1.13.0',
// Misc
khronos : 'org.khronos:opengl-api:gl1.1-android-2.1_r1',
// Kotlin
kotlinStandardLib : "org.jetbrains.kotlin:kotlin-stdlib:${KOTLIN_VERSION}",
kotlinCoroutines : "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4",
kotlinCoroutinesTest : "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4",
kotlinReflect : "org.jetbrains.kotlin:kotlin-reflect:${KOTLIN_VERSION}"
]