Skip to content

Fix atomicfu plugin application #3488

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

Merged
merged 1 commit into from
Oct 25, 2022
Merged

Conversation

mvicsokolova
Copy link
Contributor

@mvicsokolova mvicsokolova commented Oct 18, 2022

The new way of atomicfu compiler plugin applicaition takes 3 steps:

  • first the compiler plugin AtomicfuKotlinGradleSubplugin is applied. It adds an extension AtomicfuKotlinGradleExtension with properties for turning on jvm and js transformation.
  • Then these extension properties are set in the AtomicfuGradlePlugin.
  • When AtomicfuKotlinGradleSubplugin$isApplicable is invoked, the values of the extension properties are already set and the plugin is applied accordingly.

When we apply the atomicfu plugin too late in the configuration -- the AtomicfuKotlinGradleSubplugin$isApplicable may be called earlier, when the properties are not set yet and the compiler plugin is not applied.

The Train build with these changes + atomicfu JVM compiler plugin support

@mvicsokolova
Copy link
Contributor Author

@Tapchicoma could you please have a look at this issue, because I do not quite get the reason

@Tapchicoma
Copy link
Contributor

The problem is in this line.

It triggers :kotlinx-core-coroutines project evaluation including all afterEvaluate { .. } closures, where subplugin options are configured. The problem is that apply plugin: "configure-compilation-conventions" goes after this line meaning it configures almost nothing in :kotlinx-core-coroutines subproject as it is already evaluated. By moving "configure-compilaiton-conventions" above line #139, conventions are applied before core project evaluation fixing the issue.

@@ -76,6 +76,9 @@ def configureKotlinJvmPlatform(configuration) {
configuration.attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.jvm)
}

// Configure subprojects with Kotlin sources
apply plugin: "configure-compilation-conventions"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm okay with this particular kludge.

What puzzles me is the general debuggability, i.e. consider the same situation happens to an external user:

When we apply the atomicfu plugin too late in the configuration -- the AtomicfuKotlinGradleSubplugin$isApplicable may be called earlier, when the properties are not set yet and the compiler plugin is not applied.

What are the option for them to debug it and understand what's going on? Are there better options?

Copy link
Contributor

Choose a reason for hiding this comment

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

imho this case is nothing to do with Atomicfu plugin as it is not even present when core project evaluates. This is more Gradle edge-case. BTW why do you need evaluationDependsOn for core project? 🤔

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