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 5c99243c10
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.
This commit is contained in:
Alexey Tsvetkov
2019-07-27 20:35:00 +03:00
parent 317c39f27d
commit a16e03681b
+4 -3
View File
@@ -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)
}
}
}
}