krakowski / gradle-jextract

Gradle plugin for integrating Project Panama's jextract tool
https://plugins.gradle.org/plugin/io.github.krakowski.jextract
GNU General Public License v3.0
53 stars 10 forks source link

Fix IntelliJ import classpath issue #19

Closed Brownshome closed 8 months ago

Brownshome commented 10 months ago

Fixes #17

This changes the classpath and dependencies-specification interactions with the project to respect the sourceMode setting and sets-up the task dependencies so that they are derived implicitly from the setup.

Brownshome commented 10 months ago

I was unsure about the purpose of the exact purpose of these lines.

// This is necessary since jextract generates a compiled class file containing constants
                        compileClasspath += target.files(jextractTask)
                        runtimeClasspath += target.files(jextractTask)

To my knowledge the sourceset classpath is by default populated from the configuration classpath setup by the dependencies, so this should be redundant. (When I remove it nothing seems to break in my own project in both source and non-source mode).

If that is the case this would be a good oportunity to remove it as it would allow this implementation to be a little cleaner! I've left it in both the source and non-source cases just to be safe atm.

Brownshome commented 10 months ago

I used afterEvaluate here as the dependencies and source-sets need to be adjusted after the sourceMode variable is set. I'm not a particular fan of using afterEvaluate, but it seemed to most pragmatic way to run logic after the sourceMode is set without greatly changing the structure of this plugin.

There are a few other ways I can try if afterEvaluate is to be avoided. (Maybe a useSourceMode() method?)

krakowski commented 8 months ago

Hi @Brownshome,

took me some time to take a look at this, as I was traveling. Sorry!

I just tried out your changes and they work for me. I also tried avoiding afterEvaluate in the beginning and found out about Lazy Configuration, which I used inside this project. Unfortunately, it is not suitable for executing actions based on the evaluated property value.

Since this works for now, I will merge it and push a new version to the Plugin Portal. Thanks a lot for your contribution! :slightly_smiling_face:

krakowski commented 8 months ago

@Brownshome Did you change your GitHub e-mail address in the meantime? The commits in this Pull Request (and in master) are not linked to your account anymore. I think, adding the missing e-mail address in your profile should fix this :slightly_smiling_face:

Brownshome commented 7 months ago

Ah, thanks for the heads up re. the email! I've added the email to my account.