Skip to content

Commit 27d8eba

Browse files
committed
Make use of convention plugins and version catalogs
1 parent 42c58af commit 27d8eba

File tree

32 files changed

+446
-1260
lines changed

32 files changed

+446
-1260
lines changed

android/build.gradle

+10-182
Original file line numberDiff line numberDiff line change
@@ -13,186 +13,14 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import net.ltgt.gradle.errorprone.CheckSeverity
17-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
18-
19-
20-
21-
buildscript {
22-
apply from: rootProject.file('gradle/dependencies.gradle')
23-
repositories {
24-
google()
25-
mavenCentral()
26-
gradlePluginPortal()
27-
}
28-
dependencies {
29-
classpath deps.build.gradlePlugins.android
30-
classpath deps.build.gradlePlugins.errorprone
31-
classpath deps.build.gradlePlugins.kotlin
32-
classpath deps.build.gradlePlugins.spotless
33-
classpath deps.build.gradlePlugins.gradleMavenPublish
34-
}
16+
plugins {
17+
alias(libs.plugins.androidApplication) apply false
18+
alias(libs.plugins.androidLibrary) apply false
19+
alias(libs.plugins.kotlinAndroid) apply false
20+
alias(libs.plugins.kotlinKapt) apply false
21+
alias(libs.plugins.mavenPublish) apply false
22+
alias(libs.plugins.errorprone) apply false
23+
alias(libs.plugins.nullaway) apply false
24+
alias(libs.plugins.intellij) apply false
25+
alias(libs.plugins.spotless) apply false
3526
}
36-
37-
Set<String> useErrorProneProjects = [
38-
"memory-leaks",
39-
"tutorial1",
40-
"tutorial2"
41-
]
42-
43-
def moduleFriends = [
44-
'rib-android': 'rib-base',
45-
'rib-debug-utils': 'rib-base',
46-
'rib-router-navigator': 'rib-base',
47-
'rib-test': 'rib-base',
48-
'rib-workflow-test': 'rib-workflow',
49-
'rib-coroutines-test': 'rib-coroutines'
50-
]
51-
52-
subprojects {
53-
buildscript {
54-
repositories {
55-
google()
56-
mavenCentral()
57-
gradlePluginPortal()
58-
}
59-
}
60-
61-
repositories {
62-
google()
63-
mavenCentral()
64-
}
65-
66-
apply plugin: 'com.diffplug.spotless'
67-
spotless {
68-
format 'misc', {
69-
target '**/*.md', '**/.gitignore'
70-
71-
trimTrailingWhitespace()
72-
endWithNewline()
73-
}
74-
kotlin {
75-
target "**/*.kt"
76-
ktlint(deps.versions.ktlint).editorConfigOverride(['indent_size': '2', 'continuation_indent_size' : '4'])
77-
ktfmt(deps.versions.ktfmt).googleStyle()
78-
licenseHeaderFile rootProject.file('config/spotless/copyright.kt')
79-
trimTrailingWhitespace()
80-
endWithNewline()
81-
}
82-
java {
83-
target "src/*/java/**/*.java"
84-
googleJavaFormat(deps.versions.gjf)
85-
licenseHeaderFile rootProject.file('config/spotless/copyright.java')
86-
removeUnusedImports()
87-
trimTrailingWhitespace()
88-
endWithNewline()
89-
}
90-
groovyGradle {
91-
target '**/*.gradle'
92-
trimTrailingWhitespace()
93-
endWithNewline()
94-
}
95-
}
96-
97-
afterEvaluate {
98-
boolean isAndroidApp = project.plugins.hasPlugin("com.android.application")
99-
boolean isAndroidLibrary = project.plugins.hasPlugin("com.android.library")
100-
boolean isIntelliJPlugin = project.plugins.hasPlugin("com.android.library")
101-
boolean usesErrorProne = project.name in useErrorProneProjects
102-
boolean isKotlinLibrary = project.plugins.hasPlugin("org.jetbrains.kotlin.jvm") || project.plugins.hasPlugin("org.jetbrains.kotlin.android")
103-
104-
if ((isAndroidLibrary || isAndroidApp) && usesErrorProne) {
105-
def configurer = { variant ->
106-
variant.getJavaCompileProvider().configure {
107-
options.errorprone.nullaway {
108-
severity = CheckSeverity.ERROR
109-
annotatedPackages.add("com.uber")
110-
}
111-
options.errorprone.excludedPaths = ".*/build/generated/.*"
112-
}
113-
}
114-
if (isAndroidLibrary) {
115-
project.android.libraryVariants.configureEach(configurer)
116-
}
117-
if (isAndroidApp) {
118-
project.android.applicationVariants.configureEach(configurer)
119-
}
120-
project.android.testVariants.configureEach(configurer)
121-
project.android.unitTestVariants.configureEach(configurer)
122-
}
123-
if (isAndroidLibrary || isAndroidApp) {
124-
// TODO replace with https://issuetracker.google.com/issues/72050365 once released.
125-
project.android {
126-
if (isAndroidLibrary) {
127-
variantFilter { variant ->
128-
if (variant.buildType.name == 'debug') {
129-
variant.setIgnore(true)
130-
}
131-
}
132-
}
133-
if (isAndroidApp) {
134-
buildTypes {
135-
debug {
136-
matchingFallbacks = ['release']
137-
}
138-
}
139-
variantFilter { variant ->
140-
if (variant.buildType.name == "release") {
141-
variant.setIgnore(true)
142-
}
143-
}
144-
}
145-
}
146-
}
147-
148-
if (isKotlinLibrary) {
149-
def extraCompilerArgs = [
150-
// See https://github.com/bazelbuild/bazel/issues/15144
151-
"-Xjvm-default=enable",
152-
"-opt-in=kotlin.RequiresOptIn",
153-
]
154-
if (project.name in moduleFriends.keySet()) {
155-
def friendName = moduleFriends[project.name]
156-
def friendProject = rootProject.subprojects.stream().filter { it.name == friendName }.findFirst().get()
157-
def outputJarPath = friendProject.plugins.hasPlugin("com.android.library")
158-
? "build/intermediates/compile_library_classes_jar/release/classes.jar"
159-
: "build/libs/$friendName-${project.property('VERSION_NAME')}.jar"
160-
def friendPath="${project.rootDir}/libraries/${moduleFriends[project.name]}/$outputJarPath"
161-
extraCompilerArgs.add("-Xfriend-paths=$friendPath")
162-
}
163-
if (isAndroidLibrary || isAndroidApp) {
164-
project.android.sourceSets {
165-
main.java.srcDirs += 'src/main/kotlin'
166-
test.java.srcDirs += 'src/test/kotlin'
167-
androidTest.java.srcDirs += 'src/androidTest/kotlin'
168-
}
169-
170-
tasks.withType(KotlinCompile).configureEach {
171-
kotlinOptions {
172-
freeCompilerArgs = extraCompilerArgs
173-
jvmTarget = "11"
174-
}
175-
}
176-
} else if(!isIntelliJPlugin) {
177-
project.compileKotlin {
178-
kotlinOptions {
179-
freeCompilerArgs = extraCompilerArgs
180-
jvmTarget = "11"
181-
}
182-
}
183-
project.compileTestKotlin {
184-
kotlinOptions {
185-
freeCompilerArgs = extraCompilerArgs
186-
jvmTarget = "11"
187-
}
188-
}
189-
}
190-
}
191-
}
192-
}
193-
194-
tasks.register('clean', Delete) {
195-
delete rootProject.buildDir
196-
}
197-
198-
apply from: rootProject.file('gradle/japicmp.gradle')

android/demos/compose/build.gradle

+27-46
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,44 @@
1-
apply plugin: 'com.android.application'
2-
apply plugin: 'org.jetbrains.kotlin.android'
3-
apply plugin: "org.jetbrains.kotlin.kapt"
4-
5-
kotlin {
6-
jvmToolchain(11)
1+
plugins {
2+
id("ribs.kotlin-android-application-conventions")
3+
alias(libs.plugins.kotlinKapt)
74
}
85

96
android {
107
namespace "com.uber.rib.compose"
11-
compileSdk deps.build.compileSdkVersion
128

139
defaultConfig {
14-
minSdk deps.build.minSdkVersion
15-
targetSdk deps.build.targetSdkVersion
1610
applicationId "com.uber.rib.compose"
17-
versionCode 1
18-
versionName "1.0"
1911
}
2012
buildFeatures {
2113
compose true
2214
}
2315
composeOptions {
24-
kotlinCompilerExtensionVersion deps.versions.androidx.compose.compiler
25-
}
26-
compileOptions {
27-
sourceCompatibility deps.build.javaVersion
28-
targetCompatibility deps.build.javaVersion
29-
}
30-
31-
// No need for lint. This is just a tutorial.
32-
lint {
33-
abortOnError false
34-
quiet true
16+
kotlinCompilerExtensionVersion libs.versions.compose.compiler.get()
3517
}
3618
}
3719

3820
dependencies {
39-
kapt deps.uber.motifCompiler
40-
implementation project(":libraries:rib-android")
41-
implementation project(":libraries:rib-android-compose")
42-
implementation project(":libraries:rib-coroutines")
43-
implementation deps.androidx.activityCompose
44-
implementation deps.androidx.annotations
45-
implementation deps.androidx.appcompat
46-
implementation deps.androidx.composeAnimation
47-
implementation deps.androidx.composeFoundation
48-
implementation deps.androidx.composeMaterial
49-
implementation deps.androidx.composeNavigation
50-
implementation deps.androidx.composeRuntimeRxJava2
51-
implementation deps.androidx.composeUi
52-
implementation deps.androidx.composeViewModel
53-
implementation deps.androidx.composeUiTooling
54-
implementation deps.androidx.savedState
55-
implementation deps.external.rxandroid2
56-
implementation deps.kotlin.coroutines
57-
implementation deps.kotlin.coroutinesAndroid
58-
implementation deps.kotlin.coroutinesRx2
59-
implementation deps.uber.autodisposeCoroutines
60-
implementation deps.uber.motif
21+
kapt(libs.motif.compiler)
22+
implementation(project(":libraries:rib-android"))
23+
implementation(project(":libraries:rib-android-compose"))
24+
implementation(project(":libraries:rib-coroutines"))
25+
implementation(libs.annotation)
26+
implementation(libs.appcompat)
27+
implementation(libs.activity.compose)
28+
implementation(libs.compose.animation)
29+
implementation(libs.compose.foundation)
30+
implementation(libs.compose.material)
31+
implementation(libs.compose.navigation)
32+
implementation(libs.compose.runtime.rx2)
33+
implementation(libs.compose.ui)
34+
implementation(libs.compose.viewmodel)
35+
implementation(libs.compose.uitooling)
36+
implementation(libs.savedstate)
37+
implementation(libs.rxandroid2)
38+
implementation(libs.coroutines.android)
39+
implementation(libs.coroutines.rx2)
40+
implementation(libs.autodispose.coroutines)
41+
implementation(libs.motif.library)
6142

6243

6344
// Flipper Debug tool integration
@@ -66,7 +47,7 @@ dependencies {
6647
releaseImplementation 'com.facebook.flipper:flipper-noop:0.93.0'
6748

6849
// Flipper RIBs plugin
69-
implementation project(":tooling:rib-flipper-plugin")
50+
implementation(project(":tooling:rib-flipper-plugin"))
7051

71-
testImplementation deps.test.junit
52+
testImplementation(testLibs.junit)
7253
}

android/demos/flipper/build.gradle

+13-39
Original file line numberDiff line numberDiff line change
@@ -13,61 +13,35 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
17-
buildscript {
18-
dependencies {
19-
classpath deps.build.gradlePlugins.android
20-
}
21-
}
22-
23-
apply plugin: 'com.android.application'
24-
25-
java {
26-
toolchain {
27-
languageVersion.set(JavaLanguageVersion.of(11))
28-
}
16+
plugins {
17+
id("ribs.kotlin-android-application-conventions")
18+
alias(libs.plugins.kotlinKapt)
2919
}
3020

3121
android {
3222
namespace "com.uber.rib.flipper"
33-
compileSdk deps.build.compileSdkVersion
3423

3524
defaultConfig {
36-
minSdk deps.build.minSdkVersion
37-
targetSdk deps.build.targetSdkVersion
3825
applicationId "com.uber.rib.flipper"
39-
versionCode 1
40-
versionName "1.0"
41-
}
42-
43-
// No need for lint. This is just a demo.
44-
lint {
45-
abortOnError false
46-
quiet true
47-
}
48-
49-
compileOptions {
50-
sourceCompatibility deps.build.javaVersion
51-
targetCompatibility deps.build.javaVersion
5226
}
5327
}
5428

5529
dependencies {
56-
annotationProcessor deps.apt.daggerCompiler
57-
annotationProcessor project(":libraries:rib-compiler-test")
58-
implementation project(":libraries:rib-android")
59-
implementation deps.androidx.appcompat
60-
implementation deps.external.dagger
61-
implementation deps.external.rxbinding
62-
implementation deps.androidx.percent
63-
compileOnly deps.apt.javax
64-
testImplementation project(":libraries:rib-test")
30+
kapt(libs.dagger.compiler)
31+
kapt(project(":libraries:rib-compiler-test"))
32+
implementation(project(":libraries:rib-android"))
33+
implementation(libs.appcompat)
34+
implementation(libs.dagger.library)
35+
implementation(libs.rxbinding)
36+
implementation(libs.percent)
37+
compileOnly(libs.jsr250)
38+
testImplementation(project(":libraries:rib-test"))
6539

6640
// Flipper Debug tool integration
6741
debugImplementation 'com.facebook.flipper:flipper:0.93.0'
6842
debugImplementation 'com.facebook.soloader:soloader:0.10.1'
6943
releaseImplementation 'com.facebook.flipper:flipper-noop:0.93.0'
7044

7145
// Flipper RIBs plugin
72-
implementation project(":tooling:rib-flipper-plugin")
46+
implementation(project(":tooling:rib-flipper-plugin"))
7347
}

0 commit comments

Comments
 (0)