From 4aba3d6f1b81d9ed6dfe22eca8ad1773f3e8b00f Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sat, 20 Feb 2016 13:04:50 -0800 Subject: [PATCH] Refactor. --- .../src/main/kotlin/com/beust/kobalt/internal/SourceSet.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/SourceSet.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/SourceSet.kt index c094b82c..1ca707ca 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/SourceSet.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/SourceSet.kt @@ -8,15 +8,17 @@ enum class SourceSet { MAIN, TEST; + private fun unknown(sourceSet: SourceSet) = throw KobaltException("Unknown source set: $this") + fun correctSourceSet(project: Project) = if (this == SourceSet.MAIN) project.sourceDirectories else if (this == SourceSet.TEST) project.sourceDirectoriesTest - else throw KobaltException("Unknown source set: $this") + else unknown(this) fun correctOutputDir(project: Project) = if (this == SourceSet.MAIN) KFiles.CLASSES_DIR else if (this == SourceSet.TEST) KFiles.TEST_CLASSES_DIR - else throw IllegalArgumentException("Unknown source set: $this") + else unknown(this) companion object { fun of(isTest: Boolean) = if (isTest) TEST else MAIN