From e992d8b93564ede50bd1a4ab364c85c03442ecf3 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 17 Nov 2015 23:16:00 -0800 Subject: [PATCH] Disallow same project names. --- .../com/beust/kobalt/kotlin/BuildFileCompiler.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/kotlin/com/beust/kobalt/kotlin/BuildFileCompiler.kt b/src/main/kotlin/com/beust/kobalt/kotlin/BuildFileCompiler.kt index 945e4d98..b15eaba8 100644 --- a/src/main/kotlin/com/beust/kobalt/kotlin/BuildFileCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/kotlin/BuildFileCompiler.kt @@ -62,6 +62,17 @@ public class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val b return allProjects } + private fun validateProjects(projects: List) { + val seen = hashSetOf() + projects.forEach { + if (seen.contains(it.name)) { + throw KobaltException("Duplicate project name: $it") + } else { + seen.add(it.name) + } + } + } + private fun findProjects(context: KobaltContext): List { val result = arrayListOf() buildFiles.forEach { buildFile -> @@ -255,6 +266,8 @@ public class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val b stream?.close() } + validateProjects(projects) + // // Now that the build file has run, fetch all the project contributors, grab the projects from them and sort // them topologically