1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Timestamps for Kotlin compilation.

This commit is contained in:
Cedric Beust 2015-12-18 21:06:53 -08:00
parent e3f98ee255
commit 0f630f0756
2 changed files with 9 additions and 4 deletions

View file

@ -130,6 +130,8 @@ abstract class JvmCompilerPlugin @Inject constructor(
} }
} }
open fun toClassFile(sourceFile: String) = sourceFile + ".class"
fun addCompilerArgs(project: Project, vararg args: String) { fun addCompilerArgs(project: Project, vararg args: String) {
project.projectProperties.put(COMPILER_ARGS, arrayListOf(*args)) 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") 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) val index = sourceFile.indexOf(project.sourceSuffix)
if (index >= 0) return sourceFile.substring(0, index) if (index >= 0) return sourceFile.substring(0, index)
else return sourceFile else return sourceFile
} }
fun toClassFile(sourceFile: String) = stripSuffix(sourceFile) + ".class"
actionInfo.sourceFiles.map { it.replace("\\", "/") }.forEach { sourceFile -> actionInfo.sourceFiles.map { it.replace("\\", "/") }.forEach { sourceFile ->
val stripped = stripSourceDir(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()) { if (! classFile.exists() || File(sourceFile).lastModified() > classFile.lastModified()) {
log(2, "Outdated $sourceFile $classFile " + Date(File(sourceFile).lastModified()) +
" " + classFile.lastModified())
return true return true
} }
} }

View file

@ -145,6 +145,8 @@ class KotlinPlugin @Inject constructor(
fun addDokkaConfiguration(project: Project, dokkaConfig: DokkaConfig) { fun addDokkaConfiguration(project: Project, dokkaConfig: DokkaConfig) {
dokkaConfigurations.put(project.name, dokkaConfig) dokkaConfigurations.put(project.name, dokkaConfig)
} }
override fun toClassFile(sourceFile: String) = sourceFile + "Kt.class"
} }
/** /**