Running gradle project with Tomcat in Eclipse


(simonz) #1

Hello,

I am new to Gralde and trying to convert an existing Maven project to Gradle. I created build.gradle and manage to build from command line. But when I imported it into Eclipse. I am not able to make it the way as with Maven. 1) There is no Gradle Build (as of Maven Build) in Project properties -> Builders. So how could the project autobuild with Gradle when some source code changes. 2) I couldn’t add Gradle project to a Tomcat Server inside Eclipse. It couldn’t find resource to add to Tomcat. While with Maven project, I am able to add it to Tomcat server and run as a web application.

Anything I am missing here?

Thanks, Simon


(René Groeschke) #2

Hello Simon, as a starting point, you should have a look at gradle plugin for eclipse available at https://github.com/SpringSource/eclipse-integration-gradle This plugin provides basic integration of Gradle in the Eclipse IDE. I’m not sure if the plugin covers the features you mentioned above, but the readme.md at the link above contains links to the issue tracker and sts google group to raise feature request and bug reports.

cheers, René


(simonz) #3

René,

I did my research (including looking through the Elcipse plugin) before I post.

What I am asking is very common while developing a java web application using IDE. It would be meaningless if integrating Gradle into IDE and can’t build the project auotomatiically and deploy and test within IDE. I guess I just lack of the knowledge of how-to and hope this forum has someone who gone through this already and would like to share the experience.

We have a list of Java projects some are using Ant while the others are using Maven. I am trying to use Gradle to provide a consistent building tool. To make develops buy in this tool, I have to make the developers feel as comfortable as possible to switch to Gradle. This means, to a minimum, the Gradle should not change the way of their development environment, let alone take away some of the existing convenience.

I would appreciate if you,your team and others in the forum could provide some help. As I go through the Gradle documentations, i believe in this tool and its future.

Thanks, Simon


(Szczepan Faber) #4

Hey Simon,

There is no Gradle Build (as of Maven Build) in Project properties -> Builders. So how could the project autobuild with Gradle when some source code changes.

Gradle’s eclipse plugin does not add any ‘gradle builder’. Our design choice is to use standard java builder for java code (groovy builder for groovy, etc.) inside eclipse so that we can take full advantage of eclipse java compiler, incremental compilation, etc.

I couldn’t add Gradle project to a Tomcat Server inside Eclipse. It couldn’t find resource to add to Tomcat. While with Maven project, I am able to add it to Tomcat server and run as a web application.

If you are building a webapp make sure you apply ‘eclipse-wtp’ plugin instead of ‘eclipse’. ‘eclipse-wtp’ needs to be applied on all projects you want to see in eclipse (e.g. not only ‘war’ projects). Using ‘eclipse-wtp’ should get your project imported to eclipse cleanly.

Hope that helps!


(simonz) #5

Szczepan,

The ‘eclipse-wtp’ solution works. I tried it before and I guess it failed due to that i didn’t re-create the eclipse project and class file.

I swear i saw Gradle Build once in project builders during my desperate searching and trying different examples. I just couldn’t find it any more. But it’s not important now. I can live with Java/Groorvy builders as long as it can do auto build on source changes.

Thanks a lot, Simon