Ports a part of Unicode's ICU in pure Kotlin and implements
Android-style plural string resource support. Fixes
JetBrains/compose-multiplatform#425.
# Changes
- Added `org.jetbrains.compose.resources.intl.{PluralCategory,
PluralRule, PluralRuleList}`, which parses and evaluates scripts in
Unicode's Locale Data Markup Langauge.
- Copied `plurals.xml` from Unicode's
[CLDR](https://github.com/unicode-org/cldr/blob/release-44-1/common/supplemental/plurals.xml).
- Added `GeneratePluralRuleListsTask`, which parses `plurals.xml` and
generates required Kotlin source codes.
- Added `PluralStringResource`, `pluralStringResource`, or
`getPluralString`, corresponding to `StringResource`, `stringResource`,
or `getString`.
- Modified `ResourcesSpec.kt` so the generated `Res` class exposes
`Res.plurals`.
# Potential Further Improvements
- [ ] Allow configuring the default language in the `compose.resources
{}` block (#4482) to determine the default pluralization rule (or just
presume English as default)
- [ ] Move the parser logic to the Gradle plugin and generate
pluralization rules in `Res` only for languages used in
`composeResources`
---------
Co-authored-by: Konstantin Tskhovrebov <konstantin.tskhovrebov@jetbrains.com>
# Changes
* Add `Never` to `enum class ResourceClassGeneration` to disable the
generation of Res class in the gradle plugin
# Motivation
As the [comment in issue
4229](https://github.com/JetBrains/compose-multiplatform/issues/4229#issuecomment-2008626808)
said, my team is not in the ecosystem of gradle, but organize the build
steps in bazel. We want to follow the files layout but just disable the
generation task of gradle and handle it by outself.
Steps to reproduce:
1) Add a 'font-en' directory with a font to an android app with compose
resources
2) build the app with `assembleDebug` and check that a corresponding dir
is presented in the final APK
3) rename a qualifier of the dir to `font-de`
4) re-build the app with the same command `assembleDebug`
Expected: the new APK will contain the new font dir
Actual: the new APK doesn't have the new font dir but has old one
'font-en'
The PR fixes that
- integrate KGP resource API
- packaging final resources to iOS and JS/Wasm applications
- integration tests of publication and multi module support
- info logging of supported Gradle and KGP versions
### requirements
- Kotlin Gradle Plugin >= 2.0.0-Beta05
- Gradle >= 7.6
Hi all 👋
I recently tried to publish my macOS app to the App Store and the
publishing failed because I wasn't including an Intel version
<img width="609" alt="Screenshot 2024-02-04 at 17 31 52"
src="https://github.com/JetBrains/compose-multiplatform/assets/9467705/a3f421ed-ca77-460b-bc2e-7ceafb3ca1c0">
The alternative could be publishing a Universal binary, but it's not
quite supported now (see #1599). But by setting the minimum version of
macOS to 12, it's possible to upload only arm version.
So, I've added the possibility of changing the minimum macOS version.
It fails with:
```
Configuration `:jvmRuntimeClasspath` contains AndroidX dependencies, but the `android.useAndroidX` property is not enabled, which may cause runtime issues.
:jvmRuntimeClasspath -> org.jetbrains.compose.desktop:desktop-jvm-linux-x64:0.0.0-dev1418 -> org.jetbrains.compose.desktop:desktop:0.0.0-dev1418 -> org.jetbrains.compose.desktop:desktop-jvm:0.0.0-dev1418 -> org.jetbrains.compose.material:material:0.0.0-dev1418 -> org.jetbrains.compose.material:material-desktop:0.0.0-dev1418 -> org.jetbrains.compose.annotation-internal:annotation:0.0.0-dev1418 -> androidx.annotation:annotation:1.7.1
:jvmRuntimeClasspath -> org.jetbrains.compose.desktop:desktop-jvm-linux-x64:0.0.0-dev1418 -> org.jetbrains.compose.desktop:desktop:0.0.0-dev1418 -> org.jetbrains.compose.desktop:desktop-jvm:0.0.0-dev1418 -> org.jetbrains.compose.material:material:0.0.0-dev1418 -> org.jetbrains.compose.material:material-desktop:0.0.0-dev1418 -> org.jetbrains.compose.annotation-internal:annotation:0.0.0-dev1418 -> androidx.annotation:annotation:1.7.1 -> androidx.annotation:annotation-jvm:1.7.1
:jvmRuntimeClasspath -> org.jetbrains.compose.desktop:desktop-jvm-linux-x64:0.0.0-dev1418 -> org.jetbrains.compose.desktop:desktop:0.0.0-dev1418 -> org.jetbrains.compose.desktop:desktop-jvm:0.0.0-dev1418 -> org.jetbrains.compose.foundation:foundation:0.0.0-dev1418 -> org.jetbrains.compose.foundation:foundation-desktop:0.0.0-dev1418 -> org.jetbrains.compose.collection-internal:collection:0.0.0-dev1418 -> androidx.collection:collection:1.4.0
:jvmRuntimeClasspath -> org.jetbrains.compose.desktop:desktop-jvm-linux-x64:0.0.0-dev1418 -> org.jetbrains.compose.desktop:desktop:0.0.0-dev1418 -> org.jetbrains.compose.desktop:desktop-jvm:0.0.0-dev1418 -> org.jetbrains.compose.foundation:foundation:0.0.0-dev1418 -> org.jetbrains.compose.foundation:foundation-desktop:0.0.0-dev1418 -> org.jetbrains.compose.collection-internal:collection:0.0.0-dev1418 -> androidx.collection:collection:1.4.0 -> androidx.collection:collection-jvm:1.4.0
```
(https://teamcity.jetbrains.com/buildConfiguration/JetBrainsPublicProjects_Compose_Publish_2_All_2/4484004?hideTestsFromDependencies=false&hideProblemsFromDependencies=false&expandBuildTestsSection=true&expandBuildChangesSection=true&expandBuildDeploymentsSection=false&expandBuildProblemsSection=true)
after we added annotation/collection to desktop target dependencies.
It seems that Android plugin checks all JVM classpathes, including pure
JVM (desktop) ones. And fails, if the project doesn't have this
property.
Adding this property, as the Android fails without it as well.