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

Deprecate declaring multiple targets of the same type #3690

Closed
wants to merge 5 commits into from

Conversation

antohaby
Copy link

Hi!
I want to add deprecation information about declaring multiple targets in Kotlin Multiplatform Projects.

YT issue about deprecation: https://youtrack.jetbrains.com/issue/KT-59316

I also would like to ask your advice on how to structure this information best and consistently.

@antohaby
Copy link
Author

This is currently in a draft state. We might adjust it with more real use cases.
I will search for some community projects where multiple targets are declared and I'll try to understand why they do that and how to fix it in the recommended way. If I find some interesting and repeating cases I will consider adding them to this doc.

@github-actions
Copy link
Contributor

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Aug 19, 2023
@antohaby antohaby force-pushed the alakotka/declaring-multiple-targets branch from a21f8a9 to 6136891 Compare August 21, 2023 06:58
@antohaby antohaby requested a review from a team as a code owner August 21, 2023 06:58
@antohaby antohaby force-pushed the alakotka/declaring-multiple-targets branch from 6136891 to 5aa8101 Compare August 28, 2023 08:25
Copy link
Contributor

@dsavvinov dsavvinov left a comment

Choose a reason for hiding this comment

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

Thanks for providing examples, and sorry for suggesting to drop this work, but I'm really concerned that they are not "complete", but still quite verbose (and if we want to make them "complete", they'll have to be even more verbose). Let's discuss the idea of dropping them completley?

kotlin {
jvm()
jvm("jvmKtor")
jvm("jvmOkio") // is not recommended and will produce deprecation warning
Copy link
Contributor

Choose a reason for hiding this comment

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

It reads as if the previous line (jvm("jvmKtor")) is fine, but it's not, right?

Copy link
Author

Choose a reason for hiding this comment

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

right, we can remake it to just:

jvm()
jvm("jvmKtor") // is not recommended...

```kotlin
// Project ':myLibrary:integrationTests'
kotlin {
jvm("jvmKtor") // !!!
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd recommend to avoid using JVM-shared source sets without the specific the need. I.e., let's add linuxX64 or something here.

val okioIntegrationTest by compilations.creating

// Associate with test compilation to see tests from commonTest
ktorIntegrationTest.associateWith(compilations.getByName("test"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is associateWith considered non-experimental for KMP? I thought it's not, and only associateWith in JVM is.

val okioIntegrationTest by compilations.creating

// Associate with test compilation to see tests from commonTest
ktorIntegrationTest.associateWith(compilations.getByName("test"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it associated with test? Does it even work in IDE?

I think the direct counterpart for the previous snippet would be to:

  • associate new compilations with main
  • connect link their default source sets with dependsOn to the commonTest

// Project ':myUILibrary'
kotlin {
jvm("jvmCompose") // !!!
jvm("jvmSwing") // !!!
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto about having commonMain as JVM-shared source set

```kotlin
// Project ':myUILibrary
kotlin {
jvm()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd also avoid promoting single-target projects

</tab>
<tab title="Now" group-key="now">

```kotlin
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit conernced that this example is neither concise, nor complete. I think we have to make a firm decision: either we're providing complete examples, or we don't provide them at all and just assume that the users that had multiple same targets are advanced enough to handle this refactoring on their own.

I'm leaning towards the latter. Mostly because it's so hard to give a proper minimal migration example -- as it involves multiple files in the project, the only solution I see is an actual GitHub project with "migration commit", but IMO it's too much for this case (but we can expand it, if we see demand/questions)

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with @dsavvinov here. Also, it would be nice to include a paragraph about when to choose separate compilations over separate Gradle projects. Adding a separate Gradle project is usually more involved. Unless there's something fundamental it unlocks, I would even not mention it.

// Create a Test Run to for each integration test
testRuns {
create("ktorIntegration") { setExecutionSourceFrom(ktorIntegrationTest) }
create("okioIntegration") { setExecutionSourceFrom(okioIntegrationTest) }

This comment was marked as outdated.

@dsavvinov
Copy link
Contributor

Changes in this request will be merged as part of the #3789 . I'm closing this one.

@dsavvinov dsavvinov closed this Sep 21, 2023
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.

4 participants