From 110a9ff60009b7f801c593b99e91c4ce7639a4de Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Wed, 6 Dec 2017 15:24:36 +0300 Subject: [PATCH] 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. --- buildSrc/src/main/kotlin/artifacts.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/artifacts.kt b/buildSrc/src/main/kotlin/artifacts.kt index 99372a756c9..e4857d13ffb 100644 --- a/buildSrc/src/main/kotlin/artifacts.kt +++ b/buildSrc/src/main/kotlin/artifacts.kt @@ -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("testsJar") { + return task(MAGIC_DO_NOT_CHANGE_TEST_JAR_TASK_NAME) { dependsOn("testClasses") pluginManager.withPlugin("java") { from(project.the().sourceSets.getByName("test").output)