Search code examples
eclipsegradlegradle-eclipse

Why providedCompile dependency gets deployed?


In my build.gradle I have

dependencies {
    ...
    providedCompile 'javax:javaee-web-api:7.0'
}

I imported the project in Eclipse Mars 4.5.0 (I also installed Gradle IDE 3.7.0.201506251228-RELEASE). The Gradle dependencies contain the library and Web App Libraries doesn't. All good so far. But why this library gets deployed into WEB-INF/lib?


Solution

  • This is a known issue with the tooling. The reason for this problem is that Gradle's tooling API does not provide enough information for the IDE to distinguish provided from other dependencies. Therefore it is impossible for the IDE to properly configure the deployment assembly.

    There is a workaround for the problem (as explained in the bug report): a global list of regexps can be defined to exclude specific dependencies from deployment. Go to "Gradle >> WTP" preferences to find it.

    Alternately, you can disable 'Dependency Management' and to try to rely on Gradle's eclipse plugin (i.e. "apply plugin: 'eclipse-wtp'") to generate classpath and deployment assembly. This will probably work better.

    Generally, when using wtp-based projects its best to use a setup with dependency management disabled precisely because of bugs like these.