aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/renderers/FileWriter.kt
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-07-18 12:18:59 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-14 17:51:11 +0200
commiteae1ce49d18c2978b49166ea502bf2c109a85504 (patch)
tree477f39e33f14c71042f06eecc938d6efaa95e66c /plugins/base/src/main/kotlin/renderers/FileWriter.kt
parent6c635551ed3ea0cfe5f04b54a98cb28225061d26 (diff)
downloaddokka-eae1ce49d18c2978b49166ea502bf2c109a85504.tar.gz
dokka-eae1ce49d18c2978b49166ea502bf2c109a85504.tar.bz2
dokka-eae1ce49d18c2978b49166ea502bf2c109a85504.zip
Simplify Dokka Gradle Plugin
Diffstat (limited to 'plugins/base/src/main/kotlin/renderers/FileWriter.kt')
-rw-r--r--plugins/base/src/main/kotlin/renderers/FileWriter.kt14
1 files changed, 7 insertions, 7 deletions
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
+}