-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
base: develop
Are you sure you want to change the base?
Migrate integration-testing module from Groovy to Kts #4341
Conversation
There was a problem hiding this 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.
50d6d83
to
c7f7463
Compare
I updated the pull request |
There was a problem hiding this 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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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) |
There was a problem hiding this comment.
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.
val isEnabledNativeTargets = rootProject.properties["disable_native_targets"] == null | ||
val usingSnapshotVersion = checkIsSnapshotVersion() | ||
val hasSnapshotTrainProperty = checkIsSnapshotTrainProperty() | ||
val kotlinVersion = fetchKotlinVersion() |
There was a problem hiding this comment.
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.
} | ||
} | ||
|
||
tasks.create<Test>("jvmCoreTest") { |
There was a problem hiding this comment.
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.
} | ||
} | ||
|
||
tasks.named<KotlinCompile>("compileDebugAgentTestKotlin") { |
There was a problem hiding this comment.
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.
} | ||
|
||
// Drop this when node js version become stable | ||
tasks.withType(org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask::class.java).configureEach { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
} | ||
|
||
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile::class.java).configureEach { | ||
jvmTargetValidationMode = org.jetbrains.kotlin.gradle.dsl.jvm.JvmTargetValidationMode.WARNING |
There was a problem hiding this comment.
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.
val nodeJsRootExtension = rootProject.extensions.findByType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension::class.java) | ||
nodeJsRootExtension?.nodeVersion = "21.0.0-v8-canary202309167e82ab1fa2" | ||
nodeJsRootExtension?.nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, then
val nodeJsRootExtension = rootProject.extensions.findByType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension::class.java) | |
nodeJsRootExtension?.nodeVersion = "21.0.0-v8-canary202309167e82ab1fa2" | |
nodeJsRootExtension?.nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary" | |
rootProject.extensions.findByType<NodeJsRootExtension>()?.let { | |
it.nodeVersion = "21.0.0-v8-canary202309167e82ab1fa2" | |
it.nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary" | |
} |
(after adding an import statement). Perfectly readable even without the redundant repetition.
No description provided.