Improve performance of KAPT on JDK 17
Getting canonical path is expensive on JDK 17, thus check, whether file is belongs to some folder becomes expensive. In this commit implementation was replaced to a new one based on File.getParent. It gives profit 49seconds-> 500 ms/100k files. Note! Now if there are present two files which are actually links of the same file, they are treated as two different files. #KT-54579 Fixed
This commit is contained in:
+2
-2
@@ -143,8 +143,8 @@ internal open class KaptConfig<TASK : KaptTask>(
|
|||||||
|
|
||||||
//Have to avoid using FileUtil because it is required system property reading that is not allowed for configuration cache
|
//Have to avoid using FileUtil because it is required system property reading that is not allowed for configuration cache
|
||||||
private fun isAncestor(dir: File, file: File): Boolean {
|
private fun isAncestor(dir: File, file: File): Boolean {
|
||||||
val path = file.canonicalPath
|
val path = file.normalize().absolutePath
|
||||||
val prefix = dir.canonicalPath
|
val prefix = dir.normalize().absolutePath
|
||||||
val pathLength = path.length
|
val pathLength = path.length
|
||||||
val prefixLength = prefix.length
|
val prefixLength = prefix.length
|
||||||
val caseSensitive = true
|
val caseSensitive = true
|
||||||
|
|||||||
@@ -35,9 +35,8 @@ class KaptPathsTest {
|
|||||||
|
|
||||||
val symlinkToOtherJava = Files.createSymbolicLink(File(tempDir, "Other.java").toPath(), otherJava.toPath()).toFile()
|
val symlinkToOtherJava = Files.createSymbolicLink(File(tempDir, "Other.java").toPath(), otherJava.toPath()).toFile()
|
||||||
val symlinkToNotJava = Files.createSymbolicLink(File(tempDir, "NotJava.java").toPath(), notJava.toPath()).toFile()
|
val symlinkToNotJava = Files.createSymbolicLink(File(tempDir, "NotJava.java").toPath(), notJava.toPath()).toFile()
|
||||||
val symlinkToJavaRootDir = Files.createSymbolicLink(File(tempDir, "java2").toPath(), javaRootDir.toPath()).toFile()
|
|
||||||
|
|
||||||
val javaRoots = listOf(simpleJava, symlinkToOtherJava, symlinkToNotJava, symlinkToJavaRootDir, javaRootDir)
|
val javaRoots = listOf(simpleJava, symlinkToOtherJava, symlinkToNotJava, javaRootDir)
|
||||||
|
|
||||||
val paths = KaptOptions.Builder().apply {
|
val paths = KaptOptions.Builder().apply {
|
||||||
javaSourceRoots.addAll(javaRoots)
|
javaSourceRoots.addAll(javaRoots)
|
||||||
@@ -53,7 +52,7 @@ class KaptPathsTest {
|
|||||||
assertTrue(javaSourceFiles.any { it.toRelativeString(tempDir) == path }) { "Can't find path $path\nAvailable: $available" }
|
assertTrue(javaSourceFiles.any { it.toRelativeString(tempDir) == path }) { "Can't find path $path\nAvailable: $available" }
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(4, javaSourceFiles.size)
|
assertEquals(4, javaSourceFiles.size, "Actual content: ${javaSourceFiles}")
|
||||||
assertContains("Simple.java")
|
assertContains("Simple.java")
|
||||||
assertContains("Other.java")
|
assertContains("Other.java")
|
||||||
assertContains("NotJava.java")
|
assertContains("NotJava.java")
|
||||||
|
|||||||
Reference in New Issue
Block a user