Skip to content

[Android] Update build tools#3538

Closed
m-bert wants to merge 8 commits intomainfrom
@mbert/update-kotlin-version
Closed

[Android] Update build tools#3538
m-bert wants to merge 8 commits intomainfrom
@mbert/update-kotlin-version

Conversation

@m-bert
Copy link
Copy Markdown
Collaborator

@m-bert m-bert commented May 30, 2025

Caution

Suppressed by #3544

Description

Seems like we fallen behind with our build tools dependencies. This PR:

  • Bumps Kotlin version to 2.0.21
  • Rewrites build scripts into Kotlin
  • Updates gradle
  • Removes build warnings

Warning

Looks like spotless is a bit picky when it comes to Kotlin scripts, so I had to move it to build.gradle.kts

Test plan

  • Run yarn android in basic-example and expo-example (build apps with --warning-mode all)
  • Run yarn format:android

@m-bert m-bert marked this pull request as ready for review June 2, 2025 13:01
@m-bert m-bert requested a review from j-piasecki June 2, 2025 13:01
Comment on lines +252 to +260
spotless {
kotlin {
target("**/*.kt")
ktlint().editorConfigOverride(mapOf("indent_size" to "2", "max_line_length" to "120"))
trimTrailingWhitespace()
leadingTabsToSpaces()
endWithNewline()
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to use spotless when we're a dependency

plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
id("com.diffplug.spotless") version "7.0.4"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

val libVersion = json["version"] as String
val (major, minor, patch) = libVersion.split(".")

return Triple(major.toInt(), minor.toInt(), patch.toInt())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what way does this break when one of the segments is not a number (i.e. 0-rc.1)?

apply(plugin = "com.facebook.react")
}

fun safeExtGet(prop: String, fallback: Any?): Any? =
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be generic?

Comment on lines +217 to +218
dirs += "common/src/main/java"
dirs += "noreanimated/src/main/java"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, can those two be merged into noreanimated (likely another PR)?

Comment on lines +244 to +245
// TODO: Delete this block:
// It's safe to delete this block once we drop support for RN 0.76
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the moment (in another PR).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I didn't want to make those changes here, but it is definitely right time to do this!

}

defaultConfig {
minSdk = safeExtGet("minSdkVersion", 21) as Int
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


plugins {
id("com.android.library") version "8.5.0"
id("org.jetbrains.kotlin.android") version "2.0.21"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be read from the apps config first?


plugins {
id("com.android.library") version "8.5.0"
id("org.jetbrains.kotlin.android") version "2.0.21"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, assuming this corresponds to the buildscript block, don't we need spotless here?

}

include("lib")
project(":lib").projectDir.mkdirs() No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline

@m-bert
Copy link
Copy Markdown
Collaborator Author

m-bert commented Jun 4, 2025

Suppressed by #3544

@m-bert m-bert closed this Jun 4, 2025
m-bert added a commit that referenced this pull request Jun 5, 2025
>[!IMPORTANT]
> Replaces #3538 

## Description

Seems like we fallen behind with our build tools dependencies. This PR:

- Bumps `Kotlin` version to 2.0.21
- Updates `gradle`
- Removes build warnings
- Removes sourceSets for unsupported versions of RN

## Test plan

- Run `yarn android` in `basic-example` and `expo-example`
- Run `yarn format:android`
@m-bert m-bert deleted the @mbert/update-kotlin-version branch June 11, 2025 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants