Is there some non-obvious way of getting a build.gradle.kts
which doesn’t regularly break when IDEA is updated? I have a project which happens to have a non-standard source layout:
my-kotlin-library
├── build.gradle.kts
└── src
├── main
│ └── MyLibrary.kt
└── test
└── MyLibraryTest.kt
Since I only have Kotlin sources, it makes no sense (to me) to have the more conventional layout with an inserted “kotlin” subdirectory:
my-kotlin-library
├── build.gradle.kts
└── src
├── main
│ └── kotlin
│ └── MyLibrary.kt
└── test
└── kotlin
└── MyLibraryTest.kt
Anyway, my unconventional setup was working fine, and I had a working run configuration which found and ran all my tests … after some weeks, I upgraded IDEA (to 2019.2, I think), along with the plugins I was told were outdated. After this, my tests weren’t found any more! To solve this, I had to add
sourceSets {
main {
java {
srcDir("src/main")
}
}
test {
java {
srcDir("src/test")
}
}
}
to my build.gradle.kts
, and my tests were found again! I’ve no idea why it worked without the sourceSets
definitions before, but suddenly needed them after the upgrade. Never mind. All was OK for a while … but I’ve just upgraded to IDEA 2019.3, and now it tells me the sourceSets
is an unresolved reference! To remove this error, I unaccountably had to insert the<JavaPluginConvention>.
as a prefix to sourceSets
- not sure why that wasn’t needed before. Also, I had to change main
→ "main"
and test
→ "test"
inside the sourceSets
definition. With those changes in place, the project appears to build, but the tests aren’t found, again!
Link to working build.gradle.kts before the IDEA upgrade
Is there something basically wrong with my build.gradle.kts
which causes this constant breakage, or is yak-shaving in this area common? Any help gratefully received.
Regards,
Vinay Sajip