-
Notifications
You must be signed in to change notification settings - Fork 16
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 Java Projects with Dependencies #547
Comments
I talked to @joshtynjala about how the language server works currently.
So, hopefully the language server will automatically detect the dependencies for Maven or Gradle projects. I will plan to get some familiarity with jdt-language-server when I have a chance. On whether build.gradle or pom.xml has precedence:
For Eclipse project files:
I don't think this should be a problem, but I'll keep it in mind. |
I created some example Java applications to test dependencies: Before you open the projects, run the following commands to make sure all of the local repositories are set up. This also shows how to run the applications. If you run the JAR by itself, it gives errors for the dependencies - we will need to revisit this for Build & Run. Maven Example:
Grails Example:
Open all projects in the "maven" directory for Maven, and in the "gradle" directory for Gradle. I found that the Maven dependencies worked properly with the non-sandbox build - I did not see any errors in DependenciesTests1.java. With the App Store build, I got errors for the local repository as expected. However, none of the dependencies worked for Gradle. I saw errors for every external dependency in GradleTest1.java. |
From this page, it looks like build.gradle is checked before pom.xml. Build typesThe server looks for project/build descriptors in order to correctly configure the Java support (compiler level, classpath). The project import mechanism will lookup build descriptors in the following order:
Depending on the project type, some specific behavior can be expected:
The Gradle import is delegade to buildship. I didn't have time to review this thoroughly, but it looks promising. |
I think I figured this out. It seems that for Gradle projects, we need to manually tell Gradle to update the .classpath file. To do this, you need to add the 'eclipse' plugin:
Then you can update the .classpath with:
Once the classpath is updated, the language server needed to be restarted in order to see the changes. Currently this requires me to close and reopen the project, or to restart Moonshine. I see two solutions for this:
I think 1 is preferable unless we think we will need 2 in general. If Moonshine gets an error on "gradle eclipse", it should report "Unable to regenerate classpath for Gradle project. Please check that you have included the 'eclipse' plugin, and verify that your dependencies are correct. The 'eclipse' plugin should also be added to the Java Gradle template. Here are my updated projects: |
From the last discussion with Joel on this,
|
- Added Gradle plugin to Moonshine settings - Added check and update Gradle classpath prior to start language-server to Gradle project (reference #547)
The above needs to be tested with new Gradle project template as template file updated. on macOS until we download Gradle through Moonshine SDK Installer, having downloaded Gradle in a browser may require to remove its extended attributes manually prior test. |
I see in your commit that you have used NativeProcess - please spend some time and describe what I was asking in details in this issue #518. |
Initial Gradle download link added to Moonshine SDK Installer (Moonshine-IDE/Moonshine-SDK-Installer#9) - macOS download link yet to be updated. |
@rat-moonshine and I got this error when testing the App Store build:
The error looks like this:
From my preliminary investigation, I think this is related to how we handle the Gradle daemons. I will create a separate issue for this. |
I couldn't reproduce the results from the above procedure with the non-sandbox build on macOS, but I did notice a separate issue. Currently, Gradle Home is not populated automatically, but "gradle eclipse" runs anyway. This triggers this daemon:
However the Gradle version is wrong in this case - 5.0 instead of 5.4.1. It looks to me like it is using an old instance of Gradle created with the Gradle wrapper, but I don't understand why that shows up here. This behavior may be specific to my workstation. If I set Gradle Home manually then it loads another daemon with the correct version:
|
@piotrzarzycki21 , it looks like JavaImporter does the configuration parsing process for Java project to Moonshine. I also see |
Yes we need, cause ActionScript project like Flex/Royale can be build by Maven. All examples in Royale repository have pom.xml and are working with Maven. |
- Menus under 'Project' are all working now for Gradle project (reference #547)
Added new Gradle "Build Actions" to gradle project settings. Gradle templates adjusted to work with 'gradle eclipse'. I start receiving 'gradle clean build' error after running 'gradle eclipse'. Thanks to @piotrzarzycki21 he suggested how to add
Following menu items are now also working to Gradle project:
Tested gradle build with 2019_05_09__test_java_dependencies.zip example files. Following things I required to add in their
When GradleTest2 and GradleTest3 worked expectedly for me, GradleTest1 terminate by following error (I think this is different bug):
|
From some of my other testing, I noticed that the App Store version of Moonshine is using a different path for the Maven repository:
So, it uses ~/Library/Containers/com.moonshine-ide/Data/.m2/repository instead of ~/.m2/repository. I confirmed that if I run all of the Maven and Gradle commands from my test_java_dependencies demo above in Moonshine, then the language server and build work properly. This will allow the App Store Moonshine to be usable with dependencies, as long as the user remembers to run all Maven commands from Moonshine. However, Build & Run fails for Maven because the JAR does not have all of its dependencies. I can instead run DependenciesTest1 with the "clean package exec:java" Build Actions (this requires additional configuration in pom.xml).
|
…ad of manual file/folder clean (reference #547)
I did some tests to verify the behavior for when the Gradle project did not have the "eclipse" plugin. This works fine for a single project, but I noticed that it seemed to run for all Gradle projects, which gave some confusing results:
|
… replacing queued execution (reference #547)
This should have fixed now. Please, check. |
Do we have anything left to close this issue, @JoelProminic (?) |
Yes, this looks fine. Here is an example of how the message looks when the Eclipse plugin is missing:
|
Here is another way to handle the local JAR dependencies for Gradle. I confirmed that this also worked in Moonshine.
|
In order to properly support real Java projects, we need to make sure that the language server can handle dependencies. Ideally, the dependencies should be configured by the Ant, Maven, or Gradle scripts, but we can use manual configuration if that is not feasible. The dependencies should include:
Another option for populating the dependencies is to import the dependencies from the Eclipse or IntelliJ configuration files. If this is complicated, we can save it for a later release.
The text was updated successfully, but these errors were encountered: