Remove unused methods from Gradle plugin
This commit is contained in:
-5
@@ -81,9 +81,4 @@ open class KaptWithKotlincTask : KaptTask(), CompilerArgumentAwareWithInput<K2JV
|
||||
|
||||
private val isAtLeastJava9: Boolean
|
||||
get() = SystemInfo.isJavaVersionAtLeast(9, 0, 0)
|
||||
|
||||
private fun getJavaRuntimeVersion(): String {
|
||||
val rtVersion = System.getProperty("java.runtime.version")
|
||||
return if (Character.isDigit(rtVersion[0])) rtVersion else System.getProperty("java.version")
|
||||
}
|
||||
}
|
||||
-6
@@ -41,12 +41,6 @@ internal fun AbstractCompile.appendClasspathDynamically(file: File) {
|
||||
}
|
||||
}
|
||||
|
||||
// Extends finalizedBy clause so that finalizing task does not run if finalized task failed
|
||||
internal fun Task.finalizedByIfNotFailed(finalizer: Task) {
|
||||
finalizer.onlyIf { this@finalizedByIfNotFailed.state.failure == null }
|
||||
this.finalizedBy(finalizer)
|
||||
}
|
||||
|
||||
fun AbstractCompile.mapClasspath(fn: () -> FileCollection) {
|
||||
conventionMapping.map("classpath", fn)
|
||||
}
|
||||
|
||||
-18
@@ -96,12 +96,6 @@ internal fun findKotlinStdlibClasspath(project: Project): List<File> =
|
||||
internal fun findKotlinScriptRuntimeClasspath(project: Project): List<File> =
|
||||
findKotlinModuleJar(project, KOTLIN_SCRIPT_RUNTIME_EXPECTED_CLASS, KOTLIN_SCRIPT_RUNTIME)
|
||||
|
||||
internal fun findKotlinScriptCommonClasspath(project: Project): List<File> =
|
||||
findKotlinModuleJar(project, KOTLIN_SCRIPT_ANNOTATION_EXPECTED_CLASS, KOTLIN_SCRIPT_COMMON)
|
||||
|
||||
internal fun findKotlinScriptJvmClasspath(project: Project): List<File> =
|
||||
findKotlinModuleJar(project, KOTLIN_JVM_SCRIPT_COMPILER_EXPECTED_CLASS, KOTLIN_SCRIPT_JVM)
|
||||
|
||||
internal fun findKotlinReflectClasspath(project: Project): List<File> =
|
||||
findKotlinModuleJar(project, KOTLIN_REFLECT_EXPECTED_CLASS, KOTLIN_REFLECT)
|
||||
|
||||
@@ -120,18 +114,6 @@ internal fun findToolsJar(): File? {
|
||||
return javacUtilContextClass?.let(::findJarByClass)
|
||||
}
|
||||
|
||||
internal fun findCoroutinesClasspath(): List<File> {
|
||||
val classLoader = Thread.currentThread().contextClassLoader
|
||||
val prefix = "kotlinx." // because shadow plugin rewrites strings too, so the fqn should be constructed on runtime
|
||||
val clazz = try {
|
||||
classLoader.loadClass(prefix + "coroutines.experimental.BuildersKt")
|
||||
} catch (e: ClassNotFoundException) {
|
||||
null
|
||||
} ?: return emptyList()
|
||||
|
||||
return (findJarByClass(clazz))?.let { listOf(it) } ?: emptyList()
|
||||
}
|
||||
|
||||
private fun findJarByClass(klass: Class<*>): File? {
|
||||
val classFileName = klass.name.substringAfterLast(".") + ".class"
|
||||
val resource = klass.getResource(classFileName) ?: return null
|
||||
|
||||
-51
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.gradle.utils
|
||||
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.tasks.SourceSetOutput
|
||||
import org.gradle.api.tasks.TaskInputs
|
||||
import org.gradle.api.tasks.TaskOutputs
|
||||
import org.gradle.util.GradleVersion
|
||||
@@ -27,16 +26,6 @@ internal val Task.inputsCompatible: TaskInputs get() = inputs
|
||||
|
||||
internal val Task.outputsCompatible: TaskOutputs get() = outputs
|
||||
|
||||
private val filesMethod by lazy {
|
||||
TaskInputs::class.java.methods.first {
|
||||
it.name == "files" && it.parameterTypes.contentEquals(arrayOf(Array<Any>::class.java))
|
||||
}
|
||||
}
|
||||
|
||||
internal fun TaskInputs.filesCompatible(vararg files: Any) {
|
||||
filesMethod(this, files)
|
||||
}
|
||||
|
||||
private val propertyMethod by lazy {
|
||||
TaskInputs::class.java.methods.first {
|
||||
it.name == "property" && it.parameterTypes.contentEquals(arrayOf(String::class.java, Any::class.java))
|
||||
@@ -47,36 +36,6 @@ internal fun TaskInputs.propertyCompatible(name: String, value: Any) {
|
||||
propertyMethod(this, name, value)
|
||||
}
|
||||
|
||||
private val outputsDirMethod by lazy {
|
||||
TaskOutputs::class.java.methods.first {
|
||||
it.name == "dir" && it.parameterTypes.contentEquals(arrayOf(Any::class.java))
|
||||
}
|
||||
}
|
||||
|
||||
internal fun TaskOutputs.dirCompatible(value: Any) {
|
||||
outputsDirMethod(this, value)
|
||||
}
|
||||
|
||||
private val outputsFilesMethod by lazy {
|
||||
TaskOutputs::class.java.methods.first {
|
||||
it.name == "files" && it.parameterTypes.contentEquals(arrayOf(Array<Any>::class.java))
|
||||
}
|
||||
}
|
||||
|
||||
internal fun TaskOutputs.filesCompatible(vararg value: Any) {
|
||||
outputsFilesMethod(this, value)
|
||||
}
|
||||
|
||||
private val fileMethod by lazy {
|
||||
TaskInputs::class.java.methods.first {
|
||||
it.name == "file" && it.parameterTypes.contentEquals(arrayOf(Any::class.java))
|
||||
}
|
||||
}
|
||||
|
||||
internal fun TaskInputs.fileCompatible(filePath: Any) {
|
||||
fileMethod(this, filePath)
|
||||
}
|
||||
|
||||
private val inputsDirMethod by lazy {
|
||||
TaskInputs::class.java.methods.first {
|
||||
it.name == "dir" && it.parameterTypes.contentEquals(arrayOf(Any::class.java))
|
||||
@@ -87,16 +46,6 @@ internal fun TaskInputs.dirCompatible(dirPath: Any) {
|
||||
inputsDirMethod(this, dirPath)
|
||||
}
|
||||
|
||||
private val setClassesDirMethod by lazy {
|
||||
SourceSetOutput::class.java.methods.first {
|
||||
it.name == "setClassesDir" && it.parameterTypes.contentEquals(arrayOf(Any::class.java))
|
||||
}
|
||||
}
|
||||
|
||||
internal fun SourceSetOutput.setClassesDirCompatible(dirPath: Any) {
|
||||
setClassesDirMethod(this, dirPath)
|
||||
}
|
||||
|
||||
internal fun checkGradleCompatibility(minSupportedVersion: GradleVersion = GradleVersion.version("4.0")) {
|
||||
val currentVersion = GradleVersion.current()
|
||||
if (currentVersion < minSupportedVersion) {
|
||||
|
||||
-3
@@ -16,9 +16,6 @@ internal fun File.isJavaFile() =
|
||||
internal fun File.isKotlinFile(sourceFilesExtensions: List<String>): Boolean =
|
||||
!isJavaFile() && sourceFilesExtensions.any { it.equals(extension, ignoreCase = true) }
|
||||
|
||||
internal fun File.isClassFile(): Boolean =
|
||||
extension.equals("class", ignoreCase = true)
|
||||
|
||||
internal fun File.relativeOrCanonical(base: File): String =
|
||||
relativeToOrNull(base)?.path ?: canonicalPath
|
||||
|
||||
|
||||
-12
@@ -16,20 +16,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.gradle.utils
|
||||
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
|
||||
internal fun Class<*>.getDeclaredFieldInHierarchy(name: String): Field? {
|
||||
val inheritanceChain = generateSequence(this) { it.superclass }
|
||||
return inheritanceChain.map {
|
||||
try {
|
||||
it.getDeclaredField(name)
|
||||
} catch (_: NoSuchFieldException) {
|
||||
null
|
||||
}
|
||||
}.filterNotNull().first()
|
||||
}
|
||||
|
||||
internal inline fun <T> checkedReflection(block: () -> T, onReflectionException: (Exception) -> T): T {
|
||||
return try {
|
||||
block()
|
||||
|
||||
Reference in New Issue
Block a user