1

I'm creating a web project using Gradle (buildship) in Eclipse (WTP). I've put the libraries I need as "implementation" dependencies in my build.gradle, however they are not copied to Tomcat when I try to run the project from within Eclipse. When I build the WAR file (with gradle war), however, all the jar files are there.

I can't find anywhere the solution for this. It's beeing awful to manually (and redundantly) copying every jar and its dependency to WEB-INF/libs just to be able to run the app from Eclipse).

niqueco
  • 2,261
  • 19
  • 39
  • What do you mean with *run the project from within Eclipse*? Any build task aside compilation should be executed in Gradle. Eclipse can invoke any Gradle task with a custom configuration. – Lukas Körfer Aug 11 '18 at 16:37
  • I'm using Eclipse - Gradle integration provided by Buildship. This calls gradle for you and synchronizes everything between Eclipse and Gradle. E.g. when I add dependencies Eclipse recognizes them and the build goes fine. But when I deploy to a Eclipse managed Tomcat instance the deployment is incomplete: the dependencies' jars are note moved and the webapp crashes with "class not found" errors. – niqueco Aug 11 '18 at 16:41
  • Gradle Buildship will automatically include Gradle dependencies into Eclipse, but it won't change the Eclipse functionality. E.g. compilation will still be executed via the Eclipse compiler. You should setup your deployment in Gradle. – Lukas Körfer Aug 11 '18 at 16:46
  • My question would then be: What do I need to setup in Gradle so that I can use Eclipse's WTP deployment to a managed server while developing my app? Right now the app IS being deployed, but the deployment is incomplete. – niqueco Aug 11 '18 at 16:59
  • Did you check the `eclipse-wtp` plugin? Sadly, I'm not familiar with WTP at all. – Lukas Körfer Aug 11 '18 at 17:05
  • Yes, that's what I'm using. That's the gradle plugin that's failing me here. – niqueco Aug 11 '18 at 17:09

2 Answers2

3

I've found a workaround here: https://github.com/eclipse/buildship/issues/496

It's adding this to build.gradle:

eclipse {
    wtp {
        component {
            libConfigurations += [configurations.runtimeClasspath]
        }
    }
}

With this everything gets properly deployed.

UPDATE!

Gradle 5.3 has just been released and includes a fix for this issue and the hack above is not needed anymore.

niqueco
  • 2,261
  • 19
  • 39
2

The only thing that worked for me was changing

dependencies {
    implementation group: 'org.projectlombok', name: 'lombok', version: '1.18.4'
}

too

dependencies {
    compile group: 'org.projectlombok', name: 'lombok', version: '1.18.4'
}