Search code examples
gradleeclipse-wtpbuildship

Eclipse: How can I have gradle dependencies deployed to Tomcat


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).


Solution

  • 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.