1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-27 08:38:13 -07:00

If a dependent project fails, fail the ones that follow.

This commit is contained in:
Cedric Beust 2016-01-15 01:51:59 +04:00
parent 23032f52d7
commit 60036dcb43
13 changed files with 144 additions and 119 deletions

View file

@ -55,7 +55,7 @@ class ApplicationPlugin @Inject constructor(val executors: KobaltExecutors,
val runContributor = ActorUtils.selectAffinityActor(project, context,
context.pluginInfo.runnerContributors)
if (runContributor != null && runContributor.affinity(project, context) > 0) {
return runContributor.run(project, context, dependencyManager.dependencies(project, context, projects()))
return runContributor.run(project, context, dependencyManager.dependencies(project, context))
} else {
warn("Couldn't find a runner for project ${project.name}")
return TaskResult()

View file

@ -75,10 +75,10 @@ class JavaPlugin @Inject constructor(
}
@Directive
public fun javaProject(vararg project: Project, init: JavaProject.() -> Unit): JavaProject {
public fun javaProject(vararg projects: Project, init: JavaProject.() -> Unit): JavaProject {
return JavaProject().apply {
init()
(Kobalt.findPlugin(JavaPlugin.PLUGIN_NAME) as BasePlugin).addProject(this, project)
(Kobalt.findPlugin(JavaPlugin.PLUGIN_NAME) as JvmCompilerPlugin).addDependentProjects(this, projects.toList())
}
}

View file

@ -9,7 +9,7 @@ import com.beust.kobalt.internal.BaseProjectInfo
import com.google.inject.Singleton
@Singleton
class JavaProjectInfo : BaseProjectInfo {
class JavaProjectInfo : BaseProjectInfo() {
override val sourceDirectory = "java"
override val defaultSourceDirectories = hashSetOf("src/main/java", "src/main/resources", "src/main/res")
override val defaultTestDirectories = hashSetOf("src/test/java", "src/test/resources", "src/test/res")

View file

@ -82,7 +82,7 @@ class KotlinPlugin @Inject constructor(
val result =
if (sourceFiles.size > 0) {
compilePrivate(project, dependencyManager.testDependencies(project, context, projects()),
compilePrivate(project, dependencyManager.testDependencies(project, context),
sourceFiles,
KFiles.makeOutputTestDir(project))
} else {
@ -153,10 +153,10 @@ class KotlinPlugin @Inject constructor(
* @param project: the list of projects that need to be built before this one.
*/
@Directive
fun kotlinProject(vararg project: Project, init: KotlinProject.() -> Unit): KotlinProject {
fun kotlinProject(vararg projects: Project, init: KotlinProject.() -> Unit): KotlinProject {
return KotlinProject().apply {
init()
(Kobalt.findPlugin(KotlinPlugin.PLUGIN_NAME) as BasePlugin).addProject(this, project)
(Kobalt.findPlugin(KotlinPlugin.PLUGIN_NAME) as JvmCompilerPlugin).addDependentProjects(this, projects.toList())
}
}

View file

@ -9,7 +9,7 @@ import com.beust.kobalt.internal.BaseProjectInfo
import com.google.inject.Singleton
@Singleton
class KotlinProjectInfo : BaseProjectInfo {
class KotlinProjectInfo : BaseProjectInfo() {
override val sourceDirectory = "kotlin"
override val defaultSourceDirectories = hashSetOf("src/main/kotlin", "src/main/resources", "src/main/res")
override val defaultTestDirectories = hashSetOf("src/test/kotlin", "src/test/resources", "src/test/res")

View file

@ -142,7 +142,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
val inf = arrayListOf<IncludedFile>()
packages.filter { it.project.name == project.name }.forEach { pkg ->
pkg.jars.forEach { inf.addAll(jarGenerator.findIncludedFiles(pkg.project, context, it)) }
pkg.wars.forEach { inf.addAll(warGenerator.findIncludedFiles(pkg.project, context, it, projects)) }
pkg.wars.forEach { inf.addAll(warGenerator.findIncludedFiles(pkg.project, context, it)) }
pkg.zips.forEach { inf.addAll(zipGenerator.findIncludedFiles(pkg.project, context, it)) }
}
@ -176,7 +176,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
project.projectProperties.put(PACKAGES, packages)
packages.filter { it.project.name == project.name }.forEach { pkg ->
pkg.jars.forEach { jarGenerator.generateJar(pkg.project, context, it) }
pkg.wars.forEach { warGenerator.generateWar(pkg.project, context, it, projects) }
pkg.wars.forEach { warGenerator.generateWar(pkg.project, context, it) }
pkg.zips.forEach { zipGenerator.generateZip(pkg.project, context, it) }
if (pkg.generatePom) {
pomFactory.create(project).generate()

View file

@ -18,8 +18,7 @@ import java.util.jar.JarOutputStream
class WarGenerator @Inject constructor(val dependencyManager: DependencyManager){
fun findIncludedFiles(project: Project, context: KobaltContext, war: War,
projects: List<ProjectDescription>) : List<IncludedFile> {
fun findIncludedFiles(project: Project, context: KobaltContext, war: War) : List<IncludedFile> {
//
// src/main/web app and classes
//
@ -32,7 +31,8 @@ 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 allDependencies = dependencyManager.calculateDependencies(project, context, projects,
val dependentProjects = listOf(ProjectDescription(project, project.projectInfo.dependsOn))
val allDependencies = dependencyManager.calculateDependencies(project, context, dependentProjects,
project.compileDependencies)
val WEB_INF = "WEB-INF/lib"
@ -65,15 +65,14 @@ class WarGenerator @Inject constructor(val dependencyManager: DependencyManager)
return result
}
fun generateWar(project: Project, context: KobaltContext, war: War,
projects: List<ProjectDescription>) : File {
fun generateWar(project: Project, context: KobaltContext, war: War) : File {
val manifest = java.util.jar.Manifest()//FileInputStream(mf))
war.attributes.forEach { attribute ->
manifest.mainAttributes.putValue(attribute.first, attribute.second)
}
val allFiles = findIncludedFiles(project, context, war, projects)
val allFiles = findIncludedFiles(project, context, war)
val jarFactory = { os: OutputStream -> JarOutputStream(os, manifest) }
return PackagingPlugin.generateArchive(project, context, war.name, ".war", allFiles,
false /* don't expand jar files */, jarFactory)