Have imported Gradle project into eclipse, but strange compilation errors?

If anyone can assist me here, I’d be most grateful as I am about to throw my computer out of the window. I downloaded the Jenkins IVY Plugin code from here as I need to debug it for work. https://github.com/jenkinsci/ivy-plugin.git

Running gradle from the command line works fine and it builds the ivy plugin jar file. I imported the project into eclipse and was able to execute the gradle tasks in eclipse without any issues. The problem I am facing is that the source files in the package explorer are littered with build errors. When I open one of the source files the imports are underlined with the error “Only a type can be imported. XXXX resolves to a package” If I do a CTRL + SHIFT + T the class is found and it resides in a jar file that resides under the ‘Project and External Dependencies’. A quick check of the build path shows that ‘Project and External Dependencies’ is listed under ‘Libraries’ and the class that is listed under the failed import resides in the jar and then should be on the build path.

I have searched google for the error, but it only seems applicable to JSP files and not Java source files.

I have tried closing, cleaning, refreshing gradle project, but to no avail.

Works for me with Eclipse Neon. I imported it as a Gradle project. Saw that it was missing some generated sources, so I ran the assemble taks and then triggered another Gradle refresh to pick up the new generated source folders. Worked fine from there.

Thanks for the reply. I have just deleted the eclipse project and followed the steps you mention, but still I get the fictitious errors in the Java source view, eg “Only a type can be imported. hudson.model.AbstractBuild resolves to a package” that’s just one of many.

What is very strange is that if I do a clean in eclipse, eclipse is compiling the source code without any problems as I can see the output in the bin folder for the classes marked with errors. Never encountered these type of errors before.

I have done a screen print of eclipse, just to show what I am talking about.

https://c1.staticflickr.com/9/8060/28503406264_de0de7f445_h.jpg

I just cloned the repo but yes, a simple Gradle import will do.

Are you using the gradle wrapper that is packaged inside of the zip file?

I suspect the issue is not with gradle, but a subtle problem with eclipse Neon. I might delete my eclipse install and start again.

Yes this does not seem Gradle specific.

Not sure what you are doing differently, but I have just deleted and reinstalled eclipse Neon which has gradle buildship included. Reimported the gradle project by right mouse clicking and selecting import -> gradle project. I then ran gradle assemble followed by a ‘Refresh Gradle Project’

So as to avoid wasting each other’s time. When importing the Gradle project are you using the gradle wrapper that sits in the root of the ivy project you are installing and are you adding the project to a project set?

Just trying to understand why you do not get the errors I get in the image posted earlier.

I’m using the wrapper and an otherwise empty workspace, no workingset.

Thanks. It is eclipse. I use 4.3 Kepler at work and I imported the gradle project without any issue what so ever this morning. Very strange why Neon installed on my home machine is not happy.