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

Empty jars created when Intellij refreshes project #78

Closed
kpagratis opened this issue Nov 15, 2023 · 6 comments · Fixed by #80
Closed

Empty jars created when Intellij refreshes project #78

kpagratis opened this issue Nov 15, 2023 · 6 comments · Fixed by #80
Labels
a:bug Something isn't working

Comments

@kpagratis
Copy link

empty-jars.zip

When refreshing the attached gradle project, the plugin causes empty jars to be created.
Commenting out extra-java-module-info and re-refreshing intellij after a gradle clean results in no empty jars.

This is causing issues when using quarkus (I'll be creating an issue there as well) when it attempts to build and encounters a 0 byte jar.

@rteabeault
Copy link

I see this empty jar was added in #15. And this does cause issues with quarkus when it runs quarkusGenerateCode task. You get an error like

Failed to read /somepath/build/libs/some-test-fixtures.jar

@jjohannes
Copy link
Member

Thank you for reporting this.

I also noticed another issue with this "hack" recently (I think). If the "hacky" code is triggered, because a transform runs early, it may create the Jar. But then there can be another instance of the transform running afterwards (e.g. in another subproject) that then finds the empty Jar and thinks it is legit. Then it proceeds with the other checks and, depending on how the plugin is configured, may fail with a "the Jar is not a module error".

I think I would prefer to remove this hack again (revert #15). I think IntelliJ should not tigger this problem anymore for "standard" project setups. I'll have a look at the reproducer to see why it happens in this case. This may be an issue with the Quarkus/Gradle integration. Something similar to this problem with the shadow plugin: GradleUp/shadow#882.

We could also improve/extend the "hack" somehow. But this feels wrong and it may be a deep rabbit hole....

@jjohannes jjohannes added the a:bug Something isn't working label Nov 17, 2023
@jjohannes
Copy link
Member

The issue that the transform (sometimes?) runs during the IDEA Sync (before Jar files are created) still exists. I am not sure if it is the case for all projects, but it is in this reproducer and it looks like a very general code path to me. So that's a problem with how transforms are triggered in the Gradle/IDEA integrations itself.

The change for #15 had two parts:

  1. If the file does not exist, do not proceed - this alone should cater for the IDEA Sync issue
  2. The reproducer in Error when importing multi-module project in IDEA when using this plugin in combination with 'java-test-fixtures' #15 used the org.springframework.boot plugin. Once I fixed (1) I saw that the plugin triggered a follow up error. So I added the code to create the empty Jar, which is the hacky bit. At that point I thought that there are probably more plugins (or build configurations) that may cause this situation.

I looked again at the original reproducer from #15 and reproduced the problem from back then. Then I updated the org.springframework.boot to the latest version - 3.1.5 (including updating Java version and Gradle as required).

After that, problem (2) was gone.

What I will do is keep the check if the files exists (1) but remove creation of the empty Jar (2). With this change, the reproducer here does not have the Quarkus issue anymore.

@rteabeault
Copy link

rteabeault commented Nov 17, 2023

Thanks @jjohannes! Any idea on when a new release with this will be available?

@jjohannes
Copy link
Member

This is now released in 1.6.

@jjohannes
Copy link
Member

Today I discovered this issue in Gradle: gradle/gradle#27372

Which you may hit if you combine this plugins with other plugins that uses the Configuration.getElements() functionality.

In some cases, it is fine to disable this plugins functionality for certain "special" configurations:
https://github.com/gradlex-org/extra-java-module-info#how-do-i-deactivate-the-plugin-functionality-for-a-certain-classpath

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants