Skip to content

Commit

Permalink
Housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
psteiger committed Oct 14, 2024
1 parent a7cdef5 commit c959ea2
Show file tree
Hide file tree
Showing 175 changed files with 875 additions and 1,212 deletions.
6 changes: 4 additions & 2 deletions android/build.gradle → android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
plugins {
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.androidLibrary) apply false
alias(libs.plugins.kotlinAndroid) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.symbol.processor) apply false
alias(libs.plugins.kotlinKapt) apply false
alias(libs.plugins.mavenPublish) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.maven.publish) apply false
alias(libs.plugins.errorprone) apply false
alias(libs.plugins.nullaway) apply false
alias(libs.plugins.intellij) apply false
Expand Down
4 changes: 2 additions & 2 deletions android/conventions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
plugins {
`kotlin-dsl`
`kotlin-dsl-precompiled-script-plugins`
alias(libs.plugins.spotless)
}

repositories {
Expand All @@ -27,7 +27,7 @@ repositories {
dependencies {
// Workaround for using version catalog on precompiled scripts.
// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
implementation(files((libs as Any).javaClass.superclass.protectionDomain.codeSource.location))
implementation(gradleApi())
implementation(libs.gradle.android.plugin)
implementation(libs.gradle.kotlin.plugin)
Expand Down
23 changes: 7 additions & 16 deletions android/conventions/src/main/kotlin/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,25 @@
* limitations under the License.
*/
import com.android.build.gradle.AbstractAppExtension
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.TestedExtension
import com.android.build.gradle.api.BaseVariant
import net.ltgt.gradle.errorprone.CheckSeverity
import net.ltgt.gradle.errorprone.errorprone
import net.ltgt.gradle.nullaway.nullaway

fun AbstractAppExtension.errorprone() {
applicationVariants.configureEach { errorprone() }
testErrorprone()
}

fun LibraryExtension.errorprone() {
libraryVariants.configureEach { errorprone() }
testErrorprone()
}

fun TestedExtension.testErrorprone() {
testVariants.configureEach { errorprone() }
unitTestVariants.configureEach { errorprone() }
}

fun BaseVariant.errorprone() {
private fun BaseVariant.errorprone() {
javaCompileProvider.configure {
options.errorprone.nullaway {
severity.set(CheckSeverity.ERROR)
annotatedPackages.add("com.uber")
options.errorprone {
nullaway {
severity.set(CheckSeverity.ERROR)
annotatedPackages.add("com.uber")
}
excludedPaths.set(".*/build/generated/.*")
}
options.errorprone.excludedPaths.set(".*/build/generated/.*")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,36 @@ plugins {
}

kotlin {
jvmToolchain(11)
jvmToolchain(17)
}

android {
compileSdk = 33

compileSdk = 34
defaultConfig {
minSdk = 21
targetSdk = 28
targetSdk = 34
versionCode = 1
versionName = "1.0"
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
buildFeatures {
buildConfig = true
}

// No need for lint. Those are just tutorials.
lint {
abortOnError = false
quiet = true
}

buildTypes {
debug {
matchingFallbacks.add("release")
}
}

sourceSets {
getByName("main").java.srcDir("src/main/kotlin")
getByName("test").java.srcDir("src/test/kotlin")
getByName("androidTest").java.srcDir("src/androidTest/kotlin")
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@ dependencies {
kapt(libs.uber.nullaway)
errorprone(libs.errorprone.core)
errorprone(libs.guava.jre)
errorproneJavac(libs.errorprone.javac)
errorprone(libs.uber.nullaway)
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,27 @@ plugins {
}

kotlin {
jvmToolchain(8)
jvmToolchain(17)
}

android {
compileSdk = 33
compileSdk = 34

defaultConfig {
minSdk = 21
}

// This can be removed on AGP 8.1.0-alpha09 onwards, since we are using JVM Toolchain
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

buildFeatures {
buildConfig = false
kotlinOptions {
jvmTarget = "11"
}

sourceSets {
getByName("main").java.srcDir("src/main/kotlin")
getByName("test").java.srcDir("src/test/kotlin")
getByName("androidTest").java.srcDir("src/androidTest/kotlin")
buildFeatures {
buildConfig = false
}

testOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.jvm.JvmTargetValidationMode
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

plugins {
kotlin("jvm")
id("ribs.spotless-convention")
}

kotlin {
jvmToolchain(8)
explicitApi()
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

tasks.named("compileKotlin", org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask::class.java) {
kotlin {
jvmToolchain(17)
explicitApi()
compilerOptions {
freeCompilerArgs.add("-Xjvm-default=all")
freeCompilerArgs.addAll("-Xjvm-default=all")
jvmTarget = JvmTarget.JVM_11
}
}

tasks.withType<KotlinJvmCompile>().configureEach {
jvmTargetValidationMode = JvmTargetValidationMode.WARNING
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ plugins {

val libs = the<org.gradle.accessors.dm.LibrariesForLibs>()

configure<com.diffplug.gradle.spotless.SpotlessExtension> {
spotless {
format("misc") {
target("**/*.md", "**/.gitignore")
trimTrailingWhitespace()
Expand All @@ -31,6 +31,7 @@ configure<com.diffplug.gradle.spotless.SpotlessExtension> {
mapOf(
"indent_size" to "2",
"continuation_indent_size" to "4",
"ktlint_function_naming_ignore_when_annotated_with" to "Composable",
)
)
ktfmt(libs.versions.ktfmt.get()).googleStyle()
Expand All @@ -40,7 +41,7 @@ configure<com.diffplug.gradle.spotless.SpotlessExtension> {
}
java {
target("src/*/java/**/*.java")
googleJavaFormat(libs.versions.gjf.get())
googleJavaFormat(libs.versions.google.java.format.get())
licenseHeaderFile(rootProject.file("config/spotless/copyright.java"))
removeUnusedImports()
trimTrailingWhitespace()
Expand Down
18 changes: 10 additions & 8 deletions android/demos/compose/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("ribs.kotlin-android-application-conventions")
alias(libs.plugins.kotlinKapt)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.kotlin.symbol.processor)
}

android {
Expand All @@ -12,13 +13,14 @@ android {
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion libs.versions.compose.compiler.get()
}
}

dependencies {
kapt(libs.motif.compiler)
def composeBom = platform(libs.compose.bom)
implementation(composeBom)
androidTestImplementation(composeBom)

ksp(libs.motif.compiler)
implementation(project(":libraries:rib-android"))
implementation(project(":libraries:rib-android-compose"))
implementation(project(":libraries:rib-coroutines"))
Expand All @@ -42,9 +44,9 @@ dependencies {


// Flipper Debug tool integration
debugImplementation 'com.facebook.flipper:flipper:0.93.0'
debugImplementation 'com.facebook.soloader:soloader:0.10.1'
releaseImplementation 'com.facebook.flipper:flipper-noop:0.93.0'
debugImplementation libs.flipper
debugImplementation libs.soloader
releaseImplementation libs.flipper.noop

// Flipper RIBs plugin
implementation(project(":tooling:rib-flipper-plugin"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ import motif.ScopeFactory

class RootActivity : RibActivity() {

override fun createRouter(parentViewGroup: ViewGroup): ViewRouter<*, *> {
return ScopeFactory.create(Parent::class.java)
override fun createRouter(parentViewGroup: ViewGroup): ViewRouter<*, *> =
ScopeFactory.create(Parent::class.java)
.rootScope(this, findViewById(android.R.id.content))
.router()
}

@motif.Scope
interface Parent : Creatable<NoDependencies> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ package com.uber.rib.compose.root
import com.uber.rib.compose.root.main.MainRouter
import com.uber.rib.core.BasicViewRouter

class RootRouter(
view: RootView,
interactor: RootInteractor,
private val scope: RootScope,
) : BasicViewRouter<RootView, RootInteractor>(view, interactor) {
class RootRouter(view: RootView, interactor: RootInteractor, private val scope: RootScope) :
BasicViewRouter<RootView, RootInteractor>(view, interactor) {

private var mainRouter: MainRouter? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,17 @@ interface RootScope {

abstract fun presenter(): EmptyPresenter

fun view(parentViewGroup: ViewGroup): RootView {
return RootView(parentViewGroup.context)
}
fun view(parentViewGroup: ViewGroup): RootView = RootView(parentViewGroup.context)

@Expose
fun analyticsClient(activity: RibActivity): AnalyticsClient {
return AnalyticsClientImpl(activity.application)
}
fun analyticsClient(activity: RibActivity): AnalyticsClient =
AnalyticsClientImpl(activity.application)

@Expose
fun experimentClient(activity: RibActivity): ExperimentClient {
return ExperimentClientImpl(activity.application)
}
fun experimentClient(activity: RibActivity): ExperimentClient =
ExperimentClientImpl(activity.application)

@Expose
fun loggerClient(activity: RibActivity): LoggerClient {
return LoggerClientImpl(activity.application)
}
fun loggerClient(activity: RibActivity): LoggerClient = LoggerClientImpl(activity.application)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,16 @@ import android.widget.TextView

class RootView
@JvmOverloads
constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = 0,
) : FrameLayout(context, attrs, defStyle) {
constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) :
FrameLayout(context, attrs, defStyle) {

init {
setBackgroundColor(Color.RED)
addView(
TextView(context).apply {
text = "root (view)"
setTextColor(Color.WHITE)
},
}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update

class AuthStream {
private val _authFlow = MutableStateFlow(AuthInfo(false, "", ""))
private val authFlow = _authFlow.asStateFlow()
private val mutableAuthFlow = MutableStateFlow(AuthInfo(false, "", ""))
private val authFlow = mutableAuthFlow.asStateFlow()

fun observe() = authFlow

fun accept(value: AuthInfo) {
_authFlow.update { value }
mutableAuthFlow.update { value }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,12 @@ interface MainScope {
analyticsClient: AnalyticsClient,
experimentClient: ExperimentClient,
loggerClient: LoggerClient,
): ComposePresenter {
return object : ComposePresenter() {
): ComposePresenter =
object : ComposePresenter() {
override val composable = @Composable { MainView(childContent) }
}
}

fun view(parentViewGroup: ViewGroup): ComposeView {
return ComposeView(parentViewGroup.context)
}
fun view(parentViewGroup: ViewGroup): ComposeView = ComposeView(parentViewGroup.context)

abstract fun childContent(): MainRouter.ChildContent

Expand Down
Loading

0 comments on commit c959ea2

Please sign in to comment.