Use separate configuration for resolving native compiler plugin artifacts

Kotlin/JVM and Kotlin/JS use shaded compiler, but
Kotlin/Native uses non-shaded one.
Serialization plugin was configured to use either shaded or non-shaded
plugin version, because we used one configuration for resolving
compiler plugins.
This change introduces 'kotlinNativeCompilerPluginClasspath' configuration
for resolving Kotlin/Native compiler plugins.
This commit is contained in:
Alexey Tsvetkov
2018-09-21 23:27:05 +03:00
committed by Ilya Matveev
parent affa881421
commit de261df6f5
6 changed files with 26 additions and 18 deletions
@@ -40,6 +40,7 @@ import java.util.concurrent.Callable
import java.util.jar.Manifest
const val PLUGIN_CLASSPATH_CONFIGURATION_NAME = "kotlinCompilerPluginClasspath"
const val NATIVE_COMPILER_PLUGIN_CLASSPATH_CONFIGURATION_NAME = "kotlinNativeCompilerPluginClasspath"
internal const val COMPILER_CLASSPATH_CONFIGURATION_NAME = "kotlinCompilerClasspath"
val KOTLIN_DSL_NAME = "kotlin"
val KOTLIN_JS_DSL_NAME = "kotlin2js"
@@ -55,6 +55,9 @@ abstract class KotlinBasePluginWrapper(
// todo: Consider removing if org.jetbrains.kotlin.cli.jvm.plugins.PluginCliParser stops using parent last classloader
isTransitive = false
}
project.configurations.maybeCreate(NATIVE_COMPILER_PLUGIN_CLASSPATH_CONFIGURATION_NAME).apply {
isTransitive = false
}
// TODO: consider only set if if daemon or parallel compilation are enabled, though this way it should be safe too
System.setProperty(org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY, "true")
@@ -435,7 +435,7 @@ open class KotlinNativeTargetConfigurator(
SubpluginEnvironment
.loadSubplugins(project, kotlinPluginVersion)
.addSubpluginOptions<CommonCompilerArguments>(project, this, compilerPluginOptions)
compilerPluginClasspath = project.configurations.getByName(PLUGIN_CLASSPATH_CONFIGURATION_NAME)
compilerPluginClasspath = project.configurations.getByName(NATIVE_COMPILER_PLUGIN_CLASSPATH_CONFIGURATION_NAME)
}
private fun KotlinNativeCompile.registerOutputFiles(outputDirectory: File) {
@@ -73,11 +73,13 @@ class SubpluginEnvironment(
val pluginId = subplugin.getCompilerPluginId()
project.logger.kotlinDebug { "Loading subplugin $pluginId" }
val artifact = subplugin.getPluginArtifact()
val artifactVersion = artifact.version ?: kotlinPluginVersion
val mavenCoordinate = "${artifact.groupId}:${artifact.artifactId}:$artifactVersion"
project.logger.kotlinDebug { "Adding '$mavenCoordinate' to '$PLUGIN_CLASSPATH_CONFIGURATION_NAME' configuration" }
project.dependencies.add(PLUGIN_CLASSPATH_CONFIGURATION_NAME, mavenCoordinate)
subplugin.getPluginArtifact().let { artifact ->
project.addMavenDependency(PLUGIN_CLASSPATH_CONFIGURATION_NAME, artifact)
}
subplugin.getNativeCompilerPluginArtifact()?.let { artifact ->
project.addMavenDependency(NATIVE_COMPILER_PLUGIN_CLASSPATH_CONFIGURATION_NAME, artifact)
}
val subpluginOptions =
subplugin.apply(project, kotlinTask, javaTask, variantData, androidProjectHandler, kotlinCompilation)
@@ -92,4 +94,11 @@ class SubpluginEnvironment(
return appliedSubplugins
}
private fun Project.addMavenDependency(configuration: String, artifact: SubpluginArtifact) {
val artifactVersion = artifact.version ?: kotlinPluginVersion
val mavenCoordinate = "${artifact.groupId}:${artifact.artifactId}:$artifactVersion"
project.logger.kotlinDebug { "Adding '$mavenCoordinate' to '$configuration' configuration" }
project.dependencies.add(configuration, mavenCoordinate)
}
}