Fix project configuration: avoid adding test jar as library dependency
For some reason gradle processes "testJar" task differently and collects artifacts for it during configuration phase. This helps Idea project configurator understand that there's no need to attach test jar as separate binary library dependency. Having compiled module in dependencies results IDEA finds both compiled and source version of classes. This may cause bad navigation and reindexing.
This commit is contained in:
@@ -36,10 +36,12 @@ fun Project.classesDirsArtifact(): FileCollection {
|
||||
return classesDirs
|
||||
}
|
||||
|
||||
private const val MAGIC_DO_NOT_CHANGE_TEST_JAR_TASK_NAME = "testJar"
|
||||
|
||||
fun Project.testsJar(body: Jar.() -> Unit = {}): Jar {
|
||||
val testsJarCfg = configurations.getOrCreate("tests-jar").extendsFrom(configurations["testCompile"])
|
||||
|
||||
return task<Jar>("testsJar") {
|
||||
return task<Jar>(MAGIC_DO_NOT_CHANGE_TEST_JAR_TASK_NAME) {
|
||||
dependsOn("testClasses")
|
||||
pluginManager.withPlugin("java") {
|
||||
from(project.the<JavaPluginConvention>().sourceSets.getByName("test").output)
|
||||
|
||||
Reference in New Issue
Block a user