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

MBS-12612 Detect and prevent Kotlin daemon fallback strategy #1326

Merged
merged 1 commit into from
Feb 4, 2022

Conversation

eugene-krivobokov
Copy link
Contributor

No description provided.

) = gradlew(
projectDir,
task,
"-Dkotlin.daemon.jvm.options=invalid_jvm_argument_to_fail_process_startup",
Copy link
Contributor

Choose a reason for hiding this comment

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

I kinda like this hacky approach )
but there is a chance that it will be handled differently in the future, just saying

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, I understand and accept this trade-off.
I haven't found other good ways to simulate this but having tests is important.

@dsvoronin
Copy link
Contributor

You should probably add this PR to KT issue as a possible workaround

@eugene-krivobokov eugene-krivobokov merged commit 50044d5 into develop Feb 4, 2022
@eugene-krivobokov eugene-krivobokov deleted the MBS-12612-kotlin-fallback branch February 4, 2022 08:37
@eugene-krivobokov eugene-krivobokov changed the title MBS-12612 Detekt and prevent Kotlin daemon fallback strategy MBS-12612 Detect and prevent Kotlin daemon fallback strategy Feb 4, 2022

fun register(project: Project) {
if (isDaemonDisabled(project)) {
project.logger.debug("Kotlin daemon fallback detection is disabled due to absence of daemon")
Copy link
Contributor

Choose a reason for hiding this comment

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

lifecycle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in #1336

* Copy of internal logic in GradleKotlinCompilerRunner
*/
private fun isDaemonDisabled(project: Project): Boolean {
val strategy = project.providers.systemProperty("kotlin.compiler.execution.strategy")
Copy link
Contributor

Choose a reason for hiding this comment

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

It will be broken if property name will be changed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a test to this case: #1336

val strategy = project.providers.systemProperty("kotlin.compiler.execution.strategy")
.forUseAtConfigurationTime()
.getOrElse("daemon")
return strategy != "daemon" // "in-process", "out-of-process"
Copy link
Contributor

Choose a reason for hiding this comment

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

We could add to check flag to force using the deamon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see the need for it yet.
Daemon is the default behavior for a long time. Also, we don't have proof that it's better than other strategies.

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.

3 participants