mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Restore build file time stamps.
This commit is contained in:
parent
46e38b7385
commit
3a629b1491
2 changed files with 27 additions and 12 deletions
|
@ -11,8 +11,8 @@ import java.nio.file.attribute.BasicFileAttributes
|
||||||
public class BuildFile(val path: Path, val name: String) {
|
public class BuildFile(val path: Path, val name: String) {
|
||||||
public fun exists() : Boolean = Files.exists(path)
|
public fun exists() : Boolean = Files.exists(path)
|
||||||
|
|
||||||
public fun lastModified() : Long = Files.readAttributes(path, BasicFileAttributes::class.java).lastModifiedTime()
|
public val lastModified : Long
|
||||||
.toMillis()
|
get() = Files.readAttributes(path, BasicFileAttributes::class.java).lastModifiedTime().toMillis()
|
||||||
|
|
||||||
public val directory : File get() = path.toFile().directory
|
public val directory : File get() = path.toFile().directory
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,22 +35,37 @@ public class ScriptCompiler2 @Inject constructor(@Assisted("buildFiles") val bui
|
||||||
val result = arrayListOf<Project>()
|
val result = arrayListOf<Project>()
|
||||||
buildFiles.forEach { buildFile ->
|
buildFiles.forEach { buildFile ->
|
||||||
val pluginUrls = findPlugInUrls(buildFile)
|
val pluginUrls = findPlugInUrls(buildFile)
|
||||||
val script = File(KFiles.findBuildScriptLocation(buildFile, SCRIPT_JAR))
|
val buildScriptJarFile = File(KFiles.findBuildScriptLocation(buildFile, SCRIPT_JAR))
|
||||||
|
|
||||||
log(1, "Compiling main build file ${buildFile.path}")
|
maybeCompileBuildFile(buildFile, buildScriptJarFile, pluginUrls)
|
||||||
kotlinCompilePrivate {
|
val output = parseBuildScriptJarFile(buildScriptJarFile, pluginUrls)
|
||||||
classpath(files.kobaltJar)
|
|
||||||
classpath(pluginUrls.map { it.file })
|
|
||||||
sourceFiles(listOf(buildFile.path.toFile().absolutePath))
|
|
||||||
output = script.absolutePath
|
|
||||||
}.compile()
|
|
||||||
|
|
||||||
val output = parseBuildScriptJarFile(script, pluginUrls)
|
|
||||||
result.addAll(output.projects)
|
result.addAll(output.projects)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun maybeCompileBuildFile(buildFile: BuildFile, buildScriptJarFile: File, pluginUrls: List<URL>) {
|
||||||
|
log(2, "Running build file ${buildFile.name} jar: $buildScriptJarFile")
|
||||||
|
|
||||||
|
if (buildFile.exists() && buildScriptJarFile.exists()
|
||||||
|
&& buildFile.lastModified < buildScriptJarFile.lastModified()) {
|
||||||
|
log(2, "Build file is up to date")
|
||||||
|
} else {
|
||||||
|
log(2, "Need to recompile ${buildFile.name}")
|
||||||
|
|
||||||
|
kotlinCompilePrivate {
|
||||||
|
classpath(files.kobaltJar)
|
||||||
|
classpath(pluginUrls.map { it.file })
|
||||||
|
sourceFiles(listOf(buildFile.path.toFile().absolutePath))
|
||||||
|
output = buildScriptJarFile.absolutePath
|
||||||
|
}.compile()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the script file with only the plugins()/repos() directives and run it. Then return
|
||||||
|
* the URL's of all the plug-ins that were found.
|
||||||
|
*/
|
||||||
private fun findPlugInUrls(buildFile: BuildFile): List<URL> {
|
private fun findPlugInUrls(buildFile: BuildFile): List<URL> {
|
||||||
val result = arrayListOf<URL>()
|
val result = arrayListOf<URL>()
|
||||||
val pluginCode = arrayListOf(
|
val pluginCode = arrayListOf(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue