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.KobaltContext
|
||||||
import com.beust.kobalt.api.Project
|
import com.beust.kobalt.api.Project
|
||||||
import com.beust.kobalt.api.ProjectDescription
|
|
||||||
import com.beust.kobalt.archive.Archives
|
import com.beust.kobalt.archive.Archives
|
||||||
import com.beust.kobalt.archive.Jar
|
import com.beust.kobalt.archive.Jar
|
||||||
import com.beust.kobalt.internal.JvmCompilerPlugin
|
|
||||||
import com.beust.kobalt.maven.DependencyManager
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
import com.beust.kobalt.misc.*
|
import com.beust.kobalt.misc.*
|
||||||
import com.google.inject.Inject
|
import com.google.inject.Inject
|
||||||
|
@ -97,15 +95,12 @@ class JarGenerator @Inject constructor(val dependencyManager: DependencyManager)
|
||||||
|
|
||||||
val seen = hashSetOf<String>()
|
val seen = hashSetOf<String>()
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val dependentProjects = project.projectProperties.get(JvmCompilerPlugin.DEPENDENT_PROJECTS)
|
|
||||||
as List<ProjectDescription>
|
|
||||||
val allDependencies = project.compileDependencies + project.compileRuntimeDependencies +
|
val allDependencies = project.compileDependencies + project.compileRuntimeDependencies +
|
||||||
context.variant.buildType.compileDependencies +
|
context.variant.buildType.compileDependencies +
|
||||||
context.variant.buildType.compileRuntimeDependencies +
|
context.variant.buildType.compileRuntimeDependencies +
|
||||||
context.variant.productFlavor.compileDependencies +
|
context.variant.productFlavor.compileDependencies +
|
||||||
context.variant.productFlavor.compileRuntimeDependencies
|
context.variant.productFlavor.compileRuntimeDependencies
|
||||||
val transitiveDependencies = dependencyManager.calculateDependencies(project, context, dependentProjects,
|
val transitiveDependencies = dependencyManager.calculateDependencies(project, context, allDependencies)
|
||||||
allDependencies)
|
|
||||||
transitiveDependencies.map {
|
transitiveDependencies.map {
|
||||||
it.jarFile.get()
|
it.jarFile.get()
|
||||||
}.forEach { file : File ->
|
}.forEach { file : File ->
|
||||||
|
|
|
@ -34,6 +34,5 @@ interface IDependencyManager {
|
||||||
* allDependencies is typically either compileDependencies or testDependencies
|
* allDependencies is typically either compileDependencies or testDependencies
|
||||||
*/
|
*/
|
||||||
fun calculateDependencies(project: Project?, context: KobaltContext,
|
fun calculateDependencies(project: Project?, context: KobaltContext,
|
||||||
dependentProjects: List<ProjectDescription> = emptyList(),
|
|
||||||
vararg allDependencies: List<IClasspathDependency>): List<IClasspathDependency>
|
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
|
* allDependencies is typically either compileDependencies or testDependencies
|
||||||
*/
|
*/
|
||||||
override fun calculateDependencies(project: Project?, context: KobaltContext,
|
override fun calculateDependencies(project: Project?, context: KobaltContext,
|
||||||
dependentProjects: List<ProjectDescription>,
|
|
||||||
vararg allDependencies: List<IClasspathDependency>): List<IClasspathDependency> {
|
vararg allDependencies: List<IClasspathDependency>): List<IClasspathDependency> {
|
||||||
val result = arrayListOf<IClasspathDependency>()
|
val result = arrayListOf<IClasspathDependency>()
|
||||||
allDependencies.forEach { dependencies ->
|
allDependencies.forEach { dependencies ->
|
||||||
result.addAll(transitiveClosure(dependencies))
|
result.addAll(transitiveClosure(dependencies))
|
||||||
}
|
}
|
||||||
result.addAll(runClasspathContributors(project, context))
|
result.addAll(runClasspathContributors(project, context))
|
||||||
result.addAll(dependentProjectDependencies(dependentProjects, project, context))
|
result.addAll(dependentProjectDependencies(project, context))
|
||||||
|
|
||||||
return result
|
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
|
* If this project depends on other projects, we need to include their jar file and also
|
||||||
* their own dependencies
|
* their own dependencies
|
||||||
*/
|
*/
|
||||||
private fun dependentProjectDependencies(projectDescriptions: List<ProjectDescription>,
|
private fun dependentProjectDependencies(
|
||||||
project: Project?, context: KobaltContext) : List<IClasspathDependency> {
|
project: Project?, context: KobaltContext) : List<IClasspathDependency> {
|
||||||
val result = arrayListOf<IClasspathDependency>()
|
if (project == null) {
|
||||||
projectDescriptions.filter {
|
return emptyList()
|
||||||
it.project.name == project?.name
|
} else {
|
||||||
}.forEach { pd ->
|
val result = arrayListOf<IClasspathDependency>()
|
||||||
pd.dependsOn.forEach { p ->
|
project.projectExtra.dependsOn.forEach { p ->
|
||||||
result.add(FileDependency(KFiles.joinDir(p.directory, p.classesDir(context))))
|
result.add(FileDependency(KFiles.joinDir(p.directory, p.classesDir(context))))
|
||||||
val otherDependencies = calculateDependencies(p, context, projectDescriptions,
|
val otherDependencies = calculateDependencies(p, context, p.compileDependencies)
|
||||||
p.compileDependencies)
|
|
||||||
result.addAll(otherDependencies)
|
result.addAll(otherDependencies)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dependencies(project: Project, context: KobaltContext, isTest: Boolean)
|
private fun dependencies(project: Project, context: KobaltContext, isTest: Boolean)
|
||||||
: List<IClasspathDependency> {
|
: List<IClasspathDependency> {
|
||||||
val transitive = hashSetOf<IClasspathDependency>()
|
val transitive = hashSetOf<IClasspathDependency>()
|
||||||
val projects = listOf(ProjectDescription(project, project.projectExtra.dependsOn))
|
|
||||||
with(project) {
|
with(project) {
|
||||||
val deps = arrayListOf(compileDependencies, compileProvidedDependencies,
|
val deps = arrayListOf(compileDependencies, compileProvidedDependencies,
|
||||||
context.variant.buildType.compileDependencies,
|
context.variant.buildType.compileDependencies,
|
||||||
|
@ -202,7 +199,7 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
|
||||||
deps.add(testProvidedDependencies)
|
deps.add(testProvidedDependencies)
|
||||||
}
|
}
|
||||||
deps.filter { it.any() }.forEach {
|
deps.filter { it.any() }.forEach {
|
||||||
transitive.addAll(calculateDependencies(project, context, projects, it))
|
transitive.addAll(calculateDependencies(project, context, it))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.beust.kobalt.api.annotation.Task
|
||||||
import com.beust.kobalt.archive.Archives
|
import com.beust.kobalt.archive.Archives
|
||||||
import com.beust.kobalt.archive.Jar
|
import com.beust.kobalt.archive.Jar
|
||||||
import com.beust.kobalt.internal.ActorUtils
|
import com.beust.kobalt.internal.ActorUtils
|
||||||
import com.beust.kobalt.internal.JvmCompilerPlugin
|
|
||||||
import com.beust.kobalt.maven.DependencyManager
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
import com.beust.kobalt.misc.KobaltExecutors
|
import com.beust.kobalt.misc.KobaltExecutors
|
||||||
|
@ -106,12 +105,10 @@ class ApplicationPlugin @Inject constructor(val configActor: ConfigActor<Applica
|
||||||
val java = JavaInfo.create(File(SystemProperties.javaBase)).javaExecutable!!
|
val java = JavaInfo.create(File(SystemProperties.javaBase)).javaExecutable!!
|
||||||
if (! isFatJar(packages, jarName)) {
|
if (! isFatJar(packages, jarName)) {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val projDeps = project.projectProperties.get(JvmCompilerPlugin.DEPENDENT_PROJECTS)
|
|
||||||
as List<ProjectDescription>
|
|
||||||
// If the jar file is not fat, we need to add the transitive closure of all dependencies
|
// If the jar file is not fat, we need to add the transitive closure of all dependencies
|
||||||
// on the classpath
|
// on the classpath
|
||||||
val allTheDependencies =
|
val allTheDependencies =
|
||||||
dependencyManager.calculateDependencies(project, context, projDeps,
|
dependencyManager.calculateDependencies(project, context,
|
||||||
allDependencies = project.compileDependencies).map { it.jarFile.get().path }
|
allDependencies = project.compileDependencies).map { it.jarFile.get().path }
|
||||||
allDeps.addAll(allTheDependencies)
|
allDeps.addAll(allTheDependencies)
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,8 +118,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
|
||||||
val analyzer = Analyzer().apply {
|
val analyzer = Analyzer().apply {
|
||||||
jar = aQute.bnd.osgi.Jar(project.projectProperties.get(Archives.JAR_NAME) as String)
|
jar = aQute.bnd.osgi.Jar(project.projectProperties.get(Archives.JAR_NAME) as String)
|
||||||
val dependencies = project.compileDependencies + project.compileRuntimeDependencies
|
val dependencies = project.compileDependencies + project.compileRuntimeDependencies
|
||||||
val dependentProjects = project.dependentProjects
|
dependencyManager.calculateDependencies(project, context, dependencies).forEach {
|
||||||
dependencyManager.calculateDependencies(project, context, dependentProjects, dependencies).forEach {
|
|
||||||
addClasspath(it.jarFile.get())
|
addClasspath(it.jarFile.get())
|
||||||
}
|
}
|
||||||
setProperty(Analyzer.BUNDLE_VERSION, project.version)
|
setProperty(Analyzer.BUNDLE_VERSION, project.version)
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
package com.beust.kobalt.plugin.packaging
|
package com.beust.kobalt.plugin.packaging
|
||||||
|
|
||||||
import com.beust.kobalt.archive.Archives
|
|
||||||
import com.beust.kobalt.IFileSpec
|
import com.beust.kobalt.IFileSpec
|
||||||
import com.beust.kobalt.JarGenerator
|
import com.beust.kobalt.JarGenerator
|
||||||
import com.beust.kobalt.archive.War
|
|
||||||
import com.beust.kobalt.api.IClasspathDependency
|
import com.beust.kobalt.api.IClasspathDependency
|
||||||
import com.beust.kobalt.api.KobaltContext
|
import com.beust.kobalt.api.KobaltContext
|
||||||
import com.beust.kobalt.api.Project
|
import com.beust.kobalt.api.Project
|
||||||
import com.beust.kobalt.api.ProjectDescription
|
import com.beust.kobalt.archive.Archives
|
||||||
|
import com.beust.kobalt.archive.War
|
||||||
import com.beust.kobalt.maven.DependencyManager
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
import com.beust.kobalt.misc.From
|
import com.beust.kobalt.misc.From
|
||||||
import com.beust.kobalt.misc.IncludedFile
|
import com.beust.kobalt.misc.IncludedFile
|
||||||
|
@ -40,9 +39,7 @@ class WarGenerator @Inject constructor(val dependencyManager: DependencyManager)
|
||||||
// The transitive closure of libraries goes into WEB-INF/libs.
|
// The transitive closure of libraries goes into WEB-INF/libs.
|
||||||
// Copy them all in kobaltBuild/war/WEB-INF/libs and create one IncludedFile out of that directory
|
// Copy them all in kobaltBuild/war/WEB-INF/libs and create one IncludedFile out of that directory
|
||||||
//
|
//
|
||||||
val dependentProjects = listOf(ProjectDescription(project, project.projectExtra.dependsOn))
|
val allDependencies = dependencyManager.calculateDependencies(project, context, project.compileDependencies)
|
||||||
val allDependencies = dependencyManager.calculateDependencies(project, context, dependentProjects,
|
|
||||||
project.compileDependencies)
|
|
||||||
|
|
||||||
val outDir = project.buildDirectory + "/war"
|
val outDir = project.buildDirectory + "/war"
|
||||||
val fullDir = outDir + "/" + LIB
|
val fullDir = outDir + "/" + LIB
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue