mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
* fix debug of Build.kt (do not rename original source file but use temporary folder instead)
This commit is contained in:
parent
14ad4ce733
commit
1455a9a1a2
3 changed files with 14 additions and 2 deletions
|
@ -288,6 +288,18 @@ class KFiles {
|
|||
return it
|
||||
}
|
||||
|
||||
fun createTempBuildFileInTempDirectory(deleteOnExit: Boolean = false) : File =
|
||||
File(createTempDirectory("kobalt", deleteOnExit), Constants.BUILD_FILE_NAME).let {
|
||||
if (deleteOnExit) it.deleteOnExit()
|
||||
return it
|
||||
}
|
||||
|
||||
fun createTempDirectory(prefix : String = "kobalt", deleteOnExit: Boolean = false) : File =
|
||||
Files.createTempDirectory(prefix).let {
|
||||
if (deleteOnExit) it.toFile().deleteOnExit()
|
||||
return it.toFile()
|
||||
}
|
||||
|
||||
fun src(filePath: String): String = KFiles.joinDir(KOBALT_DIR, SRC, filePath)
|
||||
|
||||
fun makeDir(project: Project, suffix: String) : File {
|
||||
|
|
|
@ -101,7 +101,7 @@ class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val buildFil
|
|||
|
||||
// Write the modified Build.kt (e.g. maybe profiles were applied) to a temporary file,
|
||||
// compile it, jar it in buildScript.jar and run it
|
||||
val modifiedBuildFile = KFiles.createTempFile(".kt", deleteOnExit = true)
|
||||
val modifiedBuildFile = KFiles.createTempBuildFileInTempDirectory(deleteOnExit = true)
|
||||
KFiles.saveFile(modifiedBuildFile, parsedBuildFile.buildScriptCode)
|
||||
val taskResult = maybeCompileBuildFile(context, BuildFile(Paths.get(modifiedBuildFile.path),
|
||||
"Modified ${Constants.BUILD_FILE_NAME}", buildFile.realPath),
|
||||
|
|
|
@ -126,7 +126,7 @@ class ParsedBuildFile(val buildFile: BuildFile, val context: KobaltContext, val
|
|||
// Compile and run preBuildScriptCode, which contains all the plugins() calls extracted. This
|
||||
// will add all the dynamic plugins found in this code to Plugins.dynamicPlugins
|
||||
//
|
||||
val pluginSourceFile = KFiles.createTempFile(".kt", deleteOnExit = true)
|
||||
val pluginSourceFile = KFiles.createTempBuildFileInTempDirectory(deleteOnExit = true)
|
||||
pluginSourceFile.writeText(preBuildScriptCode, Charset.defaultCharset())
|
||||
kobaltLog(2, "Saved ${pluginSourceFile.absolutePath}")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue