Resolve compiler classpath using 'kotlinCompilerClasspath' configuration

#KT-24675 fixed
This commit is contained in:
Alexey Tsvetkov
2018-05-30 01:45:08 +03:00
parent 6fe0829cf8
commit af8b0ffa6d
9 changed files with 57 additions and 11 deletions
@@ -6,4 +6,11 @@ buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
subprojects {
repositories {
mavenLocal()
mavenCentral()
}
}
@@ -8,9 +8,9 @@ buildscript {
}
}
allprojects {
// for test with groovy
subprojects {
repositories {
mavenLocal()
mavenCentral()
}
}
@@ -1 +1,6 @@
apply plugin: 'kotlin'
apply plugin: 'kotlin'
repositories {
mavenLocal()
mavenCentral()
}
@@ -1,7 +1,7 @@
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
@@ -10,6 +10,11 @@ buildscript {
apply plugin: "kotlin"
repositories {
mavenLocal()
mavenCentral()
}
compileKotlin {
kotlinOptions {
languageVersion = "1.0"
@@ -1,9 +1,16 @@
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
subprojects {
repositories {
mavenLocal()
mavenCentral()
}
}
@@ -37,6 +37,7 @@ import java.util.concurrent.Callable
import java.util.jar.Manifest
internal const val PLUGIN_CLASSPATH_CONFIGURATION_NAME = "kotlinCompilerPluginClasspath"
internal const val COMPILER_CLASSPATH_CONFIGURATION_NAME = "kotlinCompilerClasspath"
val KOTLIN_DSL_NAME = "kotlin"
val KOTLIN_JS_DSL_NAME = "kotlin2js"
val KOTLIN_OPTIONS_DSL_NAME = "kotlinOptions"
@@ -337,6 +338,9 @@ internal abstract class AbstractKotlinPlugin(
internal abstract fun buildSourceSetProcessor(project: Project, javaBasePlugin: JavaBasePlugin, sourceSet: SourceSet, kotlinPluginVersion: String): KotlinSourceSetProcessor<*>
override fun apply(project: Project) {
project.configurations.create(COMPILER_CLASSPATH_CONFIGURATION_NAME).defaultDependencies {
it.add(project.dependencies.create("$KOTLIN_MODULE_GROUP:$KOTLIN_COMPILER_EMBEDDABLE:$kotlinPluginVersion"))
}
project.configurations.create(PLUGIN_CLASSPATH_CONFIGURATION_NAME).apply {
// todo: Consider removing if org.jetbrains.kotlin.cli.jvm.plugins.PluginCliParser stops using parent last classloader
isTransitive = false
@@ -42,12 +42,31 @@ const val USING_INCREMENTAL_COMPILATION_MESSAGE = "Using Kotlin incremental comp
const val USING_EXPERIMENTAL_JS_INCREMENTAL_COMPILATION_MESSAGE = "Using experimental Kotlin/JS incremental compilation"
abstract class AbstractKotlinCompileTool<T : CommonToolArguments>() : AbstractCompile(), CompilerArgumentAwareWithInput<T> {
// TODO: deprecate and remove
private fun useCompilerClasspathConfigurationMessage(propertyName: String) {
project.logger.kotlinWarn(
"'$path.$propertyName' is deprecated and will be removed soon. " +
"Use '$COMPILER_CLASSPATH_CONFIGURATION_NAME' " +
"configuration for customizing compiler classpath."
)
}
// TODO: remove
@get:Internal
var compilerJarFile: File? = null
@Deprecated("Use $COMPILER_CLASSPATH_CONFIGURATION_NAME configuration")
set(value) {
useCompilerClasspathConfigurationMessage("compilerJarFile")
field = value
}
// TODO: remove
@get:Internal
var compilerClasspath: List<File>? = null
@Deprecated("Use $COMPILER_CLASSPATH_CONFIGURATION_NAME configuration")
set(value) {
useCompilerClasspathConfigurationMessage("compilerClasspath")
field = value
}
@InputFiles
@PathSensitive(PathSensitivity.RELATIVE)
@@ -60,8 +79,7 @@ abstract class AbstractKotlinCompileTool<T : CommonToolArguments>() : AbstractCo
// a hack to remove compiler jar from the cp, will be dropped when compilerJarFile will be removed
listOf(it) + findKotlinCompilerClasspath(project).filter { !it.name.startsWith("kotlin-compiler") }
}
?: findKotlinCompilerClasspath(project).takeIf { it.isNotEmpty() }
?: throw IllegalStateException("Could not find Kotlin Compiler classpath. Please specify $name.compilerClasspath")
?: project.configurations.getByName(COMPILER_CLASSPATH_CONFIGURATION_NAME).resolve().toList()
protected abstract fun findKotlinCompilerClasspath(project: Project): List<File>
}
@@ -38,9 +38,9 @@ private val KOTLIN_SCRIPT_RUNTIME_EXPECTED_CLASS = "kotlin.script.templates.Anno
private val KOTLIN_SCRIPT_ANNOTATION_EXPECTED_CLASS = "kotlin.script.experimental.annotations.KotlinScript"
private val KOTLIN_JVM_SCRIPT_COMPILER_EXPECTED_CLASS = "kotlin.script.experimental.jvm.JvmScriptCompiler"
private val KOTLIN_REFLECT_EXPECTED_CLASS = "kotlin.reflect.full.KClasses"
private val KOTLIN_MODULE_GROUP = "org.jetbrains.kotlin"
internal const val KOTLIN_MODULE_GROUP = "org.jetbrains.kotlin"
private val KOTLIN_GRADLE_PLUGIN = "kotlin-gradle-plugin"
private val KOTLIN_COMPILER_EMBEDDABLE = "kotlin-compiler-embeddable"
internal const val KOTLIN_COMPILER_EMBEDDABLE = "kotlin-compiler-embeddable"
private val KOTLIN_STDLIB = "kotlin-stdlib"
private val KOTLIN_SCRIPT_RUNTIME = "kotlin-script-runtime"
private val KOTLIN_SCRIPT_COMMON = "kotlin-scripting-common"
+1 -1
View File
@@ -8,7 +8,7 @@ plugins {
dependencies {
runtime(project(":kotlin-stdlib"))
runtime(project(":kotlin-script-runtime"))
runtimeOnly(project(":kotlin-reflect"))
runtime(project(":kotlin-reflect"))
}
noDefaultJar()