I use Eclipse Mars.2 (4.5.2) with Buildship 1.0.14. Gradle version is 2.12.
I import my gradle project into the Eclipse.
No .project
or .classpath
files exist before import. All modules imported successfully. But almost every project with java code has missed dependencies and showing red "X".
If you open a java file with error, you can see that Eclipse can't resolve the import. But if you open imported class by name, it can find it in the other module's dependency.
Gradle -> Refresh project doesn't help.
The necessary dependencies declared in the root build.gradle
in this way:
ext.library = [
swagger: [
[ group: "io.swagger", name: "swagger-annotations", version: "1.5.3" ],
[ group: "io.swagger", name: "swagger-core", version: "1.5.3" ],
[ group: "io.swagger", name: "swagger-jaxrs", version: "1.5.3" ]
]
]
and in the modules I declare it like this:
dependencies {
providedCompile library.swagger
}
When you execute gradle build
from command line or even from Eclipse, the build is successful.
The small project example to reproduce this problem can be found on github (thank to RaGe for participating in that).
Could you help me to resolve this issue with Eclipse?
Answering with reference to the code sample you provided here.
You're not using the war plugin, but instead declaring your own custom configuration called providedCompile
. Gradle and by extension, buildship/eclipse don't know what providedCompile
means. So the dependencies you listed in providedCompile
are not being used as compile time dependencies.
It follows that your import statements become compile time errors - both in eclipse and from gradle commandline with gradle build
You can add providedCompile
to the compile classpath by doing:
sourceSets.main.compileClasspath += [configurations.providedCompile]
If you also add the eclipse plugin to your project, you can modify eclipse compile class path with:
eclipse {
classpath {
plusConfigurations += [configurations.providedCompile]
}
}