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

Order of atomicfu and kotlin plugins in the classpath #384

Closed
mvicsokolova opened this issue Dec 13, 2023 · 3 comments
Closed

Order of atomicfu and kotlin plugins in the classpath #384

mvicsokolova opened this issue Dec 13, 2023 · 3 comments

Comments

@mvicsokolova
Copy link
Collaborator

mvicsokolova commented Dec 13, 2023

After #377 a strange behaviour reproduced during application of atomicfu-gradle-plugin to kotlinx.coroutines.
The order in which atomicfu-gradle-plugin and kotlin-gradle-plugin are added to the classpath defines actual dependencies found on the classpath.
I've described the problem in detail here: Kotlin/kotlinx.coroutines#3984.

The actual reason of this behaviour should be investigated.

mvicsokolova added a commit to Kotlin/kotlinx.coroutines that referenced this issue Dec 14, 2023
This commit changes the order of adding atomicfu and kotlin gradle plugin to the classpath.

When `kotlin-gradle-plugin` is added first, `atomicfu-gradle-plugin` is not applied at all and this error is thrown: "e: Module kotlinx.atomicfu cannot be found in the module graph". The change of order fixes the issue. Should be properly investigated.

This behaviour started to reproduce after this change in kotlinx-atomicfu (Kotlin/kotlinx-atomicfu#377).

Here is the corresponding issue in atomicfu: Kotlin/kotlinx-atomicfu#384
@mvicsokolova
Copy link
Collaborator Author

mvicsokolova commented Dec 19, 2023

The high level reason of why this problem occurred is that the compiler plugin has the same id as the atomicfu-gradle-plugin (See the name of the file that provides the implementation class for the compiler plugin). 🙃 Hence this id clash causes a conflict during plugin resolution and the actual atomicfu-gradle-plugin is not applied at all.

I can suggest the temporary solution for this issue:
we just write a big message in README: "Please tweak the plugin order in case of the compilation error (or do not apply kotlin-gradle-plugin in the legacy manner via the build script)". And the good solution with migration will follow (see this comment).

Or the alternative solution will be to create AtomicfuGradlePluginLegacy with the different id, e.g. "kotlinx-atomicfu-legacy". And warn users in case of the compilation error to use the plugin with the id kotlinx-atomicfu-legacy.

Pros:

  • the conflict of ids will be avoided

Cons:

  • I guess, when you suggest users to use something deprecated or legacy, you need to provide a preferable option to use, though this version (in the form of the compiler plugin) is not ready yet.

Both solutions are bad, and in this case I'd choose the first one, because it's easier.

mvicsokolova added a commit that referenced this issue Dec 20, 2023
…-plugin.

Do not require to add it manually.

Fixes #384
@mainrs
Copy link

mainrs commented Dec 25, 2023

I want to chime in and share a bug I came across when applying the plugin as described in the readme file.

I added it to buildscript.dependencies.classpath and I then went ahead and applied the plugin to all projects using allprojects.apply(plugin = "kotlinx-atomicfu"). This broke compatibility with Java source. One of the modules of my project contained a single java class file under src/main/java and that file was not part of the classpath anymore. The project compiled file, but running the program resulted in a NoClassDefFoundError. And the jar I build using the build command did not contain said java class file.

Maybe this is a misconfiguration on my side...

@fzhinkin
Copy link
Contributor

@mainrs I don't thinks that's a misconfiguration. Java source sets support seems to be broken since 0.21.0.

woainikk pushed a commit to Kotlin/kotlinx.coroutines that referenced this issue Jan 4, 2024
This commit changes the order of adding atomicfu and kotlin gradle plugin to the classpath.

When `kotlin-gradle-plugin` is added first, `atomicfu-gradle-plugin` is not applied at all and this error is thrown: "e: Module kotlinx.atomicfu cannot be found in the module graph". The change of order fixes the issue. Should be properly investigated.

This behaviour started to reproduce after this change in kotlinx-atomicfu (Kotlin/kotlinx-atomicfu#377).

Here is the corresponding issue in atomicfu: Kotlin/kotlinx-atomicfu#384

(cherry picked from commit 605ec56)
woainikk pushed a commit to Kotlin/kotlinx.coroutines that referenced this issue Jan 4, 2024
This commit changes the order of adding atomicfu and kotlin gradle plugin to the classpath.

When `kotlin-gradle-plugin` is added first, `atomicfu-gradle-plugin` is not applied at all and this error is thrown: "e: Module kotlinx.atomicfu cannot be found in the module graph". The change of order fixes the issue. Should be properly investigated.

This behaviour started to reproduce after this change in kotlinx-atomicfu (Kotlin/kotlinx-atomicfu#377).

Here is the corresponding issue in atomicfu: Kotlin/kotlinx-atomicfu#384

(cherry picked from commit 605ec56)
woainikk pushed a commit to Kotlin/kotlinx.coroutines that referenced this issue Jan 9, 2024
This commit changes the order of adding atomicfu and kotlin gradle plugin to the classpath.

When `kotlin-gradle-plugin` is added first, `atomicfu-gradle-plugin` is not applied at all and this error is thrown: "e: Module kotlinx.atomicfu cannot be found in the module graph". The change of order fixes the issue. Should be properly investigated.

This behaviour started to reproduce after this change in kotlinx-atomicfu (Kotlin/kotlinx-atomicfu#377).

Here is the corresponding issue in atomicfu: Kotlin/kotlinx-atomicfu#384

(cherry picked from commit 605ec56)
mvicsokolova added a commit that referenced this issue Jan 9, 2024
…-plugin.

Do not require to add it manually.

Fixes #384
woainikk pushed a commit to Kotlin/kotlinx.coroutines that referenced this issue Jan 9, 2024
This commit changes the order of adding atomicfu and kotlin gradle plugin to the classpath.

When `kotlin-gradle-plugin` is added first, `atomicfu-gradle-plugin` is not applied at all and this error is thrown: "e: Module kotlinx.atomicfu cannot be found in the module graph". The change of order fixes the issue. Should be properly investigated.

This behaviour started to reproduce after this change in kotlinx-atomicfu (Kotlin/kotlinx-atomicfu#377).

Here is the corresponding issue in atomicfu: Kotlin/kotlinx-atomicfu#384

(cherry picked from commit 605ec56)
woainikk pushed a commit to Kotlin/kotlinx.coroutines that referenced this issue Jan 18, 2024
This commit changes the order of adding atomicfu and kotlin gradle plugin to the classpath.

When `kotlin-gradle-plugin` is added first, `atomicfu-gradle-plugin` is not applied at all and this error is thrown: "e: Module kotlinx.atomicfu cannot be found in the module graph". The change of order fixes the issue. Should be properly investigated.

This behaviour started to reproduce after this change in kotlinx-atomicfu (Kotlin/kotlinx-atomicfu#377).

Here is the corresponding issue in atomicfu: Kotlin/kotlinx-atomicfu#384

(cherry picked from commit 605ec56)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants