Gradle build module dependencies not working properly

I have a Gradle build file for my web application. That references a bunch of dependencies, most of them external (Spring, Hibernate, other stuff), but many of them our own framework libraries. All of these dependencies are currently Maven builds. So I import all of my Maven projects into my IntelliJ project as Maven modules. Then I import my Gradle project as a Gradle module.

With our existing code base, I do exactly the same thing, except that the web application is an Eclipse project (not Maven, long story). After I do the import, I go into the dependencies for my web project, delete hard references to our own libraries, and replace them with dependencies to the Maven modules in the project. This works great in that case.

This does NOT work great for my Gradle project. I have built all of my Maven dependencies with a "mvn clean install", so I know the most recent versions of the jars are built (and this shouldn't matter, since it should be using the module dependency for the build). But when I run the app under Tomcat 7 and set a breakpoint in the code of one of my dependencies, the line numbering is way off. This indicates that IntelliJ is getting an older version of my code instead of using the module dependency. I've tried deleting the older version of the dependency in the .gradle cache, but then that breaks the library reference to that dependency (even though the module no longer references it, it's still defined in the project). When I click "Refresh External Project", I can see Gradle go out to the Maven server and retrieve the dependency from there. This basically means I need to re-deploy my Maven artifacts every time I make a change, which is unacceptable.

I wouldn't even mind so much if I could re-build my Maven dependencies and then tell IntelliJ's Gradle to refresh the dependencies (e.g. gradle build --refresh dependencies), but I can't figure out how to do that either.

I don't know if this is an issue if all of the modules in the project are also Gradle modules, but I'd really rather not have to put the time into converting them into Gradle projects when they're doing just fine as Maven builds.

I'm really close to just converting my Gradle build into Maven build. We want to use Gradle for our build tool, but the Gradle integration in IntelliJ is proving to be a huge hurdle to overcome. Hopefully someone can tell my I'm just doing something wrong. Any help on this would be greatly appreciated.

1 comment

BTW, meant to add that this is with the latest 13.1.3 EAP IU-135.908 on OS X, but I've seen the same problem with 13.1.2 and previous EAPs.

0

Please sign in to leave a comment.