diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/IDependencyManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/IDependencyManager.kt index ce1778aa..c2e7fdb9 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/IDependencyManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/IDependencyManager.kt @@ -26,7 +26,7 @@ interface IDependencyManager { /** * @return the source dependencies for this project, including the contributors. */ - fun dependencies(project: Project, context: KobaltContext): List + fun dependencies(project: Project, context: KobaltContext, scopes: List): List /** * @return the test dependencies for this project, including the contributors. diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt index d5b4cd2b..9bcbee7a 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt @@ -70,12 +70,14 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, /** * @return the source dependencies for this project, including the contributors. */ - override fun dependencies(project: Project, context: KobaltContext) = dependencies(project, context, false) + override fun dependencies(project: Project, context: KobaltContext, scopes: List) + = privateDependencies(project, context, listOf(Scope.COMPILE)) /** * @return the test dependencies for this project, including the contributors. */ - override fun testDependencies(project: Project, context: KobaltContext) = dependencies(project, context, true) + override fun testDependencies(project: Project, context: KobaltContext) + = privateDependencies(project, context, listOf(Scope.COMPILE, Scope.TEST)) /** * Transitive dependencies for the compilation of this project. @@ -232,18 +234,26 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, } } - private fun dependencies(project: Project, context: KobaltContext, isTest: Boolean) + private fun privateDependencies(project: Project, context: KobaltContext, passedScopes: List) : List { + val isTest = passedScopes.contains(Scope.TEST) val transitive = hashSetOf() with(project) { val scopeFilters : ArrayList = arrayListOf(Scope.COMPILE) context.variant.let { variant -> - val deps = arrayListOf(compileDependencies, compileProvidedDependencies, - variant.buildType.compileDependencies, - variant.buildType.compileProvidedDependencies, - variant.productFlavor.compileDependencies, - variant.productFlavor.compileProvidedDependencies - ) + val deps: ArrayList> = + if (passedScopes.contains(Scope.COMPILE)) { + arrayListOf(compileDependencies, compileProvidedDependencies, + variant.buildType.compileDependencies, + variant.buildType.compileProvidedDependencies, + variant.productFlavor.compileDependencies, + variant.productFlavor.compileProvidedDependencies) + } else if (passedScopes.contains(Scope.RUNTIME)) { + arrayListOf(compileRuntimeDependencies) + } else { + arrayListOf(arrayListOf()) + } + val runtimeDeps = arrayListOf(compileRuntimeDependencies) if (isTest) { deps.add(testDependencies) deps.add(testProvidedDependencies) @@ -252,9 +262,9 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val filter = if (isTest) OrDependencyFilter(Filters.COMPILE_FILTER, Filters.TEST_FILTER) else Filters.COMPILE_FILTER - deps.filter { it.any() }.forEach { + runtimeDeps.filter { it.any() }.forEach { transitive.addAll(calculateDependencies(project, context, filter, - scopes = Scope.toScopes(isTest), + passedScopes, // scopes = Scope.toScopes(isTest), passedDependencies = it)) } } diff --git a/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt index d053b918..69a61ceb 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt @@ -61,7 +61,8 @@ class ApplicationPlugin @Inject constructor(val configActor: ConfigActor 0) { - return runContributor.run(project, context, dependencyManager.dependencies(project, context)) + return runContributor.run(project, context, + dependencyManager.dependencies(project, context, listOf(Scope.RUNTIME))) } else { context.logger.log(project.name, 1, "Couldn't find a runner for project ${project.name}. Please make sure" +