-
Notifications
You must be signed in to change notification settings - Fork 174
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
Support Jigsaw projects #658
Comments
Thanks for taking the time to investigate how to make it work in Eclipse! Gradle doesn't provide much support for Jigsaw at this point out of the box. We have an experimental plugin that you can use in the meantime. Your configuration above should probably be added to that plugin. A pull request would be welcome! |
Upon further testing I encountered some issues and inconsistencies in the way buildship handles this. For some reason it broke overnight 😕. I'm still investigating, but this is what I've got so far: Java 8The following configuration makes everything work perfectly as intended: eclipse {
classpath {
file {
whenMerged {
entries.findAll { isSource(it) && isTestScope(it) }.each { it.entryAttributes['test'] = 'true' }
entries.findAll { isLibrary(it) && isTestScope(it) }.each { it.entryAttributes['test'] = 'true' }
}
}
}
}
boolean isLibrary(entry) { return entry.properties.kind.equals('lib') }
boolean isTestScope(entry) { return entry.entryAttributes.get('gradle_used_by_scope').equals('test'); }
boolean isSource(entry) { return entry.properties.kind.equals('src'); } Although technically not required to make things work, I think it's still wise to put this in (it can't do any harm as far as I know). Java 9What does work:
This is where things start to break apartUsing the same configuration as above.
Things I still have to look into
SummaryThe core issue is that buildship doesn't know the |
That property is added by a
This is intentional. Everything can be configured in the |
Running
Importing the project into eclipse outputs:
|
@HoldYourWaffle If I import the project with Gradle 4.4+ into Eclipse then the output is:
The project contains the wrapper executable ( |
There was indeed some weird stuff going on with my wrapper, no idea how that happened and why it continued on fresh projects. Doing some investigation on java 9 configuration for eclipse again, stuff is being really weird and I have no idea why. It's like the module flag suddenly has no meaning. Stuff that worked before just magically broke for some reason although I'll need to investigate further. |
Alright I think I've sorted this out now.
That's all the configuration that's necessary to get a working Java 9 Jigsaw project inside eclipse. This works perfect concerning the scope of buildship.
I have literally no idea how to fix this or what causes it. Test libraries are on the classpath like eclipse asked so I'm not even sure this is a buildship issue. Any help would be greatly appreciated 😄 |
Can you update your sample project so that it contains your latest findings? Maybe the Eclipse Java9 support doesn't play nicely with the Buildship classpath customization. |
I have updated my sample project. |
Any update on this? |
Isn't this something that has to be fixed in the Gradle eclipse plugin? |
Well..... yeah. |
We are at eclipse buildship. That is why I asked. https://github.com/gradle/gradle/blob/master/subprojects/ide/src/main/java/org/gradle/plugins/ide/eclipse/EclipsePlugin.java Is there an reported issue on the Eclipse Plugin project for this problem? I can't find any. |
Damn you just blew my mind. |
From what I understand the EclipsePlugin under gradle is to handle things that are "one-off" (i.e. I use it to ignore warnings on generated source folders). It's not meant to be full support for Gradle in Eclipse. Buildship should be handling this classpath/module stuff by default without any major modifications to the gradle EclipsePlugin. So while the fix @HoldYourWaffle found is done through the GradlePlugin, the proper place for the fix is to get it done in Buildship. |
Any news on this? Since #708 was closed as a dupe of this. I concur with @johnjaylward ; the eclipse-gradle-plugin is not included in any of my gradle-projects, but that should not stop buildship from working with modular java? |
Really hope a fix is coming soon. I have begun using Buildship with gradle instead of the Eclipse plugin, but it dows not work with Java 9+. Everytime the build configuration change I have to move "Project and External Dependencies" to Classpath to Modulepath manually. |
Changing the title, as this is not related to "Java 9", but jigsaw. There's no short-term plan to work on jigsaw support, so please don't hold your breath.
Nope, everything is done in Gradle's EclipsePlugin, Buildship just gets the data from there. Buildship does not do any significant work itself. It automatically applies the EclipsePlugin to your build if you haven't yourself. To properly support Jigsaw, that support has to be built into Gradle first. |
@oehme Thank you, this made this alittle clearer for me at least. Could we just close this then, and redirect our efforts to the gradle-github? |
It'll still need some work on Buildship to take the additional information into account once Gradle provides it, so I'd leave this open. |
Gradle 7 has improved support for JPMS. Are there plans to work on this issue in buildship? This is a blocker for projects whose maintainers are (rightfully) reluctant to add module descriptors due to the lack of tooling support. |
I have problem importing the controlsfx project I use the "partial fix" (move deps from classpath to modulepath, kudos eclipse team) but still other parts need possible the MacOSX x64 |
Importing a java 9 project without any additional configuration simply doesn't work. Certain attributes have to be set on several classpath entries to make it work:
src/test/java
source folder andtestCompile
-scoped dependencies have to be marked as 'tests' (this does not seem to work correctly in the latest Eclipse Oxygen as of writing, it works perfectly in Photon 20180202-1214)I currently use the following workaround in all my java 9 projects to generate a fully-functional (as far as I've tested) Java 9 eclipse project:
I don't know enough about gradle to be sure the methods at the bottom work for every use-case, they worked fine for me 🤷♂️
Some background information on the test configuration from the eclipse bugtracker
This configuration seems pretty trivial to me, I suggest buildship automatically does this for you (if that doesn't break compatability with java 8 in some way) so you don't have to clutter your build files with trivial configuration.
I'm sorry if my way of writing seems a bit aggressive, I'm way too tired after figuring this out for several hours 😅
The text was updated successfully, but these errors were encountered: