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

Migrate integration-testing module from Groovy to Kts #4341

Merged

Conversation

DmitryTsyvtsyn
Copy link

No description provided.

Copy link
Collaborator

@dkhalanskyjb dkhalanskyjb left a comment

Choose a reason for hiding this comment

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

With the proposed changes, I get the following Gradle error (for example, when invoking ./gradle tasks in the integration-testing directory):

Build file `kotlinx.coroutines/integration-testing/build.gradle.kts' line: 34

'kotlin_snapshot_version' should be defined when building with snapshot compiler

On develop, everything is okay, so there's a clear regression.

When I look at build.gradle and build.gradle.kts, there's a clear change in logic.

Such mistakes will be easier to avoid (and if they do happen, to pinpoint) if the refactoring is split into several commits:

  • Rename *.gradle into *.gradle.kts (the build is expected to fail due to the incorrect syntax).
  • Rewrite the syntax to be correct, but stay as faithful as possible to the original (so that all the changes are trivial).
  • Introduce the extra structure if you want.

This is just a suggestion, though. I'll accept this PR as is when it's fixed, as it's quite small and easy to verify with any approach.

@DmitryTsyvtsyn DmitryTsyvtsyn force-pushed the migrate-integration-testing-to-kts branch 2 times, most recently from 50d6d83 to c7f7463 Compare January 28, 2025 13:03
@DmitryTsyvtsyn
Copy link
Author

I updated the pull request

Copy link
Collaborator

@dkhalanskyjb dkhalanskyjb left a comment

Choose a reason for hiding this comment

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

Other than the remaining change in behavior, I think this is good to go. There are still minor things that could be improved in terms of style. Would you like me to list them, or should we merge this PR, and then I'll put my fixes on top of it in a separate PR myself?

}

plugins {
id("org.jetbrains.kotlin.jvm") version "2.0.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

2.0.0 is incorrect, it must be the configured Kotlin version.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I'll correct it

@DmitryTsyvtsyn
Copy link
Author

Other than the remaining change in behavior, I think this is good to go. There are still minor things that could be improved in terms of style. Would you like me to list them, or should we merge this PR, and then I'll put my fixes on top of it in a separate PR myself?

Give me a list of minor things, I'll correct it along with the Kotlin version

val kotlinVersion = fetchKotlinVersion()

extra.apply {
set("native_targets_enabled", isEnabledNativeTargets)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This variable is unused, so no need to set or check it.

Copy link
Author

Choose a reason for hiding this comment

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

Did

val isEnabledNativeTargets = rootProject.properties["disable_native_targets"] == null
val usingSnapshotVersion = checkIsSnapshotVersion()
val hasSnapshotTrainProperty = checkIsSnapshotTrainProperty()
val kotlinVersion = fetchKotlinVersion()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This variable is only used to set kotlin_version, which is only used in this build script. Both fetchKotlinVersion and this val can be moved outside the buildScript block.

Copy link
Author

Choose a reason for hiding this comment

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

fetchKotlinVersion() depends on different functions

Copy link
Author

Choose a reason for hiding this comment

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

It won't work, I checked

Copy link
Collaborator

Choose a reason for hiding this comment

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

The result of the function being called is available in extra["build_snapshot_train"].

Copy link
Author

Choose a reason for hiding this comment

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

If you set extra outside the buildscript block in the buildscript block you won't get the value( I checked

}
}

tasks.create<Test>("jvmCoreTest") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

By giving a name to this, you can refer to the newly-created task without using the "jvmCoreTest" string below. The same goes for the other tasks.

Copy link
Author

Choose a reason for hiding this comment

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

Did

}
}

tasks.named<KotlinCompile>("compileDebugAgentTestKotlin") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Starting from this line, all of this could be put into a tasks block, so that there's no need to repeat tasks. everywhere.

Copy link
Author

Choose a reason for hiding this comment

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

Did

}

// Drop this when node js version become stable
tasks.withType(org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask::class.java).configureEach {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
tasks.withType(org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask::class.java).configureEach {
tasks.withType<org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask>().configureEach {

By importing the class name, the code becomes even more readable. The same goes for all the other tasks.withType( invocations.

Copy link
Author

Choose a reason for hiding this comment

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

Did

}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile::class.java).configureEach {
jvmTargetValidationMode = org.jetbrains.kotlin.gradle.dsl.jvm.JvmTargetValidationMode.WARNING
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would benefit from importing the name.

Copy link
Author

Choose a reason for hiding this comment

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

Did

@DmitryTsyvtsyn DmitryTsyvtsyn force-pushed the migrate-integration-testing-to-kts branch from c7f7463 to 3e35437 Compare February 16, 2025 04:53
@DmitryTsyvtsyn
Copy link
Author

It's ready! You can check!

@dkhalanskyjb dkhalanskyjb merged commit 3ed623a into Kotlin:develop Feb 18, 2025
1 check failed
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.

2 participants