JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.95k stars 1.16k forks source link

[Gradle plugin, Desktop] Ability to move Compose Previews to separate sourceSet #2832

Open dsvoronin opened 1 year ago

dsvoronin commented 1 year ago

Hello JetBrains and community!

I am using compose-jb(jvm only) actively for my pet-project for last year and have a problem that bothers me for a long time. Please, first of all, validate my idea, maybe I am missing something:

I reuse a lot of stub code in both Compose Previews and unit/integration tests. It is data class filled with stub or random data and also stub implementations of Interfaces.

I really like the idea of using gradle test-fixtures to isolate such stub code, but i can't do it because of Compose Previews.

What i want is to create a separate sourceSet for Previews and add main sourceSet, compose dependencies and test fixtures dependency for it.

I've tried and found out that it's not possible with current Preview task creation logic in the plugin, particularly because of this line.

I could have move some code from plugin to my own custom plugin, but there are a lot of wiring, deep into plugin, i'd have to move Tasks and a lot of stuff with me. That's all because of internal modificators all over the plugin.

What do you think about the idea in general? If it's not only me who can benefit from these type of project organizations, than it's probably a good idea to add the ability to register additional source sets in the plugin?

rossdanderson commented 1 year ago

I second this!

okushnikov commented 2 months ago

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