Intellij not respecting Gradles dependency scopes in .iml


(Beau Plath) #1

When importing my gradle project into Intellij, the .iml file for a module is forcing all dependencies to be scoped as “Provided” despite their actual scope as specified in gradle (compile and test scopes are present but not reflected in .iml). Problem comes when I try to use run configurations to execute a main method in Java - classNotFound errors pop up because the dependencies are specified as provided (if switched to compile then error stops for that class - but this was manual.

Running on gradle 1.12 with Intellij 13.1.3. Build is not overly complex save the multi-module approach.


(Beau Plath) #2

Forgot to mention the plugin that was providing the “provided” scope. Used the propdeps plugin contributed by Spring. Found the problem, documentation says when configuring the plugin to include the following:

configure(allprojects) {

apply plugin: ‘propdeps’

apply plugin: ‘propdeps-maven’

apply plugin: ‘propdeps-idea’

apply plugin: ‘propdeps-eclipse’ }

However found that when changing the first line to include spaces around allprojects (noticed this subtle difference when working with the cascaing-jdbc github repo which runs gradle) that the correct scopes are specified by the .iml file in intellij. Something still seems fishy for this sensitivity as there are other calls without the spaces that do not exhibit strange behavior.

// Working version, added a space before and after allprojects configure( allprojects ) {

apply plugin: ‘propdeps’

apply plugin: ‘propdeps-maven’

apply plugin: ‘propdeps-idea’

apply plugin: ‘propdeps-eclipse’ }


(Peter Niederwieser) #3

Depending on how exactly you import into IntelliJ, maybe adding the spaces triggered IntelliJ to update the project (because the build script had changed). Other than that, the spaces don’t matter.

PS: The idiomatic syntax is ‘allprojects { … }’. No need for ‘configure’ here.


(Beau Plath) #4

Thanks for the reply.

I actually missed another change that coincided with the spaces - the plugin version (was on 0.0.4 and updated to 0.0.6). I was comparing configs from spring’s readme and from the cascading-jdbc repo and had made both changes at two different sittings, forgot about the first :frowning:

I did actually have the plugin inclusions within allprojects but moved it out to try to match other examples to narrow down the problem. I’ve put it back, with the correct version and all is fine (.iml is correct and provided scope also works).

Thanks again for the reply, the whitespace seemed ridiculous - glad I’m not crazy…