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

Resources: multimodule projects support #4229

Closed
xinzhengzhang opened this issue Feb 4, 2024 · 15 comments
Closed

Resources: multimodule projects support #4229

xinzhengzhang opened this issue Feb 4, 2024 · 15 comments
Assignees
Labels
enhancement New feature or request resources

Comments

@xinzhengzhang
Copy link

Describe the bug
Two modules has values/strings.xml cause compile error

Affected platforms
Select one of the platforms below:

  • Android

If the bug is Android-only, report it in the Jetpack Compose tracker

Versions

  • Kotlin version*: 1.9.22
  • Compose Multiplatform version*: 1.6.0-dev1397

To Reproduce
Steps and/or the code snippet to reproduce the behavior:

  1. Go to 'compose-multiplatform/components/resources'
  2. Duplicated demo/shared directory to demo/shared2 and only leave demo/shared2/src/commonMain/composeResources/values/strings.xml
  3. Add shared2 to deps of settings.gradle.kts and demo/androidApp
  4. :resources:demo:androidApp:assembleDebug

Expected behavior
Compile succeed

Screenshots
Screenshot 2024-02-04 at 13 05 06

@xiaozhikang0916
Copy link
Contributor

Any progress on this issue?

@dima-avdeev-jb
Copy link
Contributor

@xiaozhikang0916
Currently @terrakok is on vacation. Please wait a little bit

@blazsolar
Copy link
Contributor

Based on the response #4165 (comment), this will not be implemented.

@xiaozhikang0916
Copy link
Contributor

So, according to #4327 (comment) and #4165 (comment), if I need to use string resources in multiple modules with compose, I have to extract those resources in one public module and export all the resources by handwriting codes?

@MobiDevelop
Copy link

So, according to #4327 (comment) and #4165 (comment), if I need to use string resources in multiple modules with compose, I have to extract those resources in one public module and export all the resources by handwriting codes?

This isn't really an acceptable solution.

@terrakok
Copy link
Collaborator

https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-images-resources.html

  • Multimodule projects are not supported yet. The JetBrains team is working on adding this functionality in future releases. For now, store all resources in the main application module.

  • The publication of Compose Multiplatform libraries with resources is not supported yet. The JetBrains team is working on adding this functionality in future releases.

Currently, there are some limitations in underlying things that block us from doing this. We're working with Kotlin and other teams to make this happen.

@xiaozhikang0916
Copy link
Contributor

Please consider making the default visibility public of the generated Res class for the current limitations to avoid the boilerplate exposing fields or hacking scripts.

@terrakok terrakok changed the title [Bug] Res generation grade plugin Resources: multimodule projects support Feb 26, 2024
@terrakok terrakok added enhancement New feature or request and removed bug Something isn't working labels Feb 26, 2024
@terrakok
Copy link
Collaborator

#4327 (comment)

@xinzhengzhang
Copy link
Author

Is it possible to add at least a turn off switch to control the resource itself if it is not expected to use the resource? Or is it more recommended not to use the composeResources directory in this case?

@terrakok
Copy link
Collaborator

Could you explain your problem? I don't get it

@xinzhengzhang
Copy link
Author

Could you explain your problem? I don't get it

Main reasons:
I am using bazel to organize kmm projects, and will generate ide projects (gradle) for R & D similar to rules_xcodeproj for iOS. For some generate artifacts (ksp & kapt) I currently have my own generation pipeline and do not use gradle plugin. This is why I want to be able to control the production products (Res) myself.

Other reasons:
Currently there are many limitation on using Res, such as requiring the use of one module to integrate Res, and handwriting template code to expose internal resources is not very friendly, and I will even consider analyzing the Res pipeline to make these internal resources public. This is also I hope there is a switch to turn off this part, and I manage the pipeline generation of integrated Res myself

@terrakok
Copy link
Collaborator

#4454

@xinzhengzhang
Copy link
Author

#4454

Thank a lot for the support!
In addition, I would like to confirm about Resources.Options

So far I see only enum class ResourceClassGeneration {Auto, Always} I would like to ask if there are plans to separate the Resource compile tool like aapt in android and open {Never} to add more freedom for some customization scenarios?

terrakok pushed a commit that referenced this issue Mar 25, 2024
# 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](#4229 (comment))
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.
@Deorigami
Copy link

gambar
Hi @xiaozhikang0916 .. can you please tell me on how to configure the Resources to be Public .. i cant fint the Resources Extensions .. thank you

@okushnikov
Copy link

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request resources
Projects
None yet
Development

No branches or pull requests

9 participants