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
16.08k stars 1.17k forks source link

Align project wizard with Multiplatform template #579

Closed ColtonIdle closed 3 weeks ago

ColtonIdle commented 3 years ago

I'm trying to move my existing android app to be multiplatform. I've been using the multiplatform template here as a reference AND the multiplateform code generated from the intellij wizard... but there are a few differences that I just don't understand... and I'm not even sure if they're intentional or mistakes.

  1. I understand that logically the template on github should be more up to date, but it seems more cluttered than the one from the generated wizard project. Personally. I'm so lost here in terms of "what is actually needed to use jetbrains compose" that I don't even want to move any further. Can someone clarify?

    Screen Shot 2021-04-10 at 9 47 33 PM
  2. Mostly a nitpick, but I'd recommend removing System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") from root build.gradle.kts. Is that really needed in a template project? I just feel like it confused me more. "Did I miss documentation where I should be setting an ENV var somehwere?"

  3. Okay. This issn't a difference, but again a nitpick common/build.gradle.kts contains android dependencies and android/build.gradle.kts contains android dependencies

    named("androidMain") {
            dependencies {
                api("androidx.appcompat:appcompat:1.3.0-beta01")
                api("androidx.core:core-ktx:1.3.1")
            }
        }

and

dependencies {
    implementation(project(":common"))
    implementation("androidx.activity:activity-compose:1.3.0-alpha03")
}

As a first time user of multiplatform compose... this is confusing. I can remove the ones from common and drop them into the project directly and everything still works. It seems like common android deps is a superset. But again. As a new user (hence using a template) this is confusing. Am I only supposed to put certain dependencies in certain places? I would suggest simplifying this as much as possible. At the very least. add a comment like brand new android projects.

New android projects have a root build.gradle with this warning message

// NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
  1. android build.gradle.kts differences

wizard generated project shows this

plugins {
    id("org.jetbrains.compose") version "0.3.1"
    id("com.android.application")
    kotlin("android")
}

but github template shows this

plugins {
    id("com.android.application")
    kotlin("android")
    id("org.jetbrains.compose")
}

Should I be declaring versions after id("org.jetbrains.compose") or not?

I know some of these are a bit nitpicky, but I care a lot about compose desktop and multiplatform and I just don't want new users (and new people that want to adopt compose into existing projects) to run into the same issues or questions as me. Thanks

akurasov commented 3 years ago
  1. Will take a look at it.
  2. See response in https://github.com/JetBrains/compose-jb/issues/728
  3. This is a bit surprise. Android sourceSet of common modules uses API declared in these deps. And if you move them to android module, the common module should've compilation errors. I will double check it.
  4. Will add the version there, if it is not.
akurasov commented 3 years ago

TBD with wizard

  1. In wizard move compose version to top-level build.gradle.kts
  2. Move android dependencies to Android module - there is no android api usage in common module.

@ColtonIdle, answering the forth point. In template version is set in top-level build.gradle, so there is no need to have it in each module. We will modify wizard to support it the same way, as it is move convenient.

ColtonIdle commented 3 years ago

Thanks for following up on my feedback! Just trying to make it as easy for a newcomer to understand what's going on =)

okushnikov commented 3 months ago

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