Implement fallback compiler search
This commit is contained in:
+4
@@ -26,6 +26,7 @@ import java.util.*
|
|||||||
fun mapKotlinTaskProperties(project: Project, task: AbstractKotlinCompile<*>) {
|
fun mapKotlinTaskProperties(project: Project, task: AbstractKotlinCompile<*>) {
|
||||||
PropertiesProvider(project).apply {
|
PropertiesProvider(project).apply {
|
||||||
coroutines?.let { task.coroutinesFromGradleProperties = it }
|
coroutines?.let { task.coroutinesFromGradleProperties = it }
|
||||||
|
useFallbackCompilerSearch?.let { task.useFallbackCompilerSearch = it }
|
||||||
|
|
||||||
if (task is KotlinCompile) {
|
if (task is KotlinCompile) {
|
||||||
incrementalJvm?.let { task.incremental = it }
|
incrementalJvm?.let { task.incremental = it }
|
||||||
@@ -67,6 +68,9 @@ internal class PropertiesProvider(private val project: Project) {
|
|||||||
val usePreciseJavaTracking: Boolean?
|
val usePreciseJavaTracking: Boolean?
|
||||||
get() = booleanProperty("kotlin.incremental.usePreciseJavaTracking")
|
get() = booleanProperty("kotlin.incremental.usePreciseJavaTracking")
|
||||||
|
|
||||||
|
val useFallbackCompilerSearch: Boolean?
|
||||||
|
get() = booleanProperty("kotlin.useFallbackCompilerSearch")
|
||||||
|
|
||||||
private fun booleanProperty(propName: String): Boolean? =
|
private fun booleanProperty(propName: String): Boolean? =
|
||||||
property(propName)?.toBoolean()
|
property(propName)?.toBoolean()
|
||||||
|
|
||||||
|
|||||||
+18
-1
@@ -72,6 +72,9 @@ abstract class AbstractKotlinCompileTool<T : CommonToolArguments>() : AbstractCo
|
|||||||
@PathSensitive(PathSensitivity.RELATIVE)
|
@PathSensitive(PathSensitivity.RELATIVE)
|
||||||
override fun getSource() = super.getSource()
|
override fun getSource() = super.getSource()
|
||||||
|
|
||||||
|
@get:Input
|
||||||
|
internal var useFallbackCompilerSearch: Boolean = false
|
||||||
|
|
||||||
@get:Classpath @get:InputFiles
|
@get:Classpath @get:InputFiles
|
||||||
internal val computedCompilerClasspath: List<File>
|
internal val computedCompilerClasspath: List<File>
|
||||||
get() = compilerClasspath?.takeIf { it.isNotEmpty() }
|
get() = compilerClasspath?.takeIf { it.isNotEmpty() }
|
||||||
@@ -79,7 +82,21 @@ abstract class AbstractKotlinCompileTool<T : CommonToolArguments>() : AbstractCo
|
|||||||
// a hack to remove compiler jar from the cp, will be dropped when compilerJarFile will be removed
|
// 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") }
|
listOf(it) + findKotlinCompilerClasspath(project).filter { !it.name.startsWith("kotlin-compiler") }
|
||||||
}
|
}
|
||||||
?: project.configurations.getByName(COMPILER_CLASSPATH_CONFIGURATION_NAME).resolve().toList()
|
?: if (!useFallbackCompilerSearch) {
|
||||||
|
try {
|
||||||
|
project.configurations.getByName(COMPILER_CLASSPATH_CONFIGURATION_NAME).resolve().toList()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
project.logger.error(
|
||||||
|
"Could not resolve compiler classpath. " +
|
||||||
|
"Check if Kotlin Gradle plugin repository is configured in $project."
|
||||||
|
)
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
findKotlinCompilerClasspath(project)
|
||||||
|
}
|
||||||
|
?: throw IllegalStateException("Could not find Kotlin Compiler classpath")
|
||||||
|
|
||||||
|
|
||||||
protected abstract fun findKotlinCompilerClasspath(project: Project): List<File>
|
protected abstract fun findKotlinCompilerClasspath(project: Project): List<File>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user