mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Better runtime scope handling.
This commit is contained in:
parent
a99ce1ce4d
commit
df7d9e7d68
3 changed files with 24 additions and 13 deletions
|
@ -26,7 +26,7 @@ interface IDependencyManager {
|
||||||
/**
|
/**
|
||||||
* @return the source dependencies for this project, including the contributors.
|
* @return the source dependencies for this project, including the contributors.
|
||||||
*/
|
*/
|
||||||
fun dependencies(project: Project, context: KobaltContext): List<IClasspathDependency>
|
fun dependencies(project: Project, context: KobaltContext, scopes: List<Scope>): List<IClasspathDependency>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the test dependencies for this project, including the contributors.
|
* @return the test dependencies for this project, including the contributors.
|
||||||
|
|
|
@ -70,12 +70,14 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors,
|
||||||
/**
|
/**
|
||||||
* @return the source dependencies for this project, including the contributors.
|
* @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<Scope>)
|
||||||
|
= privateDependencies(project, context, listOf(Scope.COMPILE))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the test dependencies for this project, including the contributors.
|
* @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.
|
* 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<Scope>)
|
||||||
: List<IClasspathDependency> {
|
: List<IClasspathDependency> {
|
||||||
|
val isTest = passedScopes.contains(Scope.TEST)
|
||||||
val transitive = hashSetOf<IClasspathDependency>()
|
val transitive = hashSetOf<IClasspathDependency>()
|
||||||
with(project) {
|
with(project) {
|
||||||
val scopeFilters : ArrayList<Scope> = arrayListOf(Scope.COMPILE)
|
val scopeFilters : ArrayList<Scope> = arrayListOf(Scope.COMPILE)
|
||||||
context.variant.let { variant ->
|
context.variant.let { variant ->
|
||||||
val deps = arrayListOf(compileDependencies, compileProvidedDependencies,
|
val deps: ArrayList<ArrayList<IClasspathDependency>> =
|
||||||
|
if (passedScopes.contains(Scope.COMPILE)) {
|
||||||
|
arrayListOf(compileDependencies, compileProvidedDependencies,
|
||||||
variant.buildType.compileDependencies,
|
variant.buildType.compileDependencies,
|
||||||
variant.buildType.compileProvidedDependencies,
|
variant.buildType.compileProvidedDependencies,
|
||||||
variant.productFlavor.compileDependencies,
|
variant.productFlavor.compileDependencies,
|
||||||
variant.productFlavor.compileProvidedDependencies
|
variant.productFlavor.compileProvidedDependencies)
|
||||||
)
|
} else if (passedScopes.contains(Scope.RUNTIME)) {
|
||||||
|
arrayListOf(compileRuntimeDependencies)
|
||||||
|
} else {
|
||||||
|
arrayListOf(arrayListOf<IClasspathDependency>())
|
||||||
|
}
|
||||||
|
val runtimeDeps = arrayListOf(compileRuntimeDependencies)
|
||||||
if (isTest) {
|
if (isTest) {
|
||||||
deps.add(testDependencies)
|
deps.add(testDependencies)
|
||||||
deps.add(testProvidedDependencies)
|
deps.add(testProvidedDependencies)
|
||||||
|
@ -252,9 +262,9 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors,
|
||||||
val filter =
|
val filter =
|
||||||
if (isTest) OrDependencyFilter(Filters.COMPILE_FILTER, Filters.TEST_FILTER)
|
if (isTest) OrDependencyFilter(Filters.COMPILE_FILTER, Filters.TEST_FILTER)
|
||||||
else Filters.COMPILE_FILTER
|
else Filters.COMPILE_FILTER
|
||||||
deps.filter { it.any() }.forEach {
|
runtimeDeps.filter { it.any() }.forEach {
|
||||||
transitive.addAll(calculateDependencies(project, context, filter,
|
transitive.addAll(calculateDependencies(project, context, filter,
|
||||||
scopes = Scope.toScopes(isTest),
|
passedScopes, // scopes = Scope.toScopes(isTest),
|
||||||
passedDependencies = it))
|
passedDependencies = it))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,8 @@ class ApplicationPlugin @Inject constructor(val configActor: ConfigActor<Applica
|
||||||
val runContributor = ActorUtils.selectAffinityActor(project, context,
|
val runContributor = ActorUtils.selectAffinityActor(project, context,
|
||||||
context.pluginInfo.runnerContributors)
|
context.pluginInfo.runnerContributors)
|
||||||
if (runContributor != null && runContributor.affinity(project, context) > 0) {
|
if (runContributor != null && runContributor.affinity(project, context) > 0) {
|
||||||
return runContributor.run(project, context, dependencyManager.dependencies(project, context))
|
return runContributor.run(project, context,
|
||||||
|
dependencyManager.dependencies(project, context, listOf(Scope.RUNTIME)))
|
||||||
} else {
|
} else {
|
||||||
context.logger.log(project.name, 1,
|
context.logger.log(project.name, 1,
|
||||||
"Couldn't find a runner for project ${project.name}. Please make sure" +
|
"Couldn't find a runner for project ${project.name}. Please make sure" +
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue