From c34c69b1cc0b49d7321e0196153eb2dabb620365 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sat, 20 Feb 2016 13:10:22 -0800 Subject: [PATCH] More refactoring. --- .../com/beust/kobalt/internal/JvmCompilerPlugin.kt | 2 +- .../kotlin/com/beust/kobalt/internal/SourceSet.kt | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt index 76ae6499..89eed3d2 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/JvmCompilerPlugin.kt @@ -115,7 +115,7 @@ open class JvmCompilerPlugin @Inject constructor( * Copy the resources from a source directory to the build one */ protected fun copyResources(project: Project, sourceSet: SourceSet) { - var outputDir = sourceSet.correctOutputDir(project) + var outputDir = sourceSet.outputDir val variantSourceDirs = context.variant.resourceDirectories(project, sourceSet) if (variantSourceDirs.size > 0) { 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 31f13e08..e0a3178f 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 @@ -4,9 +4,9 @@ import com.beust.kobalt.KobaltException import com.beust.kobalt.api.Project import com.beust.kobalt.misc.KFiles -enum class SourceSet { - MAIN, - TEST; +enum class SourceSet(val outputDir: String) { + MAIN(KFiles.CLASSES_DIR), + TEST(KFiles.TEST_CLASSES_DIR); fun correctSourceSet(project: Project) = when(this) { SourceSet.MAIN -> project.sourceDirectories @@ -14,12 +14,6 @@ enum class SourceSet { else -> unknown(this) } - fun correctOutputDir(project: Project) = when(this) { - SourceSet.MAIN -> KFiles.CLASSES_DIR - SourceSet.TEST -> KFiles.TEST_CLASSES_DIR - else -> unknown(this) - } - companion object { fun of(isTest: Boolean) = if (isTest) TEST else MAIN private fun unknown(sourceSet: SourceSet) = throw KobaltException("Unknown source set: $sourceSet")