I heard in the Buildship Bug Tracker, that the Eclipse WTP support should have been greatly improved with Gradle 3.
Now I wanted to play a little with Gradle 3.0-milestone-2, Eclipse NEON and Buildship 1.0.16.
I created a folder and some files by hand and tried the Buildship importer.
The current result is not, what’s expected but I hope to get support here, to publish the idea for everybody.
I have uploaded a new version to the GitHub repo named above.
At the moment, I test with Eclipse Neon, BuildShip 1.0.21 and Gradle 3.2.
All above steps are now working out of the box for a web project, that does not need files from another parallel project.
The new test case covers a Test class, that is written in the API project which is used in the Web project.
After import using BuildShip all projects are in eclipse and look fine. The Web project has correct facets. The only thing I wonder is why the Eclipse facet XML config contains the jst.web 2.4 in addition and why the facets from Gradle are fixed.
Within Eclipse the Web project has a dependency on the API project and code completion is working fine.
If I now start the Web project on my local Tomcat from inside Eclipse, it starts without any error.
The Controller is available and besides it is not completely correct, it’s working fine.
Then I added the following lines to the StartController
Test t = new Test();
System.out.println("Test:" + t.getName());
If the helloWorld method is called, a ClassNotFoundException is thrown because of de.mbur.audit.api.Test class.
The reason? the API project is not deployed to the Tomcat.
Now I changed the API project within Eclipse. I converted it to faceted form, set Java to 1.8 and checked Utility Module.
Eclipse now deployed also the API project to the Tomcat.
So what do I which/expect from BuildShip/Gradle?
It would be great if one can set up facets also if one don’t use eclipse-wtp, because this would enable jst.web also.
Even after running cleanEclipse? The eclipse tasks are currently adding things, but not removing stuff. You currently need to clean explicitly. The reason was to allow users to manually tweak things if necessary. With Buildship 2.0 we’ll clean those files automatically and let the user do adjustments in the build.gradle file instead.
We can’t remove the whole .settings folder because it contains stuff that we did not create. The same is true for the bin folder. Out of the box, cleanEclipse only removes what eclipse generates. You can of course adjust this to your liking.
Since I’m not a WTP user I don’t know what the effect of these is. I assume that we decided to go with a relatively small number of facets and let the user decide which others to add. I’m very open to suggestions what the default behavior for each kind of project should be.
This has nothing to do with cleanEclipse. There are no Eclipse files. It happens during a fresh first import into Eclipse using BuildShip. After this import the facet config file contains two jst.web entries. The one that was specified in the build.gradle (3.1) and the default one (2.4)
Got that. How would I configure this additional behaviour in the build.gradle?
This elements of an Eclipse Web project are no matter of additional facets. As I said. They appear automatically when I use Eclipse to enabled the Dynamic Web Module facet. And it does not matter if I set it to version 2.4, 3.0 or 3.1.
Also if I tried this build.gradle
I also don’t know a way to change the project layout in eclipse. As fare as I know, it is done, when activating the facet for Dynamic Web Module.
I did some tests and compared two identical instances of the same project in different folders and the files generated by BuildShip and generated by Eclipse are different at many points…
Left side is BuildShip, right side is from Eclipse
.classpath (I’m not allowed to post more then one image)
img src="/uploads/default/original/2X/6/631c35c24ee0fa40f9640c922ff2266003c80037.jpg" width=“690” height=“24”
.settings\org.eclipse.wst.common.component (I’m not allowed to post more then one image)
img src="/uploads/default/original/2X/b/b62f5682ca019a4119e1ecb21f5f5b446643fdc8.jpg" width=“690” height=“44”
.settings\org.eclipse.wst.common.project.facet.core.xml already mentioned
There are additional files on the Eclipse only side. But they do not seem to matter.
After dozens of Gralde Imports and project deletions from Eclipse and cleanEclipse and Imports of Existing Projects into Workspace, I thing it’s the project facet only, that corrupts it.
The current build.gradle
change org.eclipse.wst.common.project.facet.core.xml by deleting the wrong entry installed facet=“jst.web” version=“2.4”/
change .project by adding the missing nature org.eclipse.wst.jsdt.core.jsNature
reimporting the Project using Existing Projects into Workspace
Now the Project Layout looks nearly correct.
The duplicate facet is interesting, I’ll have a look at that. It might be added automatically when the nature is added.
Every Delete task can be configured to delete additional directories.
Isn’t it already the case that BuildShip is adding more to the Gradle project handling? When I run gradle eclipse from command line the result is different then the result of BuildShip.
Tell me, if you need my support.
Sorry I don’t know how to “overwrite” or enhance cleanEclipse to use this deletion but I’ll look into the documentation… Thank you.
The result is the same except that we put dependencies in a container to make the .classpath file portable. We don’t do any special handling and don’t intend to add that. The model should be correctly handled in Gradle.
The duplicate facet problem is probably related to this issue. A fix has been implemented and will be available in the Buildship 2.0 release. In the meanwhile, would you mind trying out our latest 2.0 development snapshot and see if works better for you? You’ll find the update sites here.
@st_oehme I changed the cleanEclipse Task when we talked last time but then recognized that this is a problem.
So no, there are no additional deletions anymore.
For the deletion purpose I created a new Task:
Is it possible that a task, that is named cleanEclipseCustom is called by Gradle/BuildShip when the Task cleanEclipse ist called?
After removing my custom clean task completely the .settings folder are not deleted any more. In addition I got a Update for BuildShip 2 today, that also may be responsible for the fix.
With BuildShip 2 the wrong jst.web entry is still there and the project is still not correct…