mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
GITHUB-215: Bug in dependent project classpath.
Fixes https://github.com/cbeust/kobalt/issues/215
This commit is contained in:
parent
6ac16074f0
commit
f89688ae19
6 changed files with 18 additions and 34 deletions
|
@ -2,10 +2,8 @@ package com.beust.kobalt
|
|||
|
||||
import com.beust.kobalt.api.KobaltContext
|
||||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.api.ProjectDescription
|
||||
import com.beust.kobalt.archive.Archives
|
||||
import com.beust.kobalt.archive.Jar
|
||||
import com.beust.kobalt.internal.JvmCompilerPlugin
|
||||
import com.beust.kobalt.maven.DependencyManager
|
||||
import com.beust.kobalt.misc.*
|
||||
import com.google.inject.Inject
|
||||
|
@ -97,15 +95,12 @@ class JarGenerator @Inject constructor(val dependencyManager: DependencyManager)
|
|||
|
||||
val seen = hashSetOf<String>()
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val dependentProjects = project.projectProperties.get(JvmCompilerPlugin.DEPENDENT_PROJECTS)
|
||||
as List<ProjectDescription>
|
||||
val allDependencies = project.compileDependencies + project.compileRuntimeDependencies +
|
||||
context.variant.buildType.compileDependencies +
|
||||
context.variant.buildType.compileRuntimeDependencies +
|
||||
context.variant.productFlavor.compileDependencies +
|
||||
context.variant.productFlavor.compileRuntimeDependencies
|
||||
val transitiveDependencies = dependencyManager.calculateDependencies(project, context, dependentProjects,
|
||||
allDependencies)
|
||||
val transitiveDependencies = dependencyManager.calculateDependencies(project, context, allDependencies)
|
||||
transitiveDependencies.map {
|
||||
it.jarFile.get()
|
||||
}.forEach { file : File ->
|
||||
|
|
|
@ -34,6 +34,5 @@ interface IDependencyManager {
|
|||
* allDependencies is typically either compileDependencies or testDependencies
|
||||
*/
|
||||
fun calculateDependencies(project: Project?, context: KobaltContext,
|
||||
dependentProjects: List<ProjectDescription> = emptyList(),
|
||||
vararg allDependencies: List<IClasspathDependency>): List<IClasspathDependency>
|
||||
}
|
|
@ -85,14 +85,13 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
|
|||
* allDependencies is typically either compileDependencies or testDependencies
|
||||
*/
|
||||
override fun calculateDependencies(project: Project?, context: KobaltContext,
|
||||
dependentProjects: List<ProjectDescription>,
|
||||
vararg allDependencies: List<IClasspathDependency>): List<IClasspathDependency> {
|
||||
val result = arrayListOf<IClasspathDependency>()
|
||||
allDependencies.forEach { dependencies ->
|
||||
result.addAll(transitiveClosure(dependencies))
|
||||
}
|
||||
result.addAll(runClasspathContributors(project, context))
|
||||
result.addAll(dependentProjectDependencies(dependentProjects, project, context))
|
||||
result.addAll(dependentProjectDependencies(project, context))
|
||||
|
||||
return result
|
||||
}
|
||||
|
@ -169,27 +168,25 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
|
|||
* If this project depends on other projects, we need to include their jar file and also
|
||||
* their own dependencies
|
||||
*/
|
||||
private fun dependentProjectDependencies(projectDescriptions: List<ProjectDescription>,
|
||||
private fun dependentProjectDependencies(
|
||||
project: Project?, context: KobaltContext) : List<IClasspathDependency> {
|
||||
val result = arrayListOf<IClasspathDependency>()
|
||||
projectDescriptions.filter {
|
||||
it.project.name == project?.name
|
||||
}.forEach { pd ->
|
||||
pd.dependsOn.forEach { p ->
|
||||
if (project == null) {
|
||||
return emptyList()
|
||||
} else {
|
||||
val result = arrayListOf<IClasspathDependency>()
|
||||
project.projectExtra.dependsOn.forEach { p ->
|
||||
result.add(FileDependency(KFiles.joinDir(p.directory, p.classesDir(context))))
|
||||
val otherDependencies = calculateDependencies(p, context, projectDescriptions,
|
||||
p.compileDependencies)
|
||||
val otherDependencies = calculateDependencies(p, context, p.compileDependencies)
|
||||
result.addAll(otherDependencies)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
private fun dependencies(project: Project, context: KobaltContext, isTest: Boolean)
|
||||
: List<IClasspathDependency> {
|
||||
val transitive = hashSetOf<IClasspathDependency>()
|
||||
val projects = listOf(ProjectDescription(project, project.projectExtra.dependsOn))
|
||||
with(project) {
|
||||
val deps = arrayListOf(compileDependencies, compileProvidedDependencies,
|
||||
context.variant.buildType.compileDependencies,
|
||||
|
@ -202,7 +199,7 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
|
|||
deps.add(testProvidedDependencies)
|
||||
}
|
||||
deps.filter { it.any() }.forEach {
|
||||
transitive.addAll(calculateDependencies(project, context, projects, it))
|
||||
transitive.addAll(calculateDependencies(project, context, it))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue