1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 16:28:12 -07:00

Refactor.

This commit is contained in:
Cedric Beust 2016-02-20 13:07:25 -08:00
parent 4aba3d6f1b
commit 9f3f09ea6a

View file

@ -8,21 +8,21 @@ enum class SourceSet {
MAIN, MAIN,
TEST; TEST;
private fun unknown(sourceSet: SourceSet) = throw KobaltException("Unknown source set: $this") fun correctSourceSet(project: Project) = when(this) {
SourceSet.MAIN -> project.sourceDirectories
SourceSet.TEST -> project.sourceDirectoriesTest
else -> unknown(this)
}
fun correctSourceSet(project: Project) = fun correctOutputDir(project: Project) = when(this) {
if (this == SourceSet.MAIN) project.sourceDirectories SourceSet.MAIN -> KFiles.CLASSES_DIR
else if (this == SourceSet.TEST) project.sourceDirectoriesTest SourceSet.TEST -> KFiles.TEST_CLASSES_DIR
else unknown(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 unknown(this)
companion object { companion object {
fun of(isTest: Boolean) = if (isTest) TEST else MAIN fun of(isTest: Boolean) = if (isTest) TEST else MAIN
private fun unknown(sourceSet: SourceSet) = throw KobaltException("Unknown source set: $sourceSet")
} }
} }