Don't call File.getCanonicalPath in KGP

Relates to KT-54579.
This commit is contained in:
Andrey Uskov
2022-11-23 16:41:21 +03:00
committed by teamcity
parent ca8f234f28
commit 41ff283856
27 changed files with 50 additions and 50 deletions
@@ -23,7 +23,7 @@ abstract class ICReporterBase(private val pathsBase: File? = null) : ICReporter
} }
protected fun relativizeIfPossible(files: Iterable<File>): List<File> = protected fun relativizeIfPossible(files: Iterable<File>): List<File> =
files.map { it.relativeOrCanonical() } files.map { it.relativeOrAbsolute() }
protected fun pathsAsString(files: Iterable<File>): String = protected fun pathsAsString(files: Iterable<File>): String =
relativizeIfPossible(files).map { it.path }.sorted().joinToString() relativizeIfPossible(files).map { it.path }.sorted().joinToString()
@@ -31,6 +31,6 @@ abstract class ICReporterBase(private val pathsBase: File? = null) : ICReporter
protected fun pathsAsString(vararg files: File): String = protected fun pathsAsString(vararg files: File): String =
pathsAsString(files.toList()) pathsAsString(files.toList())
protected fun File.relativeOrCanonical(): File = protected fun File.relativeOrAbsolute(): File =
pathsBase?.let { relativeToOrNull(it) } ?: canonicalFile pathsBase?.let { relativeToOrNull(it) } ?: normalize().absoluteFile
} }
@@ -104,7 +104,7 @@ open class IncrementalJvmCache(
className in multifileFacadeToParts className in multifileFacadeToParts
override fun getClassFilePath(internalClassName: String): String { override fun getClassFilePath(internalClassName: String): String {
return toSystemIndependentName(File(outputDir, "$internalClassName.class").canonicalPath) return toSystemIndependentName(File(outputDir, "$internalClassName.class").normalize().absolutePath)
} }
fun saveModuleMappingToCache(sourceFiles: Collection<File>, file: File) { fun saveModuleMappingToCache(sourceFiles: Collection<File>, file: File) {
@@ -126,7 +126,7 @@ class FileAgeComparator : Comparator<File> {
leftTS == 0L || rightTS == 0L -> 0 // cannot read any file timestamp, => undecidable leftTS == 0L || rightTS == 0L -> 0 // cannot read any file timestamp, => undecidable
leftTS > rightTS -> -1 leftTS > rightTS -> -1
leftTS < rightTS -> 1 leftTS < rightTS -> 1
else -> compareValues(left.canonicalPath, right.canonicalPath) else -> compareValues(left.normalize().absolutePath, right.normalize().absolutePath)
} }
} }
} }
@@ -1063,7 +1063,7 @@ class CompileServiceImpl(
} }
daemon.scheduleShutdown(true) daemon.scheduleShutdown(true)
} catch (e: Throwable) { } catch (e: Throwable) {
log.info("Cannot connect to a daemon, assuming dying ('${runFile.canonicalPath}'): ${e.message}") log.info("Cannot connect to a daemon, assuming dying ('${runFile.normalize().absolutePath}'): ${e.message}")
} }
} }
} }
@@ -527,7 +527,7 @@ class CompileServiceServerSideImpl(
daemon.scheduleShutdown(true) daemon.scheduleShutdown(true)
log.fine("other : SHUTDOWN_OK") log.fine("other : SHUTDOWN_OK")
} catch (e: Throwable) { } catch (e: Throwable) {
log.info("Cannot connect to a daemon, assuming dying ('${runFile.canonicalPath}'): ${e.message}") log.info("Cannot connect to a daemon, assuming dying ('${runFile.normalize().absolutePath}'): ${e.message}")
} }
} }
} }
@@ -37,7 +37,7 @@ class BuildReportICReporter(
icLogLines.add("Compile iteration:") icLogLines.add("Compile iteration:")
for (file in sourceFiles) { for (file in sourceFiles) {
val reason = recompilationReason[file]?.let { " <- $it" } ?: "" val reason = recompilationReason[file]?.let { " <- $it" } ?: ""
icLogLines.add(" ${file.relativeOrCanonical()}$reason") icLogLines.add(" ${file.relativeOrAbsolute()}$reason")
} }
recompilationReason.clear() recompilationReason.clear()
} }
@@ -80,7 +80,7 @@ internal class BuildReportICReporterAsync(
icLogLines.add("Compile iteration:") icLogLines.add("Compile iteration:")
for (file in sourceFiles) { for (file in sourceFiles) {
val reason = recompilationReason[file]?.let { " <- $it" } ?: "" val reason = recompilationReason[file]?.let { " <- $it" } ?: ""
icLogLines.add(" ${file.relativeOrCanonical()}$reason") icLogLines.add(" ${file.relativeOrAbsolute()}$reason")
} }
recompilationReason.clear() recompilationReason.clear()
} }
@@ -435,7 +435,7 @@ abstract class IncrementalCompilerRunner<
dirtySources.addAll(compiledSources) dirtySources.addAll(compiledSources)
allDirtySources.addAll(dirtySources) allDirtySources.addAll(dirtySources)
val text = allDirtySources.joinToString(separator = System.getProperty("line.separator")) { it.canonicalPath } val text = allDirtySources.joinToString(separator = System.getProperty("line.separator")) { it.normalize().absolutePath }
dirtySourcesSinceLastTimeFile.writeText(text) dirtySourcesSinceLastTimeFile.writeText(text)
@@ -23,7 +23,7 @@ import java.io.File
object FileSnapshotExternalizer : DataExternalizer<FileSnapshot> { object FileSnapshotExternalizer : DataExternalizer<FileSnapshot> {
override fun save(out: DataOutput, value: FileSnapshot) { override fun save(out: DataOutput, value: FileSnapshot) {
out.writeUTF(value.file.canonicalPath) out.writeUTF(value.file.normalize().absolutePath)
out.writeLong(value.length) out.writeLong(value.length)
out.writeInt(value.hash.size) out.writeInt(value.hash.size)
out.write(value.hash) out.write(value.hash)
@@ -50,10 +50,10 @@ class KotlinDirtySourceFilesHolder(
*/ */
internal fun _markDirty(file: File, root: JavaSourceRootDescriptor) { internal fun _markDirty(file: File, root: JavaSourceRootDescriptor) {
val isCrossCompiled = root is KotlinIncludedModuleSourceRoot val isCrossCompiled = root is KotlinIncludedModuleSourceRoot
val old = _dirty.put(file.canonicalFile, KotlinModuleBuildTarget.Source(file, isCrossCompiled)) val old = _dirty.put(file.normalize().absoluteFile, KotlinModuleBuildTarget.Source(file, isCrossCompiled))
check(old == null || old.isCrossCompiled == isCrossCompiled) { check(old == null || old.isCrossCompiled == isCrossCompiled) {
"`${file.canonicalFile}` already marked as dirty: " + "`${file.normalize().absoluteFile}` already marked as dirty: " +
"old is cross compiled: ${old!!.isCrossCompiled}, " + "old is cross compiled: ${old!!.isCrossCompiled}, " +
"new is cross compiled: $isCrossCompiled" "new is cross compiled: $isCrossCompiled"
} }
@@ -400,8 +400,8 @@ class KotlinJvmModuleBuildTarget(kotlinContext: KotlinCompileContext, jpsModuleB
} }
callback.associate( callback.associate(
FileUtil.toSystemIndependentName(output.outputFile.canonicalPath), FileUtil.toSystemIndependentName(output.outputFile.normalize().absolutePath),
sourceFiles.map { FileUtil.toSystemIndependentName(it.canonicalPath) }, sourceFiles.map { FileUtil.toSystemIndependentName(it.normalize().absolutePath) },
ClassReader(output.outputClass.fileContents) ClassReader(output.outputClass.fileContents)
) )
} }
@@ -33,7 +33,7 @@ class FilesSubpluginOption(
key: String, key: String,
val files: Iterable<File>, val files: Iterable<File>,
val kind: FilesOptionKind = FilesOptionKind.INTERNAL, val kind: FilesOptionKind = FilesOptionKind.INTERNAL,
lazyValue: Lazy<String> = lazy { files.joinToString(File.pathSeparator) { it.canonicalPath } } lazyValue: Lazy<String> = lazy { files.joinToString(File.pathSeparator) { it.normalize().absolutePath } }
) : SubpluginOption(key, lazyValue) { ) : SubpluginOption(key, lazyValue) {
constructor( constructor(
@@ -41,7 +41,7 @@ class FilesSubpluginOption(
files: List<File>, files: List<File>,
kind: FilesOptionKind = FilesOptionKind.INTERNAL, kind: FilesOptionKind = FilesOptionKind.INTERNAL,
value: String? = null value: String? = null
) : this(key, files, kind, lazy { value ?: files.joinToString(File.pathSeparator) { it.canonicalPath } }) ) : this(key, files, kind, lazy { value ?: files.joinToString(File.pathSeparator) { it.normalize().absolutePath } })
} }
class CompositeSubpluginOption( class CompositeSubpluginOption(
@@ -347,12 +347,13 @@ internal open class GradleCompilerRunner(
kotlinTask.abiSnapshotFile.get().asFile kotlinTask.abiSnapshotFile.get().asFile
) )
val jarTask = project.tasks.findByName(target.artifactsTaskName) as? AbstractArchiveTask ?: continue val jarTask = project.tasks.findByName(target.artifactsTaskName) as? AbstractArchiveTask ?: continue
jarToModule[jarTask.archivePathCompatible.canonicalFile] = module jarToModule[jarTask.archivePathCompatible.normalize().absoluteFile] = module
if (target is KotlinWithJavaTarget<*, *>) { if (target is KotlinWithJavaTarget<*, *>) {
val jar = project.tasks.getByName(target.artifactsTaskName) as Jar val jar = project.tasks.getByName(target.artifactsTaskName) as Jar
jarToClassListFile[jar.archivePathCompatible.canonicalFile] = target.defaultArtifactClassesListFile.get() jarToClassListFile[jar.archivePathCompatible.normalize().absoluteFile] =
target.defaultArtifactClassesListFile.get()
//configure abiSnapshot mapping for jars //configure abiSnapshot mapping for jars
jarToAbiSnapshot[jar.archivePathCompatible.canonicalFile] = jarToAbiSnapshot[jar.archivePathCompatible.normalize().absoluteFile] =
target.buildDir.get().file(kotlinTask.abiSnapshotRelativePath).get().asFile target.buildDir.get().file(kotlinTask.abiSnapshotRelativePath).get().asFile
} }
@@ -414,9 +415,9 @@ internal open class GradleCompilerRunner(
internal fun getOrCreateClientFlagFile(log: Logger, projectName: String): File { internal fun getOrCreateClientFlagFile(log: Logger, projectName: String): File {
if (clientIsAliveFlagFile == null || !clientIsAliveFlagFile!!.exists()) { if (clientIsAliveFlagFile == null || !clientIsAliveFlagFile!!.exists()) {
clientIsAliveFlagFile = newTmpFile(prefix = "kotlin-compiler-in-${projectName}-", suffix = ".alive") clientIsAliveFlagFile = newTmpFile(prefix = "kotlin-compiler-in-${projectName}-", suffix = ".alive")
log.kotlinDebug { CREATED_CLIENT_FILE_PREFIX + clientIsAliveFlagFile!!.canonicalPath } log.kotlinDebug { CREATED_CLIENT_FILE_PREFIX + clientIsAliveFlagFile!!.normalize().absoluteFile }
} else { } else {
log.kotlinDebug { EXISTING_CLIENT_FILE_PREFIX + clientIsAliveFlagFile!!.canonicalPath } log.kotlinDebug { EXISTING_CLIENT_FILE_PREFIX + clientIsAliveFlagFile!!.normalize().absoluteFile }
} }
return clientIsAliveFlagFile!! return clientIsAliveFlagFile!!
@@ -437,9 +438,9 @@ internal open class GradleCompilerRunner(
if (sessionFlagFile == null || !sessionFlagFile!!.exists()) { if (sessionFlagFile == null || !sessionFlagFile!!.exists()) {
val sessionFilesDir = sessionsDir.apply { mkdirs() } val sessionFilesDir = sessionsDir.apply { mkdirs() }
sessionFlagFile = newTmpFile(prefix = "kotlin-compiler-", suffix = ".salive", directory = sessionFilesDir) sessionFlagFile = newTmpFile(prefix = "kotlin-compiler-", suffix = ".salive", directory = sessionFilesDir)
log.kotlinDebug { CREATED_SESSION_FILE_PREFIX + sessionFlagFile!!.relativeOrCanonical(projectCacheDirProvider) } log.kotlinDebug { CREATED_SESSION_FILE_PREFIX + sessionFlagFile!!.relativeOrAbsolute(projectCacheDirProvider) }
} else { } else {
log.kotlinDebug { EXISTING_SESSION_FILE_PREFIX + sessionFlagFile!!.relativeOrCanonical(projectCacheDirProvider) } log.kotlinDebug { EXISTING_SESSION_FILE_PREFIX + sessionFlagFile!!.relativeOrAbsolute(projectCacheDirProvider) }
} }
return sessionFlagFile!! return sessionFlagFile!!
@@ -149,7 +149,7 @@ internal class GradleKotlinCompilerWork @Inject constructor(
private fun compileWithDaemonOrFallbackImpl(messageCollector: MessageCollector): Pair<ExitCode, KotlinCompilerExecutionStrategy> { private fun compileWithDaemonOrFallbackImpl(messageCollector: MessageCollector): Pair<ExitCode, KotlinCompilerExecutionStrategy> {
with(log) { with(log) {
kotlinDebug { "Kotlin compiler class: ${compilerClassName}" } kotlinDebug { "Kotlin compiler class: ${compilerClassName}" }
kotlinDebug { "Kotlin compiler classpath: ${compilerFullClasspath.joinToString { it.canonicalPath }}" } kotlinDebug { "Kotlin compiler classpath: ${compilerFullClasspath.joinToString { it.normalize().absolutePath }}" }
kotlinDebug { "$taskPath Kotlin compiler args: ${compilerArgs.joinToString(" ")}" } kotlinDebug { "$taskPath Kotlin compiler args: ${compilerArgs.joinToString(" ")}" }
} }
@@ -198,7 +198,7 @@ internal open class ProcessedFilesCache(
state.remove(existedTarget) state.remove(existedTarget)
} }
} }
state[hash] = Element(file.canonicalPath, key) state[hash] = Element(file.normalize().absolutePath, key)
return key return key
} }
@@ -57,7 +57,7 @@ internal fun CompilerPluginOptions.withWrappedKaptOptions(
subpluginOptionsByPluginId.toMutableMap() subpluginOptionsByPluginId.toMutableMap()
resultOptionsByPluginId.compute(Kapt3GradleSubplugin.KAPT_SUBPLUGIN_ID) { _, kaptOptions -> resultOptionsByPluginId.compute(Kapt3GradleSubplugin.KAPT_SUBPLUGIN_ID) { _, kaptOptions ->
val changedFilesOption = changedFiles.map { SubpluginOption("changedFile", it.canonicalPath) } val changedFilesOption = changedFiles.map { SubpluginOption("changedFile", it.normalize().absolutePath) }
val classpathChangesOption = classpathChanges.map { SubpluginOption("classpathChange", it) } val classpathChangesOption = classpathChanges.map { SubpluginOption("classpathChange", it) }
val processIncrementallyOption = SubpluginOption("processIncrementally", processIncrementally.toString()) val processIncrementallyOption = SubpluginOption("processIncrementally", processIncrementally.toString())
val compiledSourcesOption = val compiledSourcesOption =
@@ -81,7 +81,7 @@ internal abstract class AbstractKotlinPlugin(
} }
val inspectTask = project.registerTask<InspectClassesForMultiModuleIC>(INSPECT_IC_CLASSES_TASK_NAME) { inspectTask -> val inspectTask = project.registerTask<InspectClassesForMultiModuleIC>(INSPECT_IC_CLASSES_TASK_NAME) { inspectTask ->
inspectTask.archivePath.set(jarTask.map { it.archivePathCompatible.canonicalPath }) inspectTask.archivePath.set(jarTask.map { it.archivePathCompatible.normalize().absolutePath })
inspectTask.archivePath.disallowChanges() inspectTask.archivePath.disallowChanges()
inspectTask.sourceSetName.set(SourceSet.MAIN_SOURCE_SET_NAME) inspectTask.sourceSetName.set(SourceSet.MAIN_SOURCE_SET_NAME)
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner
import org.jetbrains.kotlin.gradle.logging.kotlinDebug import org.jetbrains.kotlin.gradle.logging.kotlinDebug
import org.jetbrains.kotlin.gradle.plugin.internal.state.TaskExecutionResults import org.jetbrains.kotlin.gradle.plugin.internal.state.TaskExecutionResults
import org.jetbrains.kotlin.gradle.plugin.internal.state.TaskLoggers import org.jetbrains.kotlin.gradle.plugin.internal.state.TaskLoggers
import org.jetbrains.kotlin.gradle.utils.relativeOrCanonical import org.jetbrains.kotlin.gradle.utils.relativeOrAbsolute
import org.jetbrains.kotlin.utils.addToStdlib.sumByLong import org.jetbrains.kotlin.utils.addToStdlib.sumByLong
import java.io.File import java.io.File
import java.lang.management.ManagementFactory import java.lang.management.ManagementFactory
@@ -45,11 +45,11 @@ internal class KotlinGradleFinishBuildHandler {
// it is expected that only one session file per build exists // it is expected that only one session file per build exists
// afaik is is not possible to run multiple gradle builds in one project since gradle locks some dirs // afaik is is not possible to run multiple gradle builds in one project since gradle locks some dirs
if (sessionFiles.size > 1) { if (sessionFiles.size > 1) {
log.warn("w: Detected multiple Kotlin daemon sessions at ${sessionsDir.relativeOrCanonical(projectCacheDir)}") log.warn("w: Detected multiple Kotlin daemon sessions at ${sessionsDir.relativeOrAbsolute(projectCacheDir)}")
} }
for (file in sessionFiles) { for (file in sessionFiles) {
file.delete() file.delete()
log.kotlinDebug { DELETED_SESSION_FILE_PREFIX + file.relativeOrCanonical(projectCacheDir) } log.kotlinDebug { DELETED_SESSION_FILE_PREFIX + file.relativeOrAbsolute(projectCacheDir) }
} }
} }
@@ -168,7 +168,7 @@ class AndroidSubplugin : KotlinCompilerPluginSupportPlugin {
buildString { buildString {
append(name) append(name)
append(';') append(';')
resDirectories.map { it.dir }.joinTo(this, separator = ";") { it.canonicalPath } resDirectories.map { it.dir }.joinTo(this, separator = ";") { it.normalize().absolutePath }
} }
} }
pluginOptions += CompositeSubpluginOption( pluginOptions += CompositeSubpluginOption(
@@ -144,7 +144,7 @@ open class RewriteSourceMapFilterReader(
protected open fun transformString(value: String): String { protected open fun transformString(value: String): String {
val sourceFileResolved = File(srcSourceRoot) val sourceFileResolved = File(srcSourceRoot)
.resolve(value) .resolve(value)
.canonicalFile .normalize().absoluteFile
val transformedPath = sourceFileResolved.relativeToOrNull(File(targetSourceRoot))?.path ?: return sourceFileResolved.path val transformedPath = sourceFileResolved.relativeToOrNull(File(targetSourceRoot))?.path ?: return sourceFileResolved.path
@@ -82,7 +82,7 @@ abstract class KotlinCompileCommon @Inject constructor(
with(args) { with(args) {
classpath = classpathList.joinToString(File.pathSeparator) classpath = classpathList.joinToString(File.pathSeparator)
destination = destinationDirectory.get().asFile.canonicalPath destination = destinationDirectory.get().asFile.normalize().absolutePath
friendPaths = this@KotlinCompileCommon.friendPaths.files.map { it.absolutePath }.toTypedArray() friendPaths = this@KotlinCompileCommon.friendPaths.files.map { it.absolutePath }.toTypedArray()
refinesPaths = refinesMetadataPaths.map { it.absolutePath }.toTypedArray() refinesPaths = refinesMetadataPaths.map { it.absolutePath }.toTypedArray()
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinJsDceCompilerToolOptionsDefault
import org.jetbrains.kotlin.gradle.dsl.KotlinJsDce import org.jetbrains.kotlin.gradle.dsl.KotlinJsDce
import org.jetbrains.kotlin.gradle.dsl.KotlinJsDceOptions import org.jetbrains.kotlin.gradle.dsl.KotlinJsDceOptions
import org.jetbrains.kotlin.gradle.logging.GradleKotlinLogger import org.jetbrains.kotlin.gradle.logging.GradleKotlinLogger
import org.jetbrains.kotlin.gradle.utils.canonicalPathWithoutExtension import org.jetbrains.kotlin.gradle.utils.absolutePathWithoutExtension
import org.jetbrains.kotlin.gradle.utils.fileExtensionCasePermutations import org.jetbrains.kotlin.gradle.utils.fileExtensionCasePermutations
import org.jetbrains.kotlin.gradle.utils.newInstance import org.jetbrains.kotlin.gradle.utils.newInstance
import java.io.File import java.io.File
@@ -160,7 +160,7 @@ abstract class KotlinJsDce @Inject constructor(
return false return false
} }
return File("${file.canonicalPathWithoutExtension()}.meta.js").exists() return File("${file.absolutePathWithoutExtension()}.meta.js").exists()
} }
companion object { companion object {
@@ -1150,7 +1150,7 @@ abstract class Kotlin2JsCompile @Inject constructor(
val dependencies = libraries val dependencies = libraries
.filter { it.exists() && libraryFilter(it) } .filter { it.exists() && libraryFilter(it) }
.map { it.canonicalPath } .map { it.normalize().absolutePath }
args.libraries = dependencies.distinct().let { args.libraries = dependencies.distinct().let {
if (it.isNotEmpty()) if (it.isNotEmpty())
@@ -5,7 +5,6 @@
package org.jetbrains.kotlin.gradle.utils package org.jetbrains.kotlin.gradle.utils
import org.gradle.api.InvalidUserCodeException
import org.gradle.api.Project import org.gradle.api.Project
import java.io.File import java.io.File
import java.io.IOException import java.io.IOException
@@ -44,17 +43,17 @@ internal fun String.fileExtensionCasePermutations(): List<String> {
return result return result
} }
internal fun File.relativeOrCanonical(base: File): String = internal fun File.relativeOrAbsolute(base: File): String =
relativeToOrNull(base)?.path ?: canonicalPath relativeToOrNull(base)?.path ?: normalize().absolutePath
internal fun Iterable<File>.pathsAsStringRelativeTo(base: File): String = internal fun Iterable<File>.pathsAsStringRelativeTo(base: File): String =
map { it.relativeOrCanonical(base) }.sorted().joinToString() map { it.relativeOrAbsolute(base) }.sorted().joinToString()
internal fun File.relativeToRoot(project: Project): String = internal fun File.relativeToRoot(project: Project): String =
relativeOrCanonical(project.rootProject.rootDir) relativeOrAbsolute(project.rootProject.rootDir)
internal fun Iterable<File>.toPathsArray(): Array<String> = internal fun Iterable<File>.toPathsArray(): Array<String> =
map { it.canonicalPath }.toTypedArray() map { it.normalize().absolutePath }.toTypedArray()
internal fun newTmpFile(prefix: String, suffix: String? = null, directory: File? = null, deleteOnExit: Boolean = true): File { internal fun newTmpFile(prefix: String, suffix: String? = null, directory: File? = null, deleteOnExit: Boolean = true): File {
return try { return try {
@@ -82,8 +81,8 @@ internal fun File.isParentOf(childCandidate: File, strict: Boolean = false): Boo
} }
} }
internal fun File.canonicalPathWithoutExtension(): String = internal fun File.absolutePathWithoutExtension(): String =
canonicalPath.substringBeforeLast(".") normalize().absolutePath.substringBeforeLast(".")
internal fun File.listFilesOrEmpty() = (if (exists()) listFiles() else null).orEmpty() internal fun File.listFilesOrEmpty() = (if (exists()) listFiles() else null).orEmpty()
@@ -127,8 +127,8 @@ open class KaptContext(val options: KaptOptions, val withJdk: Boolean, val logge
@Suppress("SpellCheckingInspection") @Suppress("SpellCheckingInspection")
putJavacOption("PROCESSORPATH", "PROCESSOR_PATH", options.processingClasspath.makePathsString()) putJavacOption("PROCESSORPATH", "PROCESSOR_PATH", options.processingClasspath.makePathsString())
put(Option.S, options.sourcesOutputDir.canonicalPath) put(Option.S, options.sourcesOutputDir.normalize().absolutePath)
put(Option.D, options.classesOutputDir.canonicalPath) put(Option.D, options.classesOutputDir.normalize().absolutePath)
put(Option.ENCODING, "UTF-8") put(Option.ENCODING, "UTF-8")
} }
@@ -168,6 +168,6 @@ open class KaptContext(val options: KaptOptions, val withJdk: Boolean, val logge
companion object { companion object {
const val MODULE_INFO_FILE = "module-info.java" const val MODULE_INFO_FILE = "module-info.java"
private fun Iterable<File>.makePathsString(): String = joinToString(File.pathSeparator) { it.canonicalPath } private fun Iterable<File>.makePathsString(): String = joinToString(File.pathSeparator) { it.normalize().absolutePath }
} }
} }
@@ -157,7 +157,7 @@ fun KaptOptions.collectJavaSourceFiles(sourcesToReprocess: SourcesToReprocess =
.sortedBy { Files.isSymbolicLink(it.toPath()) } // Get non-symbolic paths first .sortedBy { Files.isSymbolicLink(it.toPath()) } // Get non-symbolic paths first
.flatMap { root -> root.walk().filter { it.isFile && it.extension == "java" }.toList() } .flatMap { root -> root.walk().filter { it.isFile && it.extension == "java" }.toList() }
.sortedBy { Files.isSymbolicLink(it.toPath()) } // This time is for .java files .sortedBy { Files.isSymbolicLink(it.toPath()) } // This time is for .java files
.distinctBy { it.canonicalPath } .distinctBy { it.normalize().absolutePath }
} }
return when (sourcesToReprocess) { return when (sourcesToReprocess) {
@@ -230,7 +230,7 @@ abstract class AbstractKapt3Extension(
if (!options.mode.runAnnotationProcessing) return if (!options.mode.runAnnotationProcessing) return
val javaSourceFiles = options.collectJavaSourceFiles(kaptContext.sourcesToReprocess) val javaSourceFiles = options.collectJavaSourceFiles(kaptContext.sourcesToReprocess)
logger.info { "Java source files: " + javaSourceFiles.joinToString { it.canonicalPath } } logger.info { "Java source files: " + javaSourceFiles.joinToString { it.normalize().absolutePath } }
val (annotationProcessingTime) = measureTimeMillis { val (annotationProcessingTime) = measureTimeMillis {
kaptContext.doAnnotationProcessing(javaSourceFiles, processors.processors) kaptContext.doAnnotationProcessing(javaSourceFiles, processors.processors)