1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 16:28:12 -07:00

Refactor.

This commit is contained in:
Cedric Beust 2016-02-06 01:37:36 +04:00
parent f6927e2304
commit 451ddf3590

View file

@ -111,17 +111,19 @@ public class DependencyManager @Inject constructor(val executors: KobaltExecutor
return result return result
} }
/** private fun dependencies(project: Project, context: KobaltContext, isTest: Boolean)
* @return the compile dependencies for this project, including the contributors. : List<IClasspathDependency> {
* TODO: very similar to the method below, refactor.
*/
fun dependencies(project: Project, context: KobaltContext) : List<IClasspathDependency> {
val result = arrayListOf<IClasspathDependency>() val result = arrayListOf<IClasspathDependency>()
val projects = listOf(ProjectDescription(project, project.projectExtra.dependsOn)) val projects = listOf(ProjectDescription(project, project.projectExtra.dependsOn))
result.add(FileDependency(KFiles.makeOutputDir(project).absolutePath)) result.add(FileDependency(KFiles.makeOutputDir(project).absolutePath))
result.add(FileDependency(KFiles.makeOutputTestDir(project).absolutePath)) result.add(FileDependency(KFiles.makeOutputTestDir(project).absolutePath))
with(project) { with(project) {
arrayListOf(compileDependencies, compileProvidedDependencies).forEach { val deps = arrayListOf(compileDependencies, compileProvidedDependencies)
if (isTest) {
deps.add(testDependencies)
deps.add(testProvidedDependencies)
}
deps.forEach {
result.addAll(calculateDependencies(project, context, projects, it)) result.addAll(calculateDependencies(project, context, projects, it))
} }
} }
@ -129,24 +131,10 @@ public class DependencyManager @Inject constructor(val executors: KobaltExecutor
return result2 return result2
} }
fun dependencies(project: Project, context: KobaltContext) = dependencies(project, context, false)
/** /**
* @return the test dependencies for this project, including the contributors. * @return the test dependencies for this project, including the contributors.
*/ */
fun testDependencies(project: Project, context: KobaltContext) : List<IClasspathDependency> { fun testDependencies(project: Project, context: KobaltContext) = dependencies(project, context, true)
val result = arrayListOf<IClasspathDependency>()
val projects = listOf(ProjectDescription(project, project.projectExtra.dependsOn))
result.add(FileDependency(KFiles.makeOutputDir(project).absolutePath))
result.add(FileDependency(KFiles.makeOutputTestDir(project).absolutePath))
with(project) {
arrayListOf(compileDependencies, compileProvidedDependencies, testDependencies,
testProvidedDependencies).forEach {
result.addAll(calculateDependencies(project, context, projects, it))
}
}
val result2 = reorderDependencies(result)
return result2
}
} }