From c16a93e4a2a299d85ebabfba7c8c64163482b185 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 28 Dec 2015 20:56:03 +0400 Subject: [PATCH] Fix the repo bug. Repo contributors were not applied early enough, so resources coming from the Android m2repository could not be resolved. --- .../kotlin/com/beust/kobalt/api/Kobalt.kt | 16 +++++++++++++-- src/main/kotlin/com/beust/kobalt/Main.kt | 20 +++++++------------ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt index 930f5d8a..e736aab1 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Kobalt.kt @@ -16,9 +16,21 @@ public class Kobalt { var context: KobaltContext? = null - val repos = HashSet(Constants.DEFAULT_REPOS.map { HostConfig(it) }) + /** + * @return the repos from the build files and from the contributors. + */ + val repos : Set + get() { + val result = HashSet(reposFromBuildFiles) + Kobalt.context?.pluginInfo?.repoContributors?.forEach { + result.addAll(it.reposFor(null)) + } + return result + } - fun addRepo(repo: HostConfig) = repos.add( + val reposFromBuildFiles = HashSet(Constants.DEFAULT_REPOS.map { HostConfig(it) }) + + fun addRepo(repo: HostConfig) = reposFromBuildFiles.add( if (repo.url.endsWith("/")) repo else repo.copy(url = (repo.url + "/"))) diff --git a/src/main/kotlin/com/beust/kobalt/Main.kt b/src/main/kotlin/com/beust/kobalt/Main.kt index 246c09d1..e55cbaa9 100644 --- a/src/main/kotlin/com/beust/kobalt/Main.kt +++ b/src/main/kotlin/com/beust/kobalt/Main.kt @@ -65,21 +65,9 @@ private class Main @Inject constructor( data class RunInfo(val jc: JCommander, val args: Args) - private fun addReposFromContributors(project: Project?) = - pluginInfo.repoContributors.forEach { - it.reposFor(project).forEach { - Kobalt.addRepo(it) - } - } - public fun run(jc: JCommander, args: Args, argv: Array): Int { // github.uploadRelease("kobalt", "0.101", File("/Users/beust/t/a.zip")) - // - // Add all the repos from repo contributors (at least those that return values without a Project) - // - addReposFromContributors(null) - // // Add all the plugins read in kobalt-plugin.xml to the Plugins singleton, so that code // in the build file that calls Plugins.findPlugin() can find them (code in the @@ -167,7 +155,13 @@ private class Main @Inject constructor( // // Now that we have projects, add all the repos from repo contributors that need a Project // - allProjects.forEach { addReposFromContributors(it) } + allProjects.forEach { project -> + pluginInfo.repoContributors.forEach { + it.reposFor(project).forEach { + Kobalt.addRepo(it) + } + } + } // // Run all their dependencies through the IDependencyInterceptors