I’m trying to track down a problem where resources are mysteriously missing from the classpath when running the tests, but this is only occurring for one module. At the moment I haven’t got the foggiest idea how to figure out why this is happening, so I thought I would attack Gradle for one other stupid thing it is doing - the naming of the .iml files. This inconsistency could indirectly be the cause of our problems, so maybe if it’s fixed, the other problem will evaporate?
So here’s what I mean. Take this example top-level project (the project name is also ‘example’, so that is the directory it is in):
group 'org.example'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'idea'
sourceCompatibility = 1.5
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
}
subprojects {
apply plugin: 'java'
apply plugin: 'idea'
}
Subproject in ‘common’:
group 'org.example'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.5
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
}
Subproject in ‘example’:
group 'org.example'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.5
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
}
When I run gradle idea
, it creates three .iml files:
$ find . -name '*.iml'
./common/common.iml
./example/example-example.iml
./example.iml
Why is the one in example not just called example.iml
?
In our real project, the file in example/
is called example.iml
. When we run gradle idea
, we now have both example/example.iml
and example/example-example.iml
. Perhaps this is the cause for our classpath issues when running the tests, but I really have no idea.
This was occurring under 2.7 and is still occurring under 2.8. I initially thought the plugin in IDEA was doing this, but it turns out the command-line tool does it as well, ignoring IDEA itself entirely.