Gradle and Eclipse with EAR Project not working as expected

I am new to Gradle but I totally like it, except for the Eclipse integration… Before I used Maven and the build/project config was just as with Gradle, easy to get working outside of eclipse but a pain in the ass to make eclipse understand what I want.

I am using Eclipse 4.2 SR1 with Gradle 1.4 on Windows 7. Maybe unrelated but I try to deploy to JBoss AS 7.

I have a root directory in which I have a settings.gradle to include subprojects and a build.gradle to define basic stuff like library versions etc.

Then there are some normal java projects which have dependencies and also a web project. The problem with the web project within eclipse is, that it includes the libraries in WEB-INF/lib even though I used providedCompile for these dependencies. The Gradle build does fine, but Eclipse can’t handle that. Subsequently I have an enterprise archive that should add the previously providedCompile’d jars to EAR/lib which again works fine when building with gradle command line tool but not within eclipse. In Eclipse I get all the dependencies added to the root directory of the EAR and also into the EAR/lib directory.

Anyone already had such problems and could help me with that? The described structure with the gradle files can be found on http://pastebin.com/Y5YhdW8y

Also the question on stackoverflow: http://stackoverflow.com/questions/14916917/gradle-and-eclipse-with-ear-project

Do you use Gradle STS integration or the Gradle plugins that generate the metadata?

If you use STS then I suspect the problem is that the tooling api does not yet provide the ‘provided’ information to the STS (it’s a missing capability at this stage). STS works around that by letting you generate the eclipse metadata before import (see the checkboxes at project import wizard). I’m not sure how successful this strategy is.

I suggest to use the gradle plugins to generate the IDE metadata and import it into eclipse. Let us know how it worked for you.

Hope that helps!

Yeah I use the STS integration. I tried to use “gradle cleanEclipse cleanEcipseWtp eclipse eclipseWtp” and then import the Gradle Projects without running any commands before or after the import as offered by the import wizard. Still I can’t get it to work as it should.

Can you try running “gradle cleanEclipse eclipse” and then import the resulting meta into eclipse using the “import an existing project” (e.g. not via sts gradle import)?

At least the web application is as it should be, but the ear is still messed up.

So is this kind of build + eclipse integration going to work anytime soon? I can’t get along with any build tool together with eclipse… I really ask myself how other people do the overlay/skinny war stuff in eclipse with maven/gradle… Why can’t there be just an example of how to do it, or is it just not possible?

I could get this kind of multi module project working with maven, the code can be found here: https://github.com/beikov/maven-multi-module-ear-skinny-war

I would like to be able to achieve the same results with gradle. The build should produce the same results and the project should work within eclipse. I couldn’t find any hints, examples or best practices to actually make it work.

Please help!

Thanks for putting together the example. Do you mind taking stab at fixing the issue and providing a pull request.

Cheers!