From a16e03681b164c3a54d9a2a71006305d6af0ec64 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov Date: Sat, 27 Jul 2019 20:35:00 +0300 Subject: [PATCH] Substitute kotlin-reflect in compileOnly configurations too This fixes running IDEA with JPS build. Gradle only uses compileClasspath configurations for compilation. Hence the substitution introduced in 5c99243c107d8897f627f917b0dc81d7f368a4aa affected only compile tasks (without affecting existing POMs). However, Intellij import also looks into compileOnly configurations in order to determine PROVIDED dependencies. Only dependencies, that are present in both compileOnly and compileClasspath confgurations, are considered to have PROVIDED scope. The substitution was replacing kotlin-reflect with kotlin-reflect-api in compileClasspath configuration. CompileOnly configurations still resolved to kotlin-reflect, so a compileOnly dependency to kotlin-reflect would result in kotlin-reflect-api dependency with COMPILE scope in IDEA. This is exactly what happened in 'idea-runner' module, thus breaking running IDEA from JPS build. This change fixes the issue by configuring the same substitution for compileOnly configurations. --- build.gradle.kts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 1cf6ebd3ff0..a9d55b293eb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -759,9 +759,10 @@ fun Project.configureShadowJarSubstitutionInCompileClasspath() { } sourceSets.all { - val compileClasspathConfig = configurations.getByName(compileClasspathConfigurationName) - compileClasspathConfig.resolutionStrategy.dependencySubstitution { - all(::configureSubstitution) + for (configName in listOf(compileOnlyConfigurationName, compileClasspathConfigurationName)) { + configurations.getByName(configName).resolutionStrategy.dependencySubstitution { + all(::configureSubstitution) + } } } }