testCompile dependencies not in Idea Compile scope

I have a multi-project Java and Scala build.

I have specified some things, e.g. Hamcrest, to be testCompile dependencies of my sub-project but when I run the idea task to generate my idea project these testCompile dependencies are marked as runtime and not compile scope in Idea. Consequently the compile fails, the only way I can get around this is to specify them as compile dependencies but I dont really want to do that because they are not needed by the published jar.

I think the offending code is this in ideaPlugin.groovy

private def configureIdeaModuleForJava(Project project) {

project.ideaModule {

sourceDirs = project.sourceSets.main.allSource.sourceTrees.srcDirs.flatten()

testSourceDirs = project.sourceSets.test.allSource.sourceTrees.srcDirs.flatten()

outputDir = project.sourceSets.main.classesDir

testOutputDir = project.sourceSets.test.classesDir

def configurations = project.configurations

scopes = [

COMPILE: [plus: [configurations.compile], minus: []],

RUNTIME: [plus: [configurations.runtime], minus: [configurations.compile]],

TEST: [plus: [configurations.testRuntime], minus: [configurations.runtime]]

]

}

}

I am using Gradle 1.6

testCompile dependencies should be mapped to the idea test scope. In the snippet of the IdeaPlugin above you can see that the testRuntime configuration (which extends testCompile) is added to the scope TEST of Idea. do you have declared any custom configurations? can you provide a selfcontained example that demos your issue?

cheers,

René

Hmm, yes I have custom test tasks/configurations, these extendFrom testCompile but the dependencies are specified as testCompile in my build,gradle. I had to manually add to the testSourcesDir in my code because the sourceSet for these is not test but testUtil or testUnit

I will try and split the code out into a stand along project so I can post here, however the problem I have is anonymising the code to remove anything company specific, the company I am currently working at is quite particular about not being identified.

We have a custom test related source set in our gradle suprojects. maybe in the meantime you can have a look on our setup at https://github.com/gradle/gradle/blob/master/gradle/integTest.gradle. maybe that helps you too.

cheers, René

Yes, that looks like something I can work with. The scopes setting in you ivy module is the thing I am missing, I had tried several ways of doing that but could not get it to work.

I will add that in how you have it and see if the problem gets solved.

Thanks

Added in and the problem is solved.

Thanks for your help