From 0f630f0756f6cf18f5b86e97dbb2b0d4b1efa4be Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Fri, 18 Dec 2015 21:06:53 -0800 Subject: [PATCH] Timestamps for Kotlin compilation. --- .../com/beust/kobalt/internal/JvmCompilerPlugin.kt | 11 +++++++---- .../com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt index f330e7e5..ddca1970 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt @@ -130,6 +130,8 @@ abstract class JvmCompilerPlugin @Inject constructor( } } + open fun toClassFile(sourceFile: String) = sourceFile + ".class" + fun addCompilerArgs(project: Project, vararg args: String) { project.projectProperties.put(COMPILER_ARGS, arrayListOf(*args)) } @@ -143,18 +145,19 @@ abstract class JvmCompilerPlugin @Inject constructor( throw KobaltException("Couldn't strip source dir from $sourceFile") } - fun stripSuffix(sourceFile: String) : String { + fun stripSuffix( sourceFile: String) : String { val index = sourceFile.indexOf(project.sourceSuffix) if (index >= 0) return sourceFile.substring(0, index) else return sourceFile } - fun toClassFile(sourceFile: String) = stripSuffix(sourceFile) + ".class" - actionInfo.sourceFiles.map { it.replace("\\", "/") }.forEach { sourceFile -> val stripped = stripSourceDir(sourceFile) - val classFile = File(KFiles.joinDir(project.directory, project.classesDir(context), toClassFile(stripped))) + val classFile = File(KFiles.joinDir(project.directory, project.classesDir(context), + toClassFile(stripSuffix(stripped)))) if (! classFile.exists() || File(sourceFile).lastModified() > classFile.lastModified()) { + log(2, "Outdated $sourceFile $classFile " + Date(File(sourceFile).lastModified()) + + " " + classFile.lastModified()) return true } } diff --git a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt index ac017f72..1c4e6151 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt @@ -145,6 +145,8 @@ class KotlinPlugin @Inject constructor( fun addDokkaConfiguration(project: Project, dokkaConfig: DokkaConfig) { dokkaConfigurations.put(project.name, dokkaConfig) } + + override fun toClassFile(sourceFile: String) = sourceFile + "Kt.class" } /**