From 33d962a55a559aa706649c29d9dd85d724cc37d9 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Mon, 10 Aug 2020 14:41:33 +0200 Subject: Handle wrongly implemented `DokkaMultiModuleFileLayout` --- .../dokka/gradle/DokkaMultiModuleFileLayout.kt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'runners/gradle-plugin/src/main/kotlin/org') diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleFileLayout.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleFileLayout.kt index bb48ba2a..e3b82e7c 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleFileLayout.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleFileLayout.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka.gradle +import org.jetbrains.dokka.DokkaException import java.io.File /** @@ -59,14 +60,25 @@ internal fun DokkaMultiModuleTask.copyChildOutputDirectory(child: AbstractDokkaT val targetChildOutputDirectory = project.file(fileLayout.targetChildOutputDirectory(this, child)) val sourceChildOutputDirectory = child.outputDirectory.getSafe() - if (!sourceChildOutputDirectory.exists()) { + /* Pointing to the same directory -> No copy necessary */ + if (sourceChildOutputDirectory.absoluteFile == targetChildOutputDirectory.absoluteFile) { return } - if (sourceChildOutputDirectory.absoluteFile == targetChildOutputDirectory.absoluteFile) { + /* Cannot target *inside* the original folder */ + if (targetChildOutputDirectory.absoluteFile.startsWith(sourceChildOutputDirectory.absoluteFile)) { + throw DokkaException( + "Cannot re-locate output directory into itself.\n" + + "sourceChildOutputDirectory=${sourceChildOutputDirectory.path}\n" + + "targetChildOutputDirectory=${targetChildOutputDirectory.path}" + ) + } + + /* Source output directory is empty -> No copy necessary */ + if (!sourceChildOutputDirectory.exists()) { return } - sourceChildOutputDirectory.copyRecursively(targetChildOutputDirectory, overwrite = false) + sourceChildOutputDirectory.copyRecursively(targetChildOutputDirectory, overwrite = true) } -- cgit