From 789c969a9b19cf63f12920f9a6caad30573b3d1a Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Mon, 3 Apr 2017 10:58:40 -0700 Subject: [PATCH] GITHUB-382: Expose Project.collect() to gather dependencies in the build file. Fixes https://github.com/cbeust/kobalt/issues/382 --- .../src/main/kotlin/com/beust/kobalt/api/Project.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Project.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Project.kt index 306a61b6..0471a53c 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Project.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/Project.kt @@ -128,6 +128,18 @@ open class Project( return result } + /** + * @return a list of the transitive dependencies (absolute paths to jar files) for the given dependencies. + * Can be used for example as `collect(compileDependencies)`. + */ + @Directive + fun collect(dependencies: List) : List { + return Kobalt.context?.dependencyManager?.transitiveClosure(dependencies)?.map { it.jarFile.get() } + ?.map { it.absolutePath} + ?: emptyList() + } + + override fun toString() = "[Project $name]" }