diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt index d7197526..39c4c2e1 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/JarGenerator.kt @@ -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() @Suppress("UNCHECKED_CAST") - val dependentProjects = project.projectProperties.get(JvmCompilerPlugin.DEPENDENT_PROJECTS) - as List 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 -> 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 76183629..9e47c0dc 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 @@ -34,6 +34,5 @@ interface IDependencyManager { * allDependencies is typically either compileDependencies or testDependencies */ fun calculateDependencies(project: Project?, context: KobaltContext, - dependentProjects: List = emptyList(), vararg allDependencies: List): List } \ No newline at end of file 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 8bda7d28..7fef033f 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 @@ -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, vararg allDependencies: List): List { val result = arrayListOf() 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, + private fun dependentProjectDependencies( project: Project?, context: KobaltContext) : List { - val result = arrayListOf() - projectDescriptions.filter { - it.project.name == project?.name - }.forEach { pd -> - pd.dependsOn.forEach { p -> + if (project == null) { + return emptyList() + } else { + val result = arrayListOf() + 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 { val transitive = hashSetOf() - 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)) } } 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 3b871016..8f0c6e8d 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/application/ApplicationPlugin.kt @@ -7,7 +7,6 @@ import com.beust.kobalt.api.annotation.Task import com.beust.kobalt.archive.Archives import com.beust.kobalt.archive.Jar import com.beust.kobalt.internal.ActorUtils -import com.beust.kobalt.internal.JvmCompilerPlugin import com.beust.kobalt.maven.DependencyManager import com.beust.kobalt.misc.KFiles import com.beust.kobalt.misc.KobaltExecutors @@ -106,12 +105,10 @@ class ApplicationPlugin @Inject constructor(val configActor: ConfigActor // If the jar file is not fat, we need to add the transitive closure of all dependencies // on the classpath val allTheDependencies = - dependencyManager.calculateDependencies(project, context, projDeps, + dependencyManager.calculateDependencies(project, context, allDependencies = project.compileDependencies).map { it.jarFile.get().path } allDeps.addAll(allTheDependencies) } diff --git a/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt index 16dea24c..79c5695e 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/packaging/PackagingPlugin.kt @@ -118,8 +118,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana val analyzer = Analyzer().apply { jar = aQute.bnd.osgi.Jar(project.projectProperties.get(Archives.JAR_NAME) as String) val dependencies = project.compileDependencies + project.compileRuntimeDependencies - val dependentProjects = project.dependentProjects - dependencyManager.calculateDependencies(project, context, dependentProjects, dependencies).forEach { + dependencyManager.calculateDependencies(project, context, dependencies).forEach { addClasspath(it.jarFile.get()) } setProperty(Analyzer.BUNDLE_VERSION, project.version) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/packaging/WarGenerator.kt b/src/main/kotlin/com/beust/kobalt/plugin/packaging/WarGenerator.kt index ad4b4f8d..a4826813 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/packaging/WarGenerator.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/packaging/WarGenerator.kt @@ -1,13 +1,12 @@ package com.beust.kobalt.plugin.packaging -import com.beust.kobalt.archive.Archives import com.beust.kobalt.IFileSpec import com.beust.kobalt.JarGenerator -import com.beust.kobalt.archive.War import com.beust.kobalt.api.IClasspathDependency 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.War import com.beust.kobalt.maven.DependencyManager import com.beust.kobalt.misc.From 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. // 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, dependentProjects, - project.compileDependencies) + val allDependencies = dependencyManager.calculateDependencies(project, context, project.compileDependencies) val outDir = project.buildDirectory + "/war" val fullDir = outDir + "/" + LIB