Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gradle] Add DSL to configure compose resources #4482

Merged
merged 3 commits into from
Mar 19, 2024
Merged

Conversation

terrakok
Copy link
Collaborator

@terrakok terrakok commented Mar 14, 2024

Example:

compose.resources {
    publicResClass = true
    packageOfResClass = "me.sample.library.resources"
    generateResClass = auto
}

@igordmn
Copy link
Collaborator

igordmn commented Mar 15, 2024

Adding a second reviewer, as we introduce a new API

@terrakok
Copy link
Collaborator Author

Renamed DSL parameter to make it more clear

compose.resources {
    publicResClass = true
-     resourceProjectId = "me.sample.library.resources"
+     packageOfResClass = "me.sample.library.resources"
    generateResClass = auto
}

Example:
compose.resources {
    publicResClass = true
    resourceProjectId = "me.sample.library.resources"
    generateResClass = auto
}
@terrakok terrakok merged commit 0d0e133 into master Mar 19, 2024
12 checks passed
@terrakok terrakok deleted the k.tskh/public-res branch March 19, 2024 20:11
@paxbun paxbun mentioned this pull request Mar 21, 2024
2 tasks
terrakok added a commit that referenced this pull request Mar 25, 2024
Ports a part of Unicode's ICU in pure Kotlin and implements
Android-style plural string resource support. Fixes
#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>
@Deorigami
Copy link

Hi @terrakok ,, sorry im still confused, how to set the Res class become public? i already use 1.6.2, but my Res class still internal, and i cant find the compose.resource extentions in my gradle, thanks if you reply this

@deepoke
Copy link

deepoke commented Apr 11, 2024

@Deorigami I don't think it made it to 1.6.2 but it was available in 1.6.10-dev1575 and it works!!

@mdsadique-inam
Copy link

Hi @terrakok 👋 I can make the Res class public and access my string Res from another project in code, but if I don't keep the copy of the same string resource, then the UI will show only an empty string.

@m0rtis
Copy link

m0rtis commented Apr 14, 2024

Many-many thanx!!!

@terrakok
Copy link
Collaborator Author

The feature works only with kotlin 2.0.0

@mdsadique-inam
Copy link

Hello @terrakok 👋 with kotlin version 2.0.0-RC1 development is working well but still same issue in production

@terrakok
Copy link
Collaborator Author

I need a reproducer. Could you share it?

@mdsadique-inam
Copy link

mdsadique-inam commented Apr 15, 2024

@terrakok this is my project repo https://github.com/mdsadique-inam/PDNS-Manager you can build using ./gradlew :launchpad:wasmJsBrowserProductionWebpack you may notice the values folder inside the built output-dir is empty and the resources are coming from commonCompose

@terrakok
Copy link
Collaborator Author

OK. this is not related with the DSL. It seems a kotlin wasm target's problem.

@terrakok
Copy link
Collaborator Author

https://youtrack.jetbrains.com/issue/KT-66228
the corresponding issue. it is marked as fixed. I notified the team to recheck it again

@terrakok
Copy link
Collaborator Author

try to run ./gradlew :composeApp:wasmJsBrowserDistribution

@eymar
Copy link
Collaborator

eymar commented Apr 15, 2024

@terrakok this is my project repo https://github.com/mdsadique-inam/PDNS-Manager you can build using ./gradlew :launchpad:wasmJsBrowserProductionWebpack you may notice the values folder inside the built output-dir is empty and the resources are coming from commonCompose

please have a look at: https://youtrack.jetbrains.com/issue/KT-66228/K-Wasm-2.0.0-Beta4-distribution-doesnt-contain-all-files#focus=Comments-27-9719548.0-0

and here: https://kotlinlang.org/docs/wasm-get-started.html#generate-artifacts

@mdsadique-inam
Copy link

@terrakok @eymar thank you for providing your precious to me.

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.

None yet

8 participants