From eae1ce49d18c2978b49166ea502bf2c109a85504 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Sat, 18 Jul 2020 12:18:59 +0200 Subject: Simplify Dokka Gradle Plugin --- plugins/base/src/main/kotlin/renderers/FileWriter.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'plugins/base/src/main/kotlin/renderers/FileWriter.kt') diff --git a/plugins/base/src/main/kotlin/renderers/FileWriter.kt b/plugins/base/src/main/kotlin/renderers/FileWriter.kt index 181295c0..cd38f1b9 100644 --- a/plugins/base/src/main/kotlin/renderers/FileWriter.kt +++ b/plugins/base/src/main/kotlin/renderers/FileWriter.kt @@ -21,10 +21,10 @@ class FileWriter(val context: DokkaContext): OutputWriter { createdFiles.add(path) try { - val dir = Paths.get(root, path.dropLastWhile { it != '/' }).toFile() + val dir = Paths.get(root.absolutePath, path.dropLastWhile { it != '/' }).toFile() withContext(Dispatchers.IO) { dir.mkdirsOrFail() - Files.write(Paths.get(root, "$path$ext"), text.lines()) + Files.write(Paths.get(root.absolutePath, "$path$ext"), text.lines()) } } catch (e: Throwable) { context.logger.error("Failed to write $this. ${e.message}") @@ -41,7 +41,7 @@ class FileWriter(val context: DokkaContext): OutputWriter { private suspend fun copyFromDirectory(pathFrom: String, pathTo: String) { - val dest = Paths.get(root, pathTo).toFile() + val dest = Paths.get(root.path, pathTo).toFile() val uri = javaClass.getResource(pathFrom).toURI() withContext(Dispatchers.IO) { File(uri).copyRecursively(dest, true) @@ -51,7 +51,7 @@ class FileWriter(val context: DokkaContext): OutputWriter { private suspend fun copyFromJar(pathFrom: String, pathTo: String) { val rebase = fun(path: String) = "$pathTo/${path.removePrefix(pathFrom)}" - val dest = Paths.get(root, pathTo).toFile() + val dest = Paths.get(root.path, pathTo).toFile() dest.mkdirsOrFail() val uri = javaClass.getResource(pathFrom).toURI() val fs = getFileSystemForURI(uri) @@ -60,12 +60,12 @@ class FileWriter(val context: DokkaContext): OutputWriter { if (Files.isDirectory(file)) { val dirPath = file.toAbsolutePath().toString() withContext(Dispatchers.IO) { - Paths.get(root, rebase(dirPath)).toFile().mkdirsOrFail() + Paths.get(root.path, rebase(dirPath)).toFile().mkdirsOrFail() } } else { val filePath = file.toAbsolutePath().toString() withContext(Dispatchers.IO) { - Paths.get(root, rebase(filePath)).toFile().writeBytes( + Paths.get(root.path, rebase(filePath)).toFile().writeBytes( this@FileWriter.javaClass.getResourceAsStream(filePath).readBytes() ) } @@ -85,4 +85,4 @@ class FileWriter(val context: DokkaContext): OutputWriter { } catch (e: FileSystemAlreadyExistsException) { FileSystems.getFileSystem(uri) } -} \ No newline at end of file +} -- cgit