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

build: introduce a multi-platform project to host the new Compose UI #4115

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Tbaile
Copy link

@Tbaile Tbaile commented Jan 19, 2025

Introducing new project that tries to give Alchemist a UI that is completely multi-platform across desktop apps and web.
This is an introductory pull requests that adds the project and the initial dependencies.

Copy link

codecov bot commented Jan 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (124d522) to head (3d8fb39).
Report is 1 commits behind head on master.

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #4115   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files           2       2           
  Lines          90      90           
  Branches        3       3           
======================================
  Misses         90      90           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@DanySK DanySK requested a review from AngeloFilaseta January 20, 2025 10:42
@DanySK DanySK force-pushed the master branch 6 times, most recently from 9889fc0 to aeead57 Compare January 20, 2025 14:08
Copy link
Member

@DanySK DanySK left a comment

Choose a reason for hiding this comment

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

let's make sure the build is clean

Comment on lines +18 to +19
id("kotlin-multiplatform-convention") apply false
kotlin("multiplatform")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
id("kotlin-multiplatform-convention") apply false
kotlin("multiplatform")
id("kotlin-multiplatform-convention")

If there are changes required to the convention, then we apply them to the convention

Copy link
Author

Choose a reason for hiding this comment

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

While the convention is fine as is, it requires the js target which is not available in this package. A possible solution is to being able to customize the convention, this needs then enough defaults so that the convention does not break everything and can be customized when needed. If that works for you I'll look into that.

Copy link
Author

@Tbaile Tbaile Jan 22, 2025

Choose a reason for hiding this comment

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

By changing the section from the kotlin-multiplatform-convention plugin from this:

js {
    browser()
    nodejs()
}

to this:

// adding js only when directory `jsMain` exists
if (projectDir.resolve("src/jsMain").exists()) {
    js {
        browser()
        nodejs()
    }
}

It's possible to achieve this behavior, not sure it's most optimal one (but might be effective in the long run, just checking for the target to build before importing the target)

Copy link
Member

Choose a reason for hiding this comment

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

Wait, why don't we have js? Isn't Compose supposed to run also in browser? This is also our main goal: an in-browser interface

Copy link
Author

Choose a reason for hiding this comment

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

It runs on web, but not using the js target, instead using the wasmJs one. This is the only way to use the cross-platform interface: https://kotlinlang.org/docs/wasm-overview.html

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I see. I'd proceed as follows:

  1. create withJS() extension method in the convention, running js { browser() nodejs() }
  2. create withWasmJS() extension method in the convention, running js { browser() nodejs() }
  3. enable only JVM inside the convention
  4. update all other modules using the convention to call withJS()

I would avoid fancy autodetection of folders. It can get very surprising, and the logics is reversed (if I have JS, then I may have the folder, not vice versa). I could (and I do) generate js for purely kotlin subprojects

alchemist-composeui/build.gradle.kts Show resolved Hide resolved
alchemist-composeui/build.gradle.kts Show resolved Hide resolved
@DanySK DanySK force-pushed the master branch 20 times, most recently from 34fa775 to 3d8fb39 Compare January 24, 2025 10:49
@DanySK DanySK force-pushed the master branch 2 times, most recently from 2092f41 to dbdaf5a Compare January 24, 2025 13:06
Comment on lines +83 to +85
fun PatternFilterable.excludeGenerated() = exclude { "build${separator}generated" in it.file.absolutePath }
withType<Detekt>().configureEach { excludeGenerated() }
ktlint { filter { excludeGenerated() } }
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be moved in the convention

*/
@OptIn(ExperimentalComposeUiApi::class)
fun main() {
ComposeViewport(document.body!!) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ComposeViewport(document.body!!) {
ComposeViewport(checkNotNull(document.body) { "Reasonable error message" }) {

@@ -122,6 +124,7 @@ spotbugs-annotations = "com.github.spotbugs:spotbugs-annotations:4.9.0"
redux-kotlin-threadsafe = "org.reduxkotlin:redux-kotlin-threadsafe:0.6.1"
svgsalamander = "guru.nidi.com.kitfox:svgSalamander:1.1.3"
trove4j = "net.sf.trove4j:trove4j:3.0.3"
androidx-lifecycle-runtime-compose = { group = "org.jetbrains.androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "androidx-lifecycle" }
Copy link
Member

Choose a reason for hiding this comment

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

please use lexicographic ordering

@@ -167,3 +170,5 @@ scalafmt = "cz.alenkacz.gradle.scalafmt:1.16.2"
shadowJar = "com.github.johnrengelman.shadow:8.1.1"
taskTree = "com.dorongold.task-tree:4.0.0"
jpackage = "org.panteleyev.jpackageplugin:1.6.0"
compose-multiplatform = { id = "org.jetbrains.compose", version.ref = "compose-multiplatform" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
Copy link
Member

Choose a reason for hiding this comment

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

lexicographic ordering

@@ -40,6 +40,7 @@ include(
"alchemist-ui-tooling",
"alchemist-swingui",
"alchemist-web-renderer",
"alchemist-composeui",
Copy link
Member

Choose a reason for hiding this comment

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

lexicographic order

Copy link
Contributor

mergify bot commented Jan 24, 2025

Hi @Tbaile! 👋
This pull request has conflicts 😖
Could you fix it? 🔧
Thank you! 🙏

Copy link

Please retry analysis of this Pull-Request directly on SonarQube Cloud

@DanySK DanySK changed the title feat: introducing multi-platform UI with Compose build: introduce a multi-platform project to host the new Compose UI Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants