mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
If a dependent project fails, fail the ones that follow.
This commit is contained in:
parent
23032f52d7
commit
60036dcb43
13 changed files with 144 additions and 119 deletions
|
@ -12,14 +12,6 @@ abstract public class BasePlugin : IPlugin {
|
||||||
this.context = context
|
this.context = context
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The list of projects depended upon (e.g. val p = javaProject(dependentProject)).
|
|
||||||
*/
|
|
||||||
protected val projects = arrayListOf<ProjectDescription>()
|
|
||||||
|
|
||||||
fun addProject(project: Project, dependsOn: Array<out Project>) =
|
|
||||||
projects.add(ProjectDescription(project, dependsOn.toList()))
|
|
||||||
|
|
||||||
override lateinit var taskManager: TaskManager
|
override lateinit var taskManager: TaskManager
|
||||||
lateinit var plugins: Plugins
|
lateinit var plugins: Plugins
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,8 +75,7 @@ abstract class JvmCompilerPlugin @Inject constructor(
|
||||||
val runContributor = ActorUtils.selectAffinityActor(project, context,
|
val runContributor = ActorUtils.selectAffinityActor(project, context,
|
||||||
context.pluginInfo.testRunnerContributors)
|
context.pluginInfo.testRunnerContributors)
|
||||||
if (runContributor != null && runContributor.affinity(project, context) > 0) {
|
if (runContributor != null && runContributor.affinity(project, context) > 0) {
|
||||||
return runContributor.run(project, context, dependencyManager.testDependencies(project, context,
|
return runContributor.run(project, context, dependencyManager.testDependencies(project, context))
|
||||||
projects()))
|
|
||||||
} else {
|
} else {
|
||||||
log(1, "Couldn't find a test runner for project ${project.name}, not running any tests")
|
log(1, "Couldn't find a test runner for project ${project.name}, not running any tests")
|
||||||
return TaskResult()
|
return TaskResult()
|
||||||
|
@ -198,7 +197,18 @@ abstract class JvmCompilerPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun projects() = projects
|
val allProjects = arrayListOf<ProjectDescription>()
|
||||||
|
|
||||||
|
fun addDependentProjects(project: Project, dependents: List<Project>) {
|
||||||
|
project.projectInfo.dependsOn.addAll(dependents)
|
||||||
|
with(ProjectDescription(project, dependents)) {
|
||||||
|
allProjects.add(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun projects() : List<ProjectDescription> {
|
||||||
|
return allProjects
|
||||||
|
}
|
||||||
|
|
||||||
@Task(name = "doc", description = "Generate the documentation for the project")
|
@Task(name = "doc", description = "Generate the documentation for the project")
|
||||||
fun taskJavadoc(project: Project): TaskResult {
|
fun taskJavadoc(project: Project): TaskResult {
|
||||||
|
@ -229,9 +239,9 @@ abstract class JvmCompilerPlugin @Inject constructor(
|
||||||
copyResources(project, JvmCompilerPlugin.SOURCE_SET_MAIN)
|
copyResources(project, JvmCompilerPlugin.SOURCE_SET_MAIN)
|
||||||
|
|
||||||
val fullClasspath = if (isTest)
|
val fullClasspath = if (isTest)
|
||||||
dependencyManager.testDependencies(project, context, projects)
|
dependencyManager.testDependencies(project, context)
|
||||||
else
|
else
|
||||||
dependencyManager.dependencies(project, context, projects)
|
dependencyManager.dependencies(project, context)
|
||||||
|
|
||||||
// Remove all the excluded dependencies from the classpath
|
// Remove all the excluded dependencies from the classpath
|
||||||
val classpath = fullClasspath.filter {
|
val classpath = fullClasspath.filter {
|
||||||
|
|
|
@ -23,10 +23,16 @@ interface IProjectInfo {
|
||||||
*/
|
*/
|
||||||
fun generateBuildConfig(project: Project, context: KobaltContext, packageName: String, variant: Variant,
|
fun generateBuildConfig(project: Project, context: KobaltContext, packageName: String, variant: Variant,
|
||||||
buildConfigs: List<BuildConfig>) : String
|
buildConfigs: List<BuildConfig>) : String
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of projects that this project depends on
|
||||||
|
*/
|
||||||
|
val dependsOn: ArrayList<Project>
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BaseProjectInfo : IProjectInfo {
|
abstract class BaseProjectInfo : IProjectInfo {
|
||||||
fun generate(field: BuildConfigField) : String
|
abstract fun generate(field: BuildConfigField) : String
|
||||||
|
|
||||||
fun generate(type: String, name: String, value: Any) = generate(BuildConfigField(type, name, value))
|
fun generate(type: String, name: String, value: Any) = generate(BuildConfigField(type, name, value))
|
||||||
|
|
||||||
fun generateFieldsFromContributors(project: Project, context: KobaltContext)
|
fun generateFieldsFromContributors(project: Project, context: KobaltContext)
|
||||||
|
@ -35,4 +41,6 @@ interface BaseProjectInfo : IProjectInfo {
|
||||||
}.map {
|
}.map {
|
||||||
generate(it)
|
generate(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val dependsOn = arrayListOf<Project>()
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.beust.kobalt.api.Project
|
||||||
import com.beust.kobalt.api.annotation.IncrementalTask
|
import com.beust.kobalt.api.annotation.IncrementalTask
|
||||||
import com.beust.kobalt.api.annotation.Task
|
import com.beust.kobalt.api.annotation.Task
|
||||||
import com.beust.kobalt.misc.benchmarkMillis
|
import com.beust.kobalt.misc.benchmarkMillis
|
||||||
|
import com.beust.kobalt.misc.kobaltError
|
||||||
import com.beust.kobalt.misc.log
|
import com.beust.kobalt.misc.log
|
||||||
import com.google.common.collect.ArrayListMultimap
|
import com.google.common.collect.ArrayListMultimap
|
||||||
import com.google.common.collect.Multimap
|
import com.google.common.collect.Multimap
|
||||||
|
@ -51,116 +52,129 @@ public class TaskManager @Inject constructor(val args: Args, val incrementalMana
|
||||||
|
|
||||||
public fun runTargets(taskNames: List<String>, projects: List<Project>) : RunTargetResult {
|
public fun runTargets(taskNames: List<String>, projects: List<Project>) : RunTargetResult {
|
||||||
var result = 0
|
var result = 0
|
||||||
|
val failedProjects = hashSetOf<String>()
|
||||||
val messages = Collections.synchronizedList(arrayListOf<String>())
|
val messages = Collections.synchronizedList(arrayListOf<String>())
|
||||||
projects.forEach { project ->
|
projects.forEach { project ->
|
||||||
val projectName = project.name
|
|
||||||
// There can be multiple tasks by the same name (e.g. PackagingPlugin and AndroidPlugin both
|
|
||||||
// define "install"), so use a multimap
|
|
||||||
val tasksByNames = ArrayListMultimap.create<String, PluginTask>()
|
|
||||||
annotationTasks.filter {
|
|
||||||
it.project.name == project.name
|
|
||||||
}.forEach {
|
|
||||||
tasksByNames.put(it.name, it)
|
|
||||||
}
|
|
||||||
|
|
||||||
AsciiArt.logBox("Building ${project.name}")
|
AsciiArt.logBox("Building ${project.name}")
|
||||||
|
|
||||||
log(3, "Tasks:")
|
// Does the current project depend on any failed projects?
|
||||||
tasksByNames.keys().forEach {
|
val fp = project.projectInfo.dependsOn.filter {
|
||||||
log(3, " $it: " + tasksByNames.get(it))
|
failedProjects.contains(it.name)
|
||||||
}
|
}
|
||||||
val graph = DynamicGraph<PluginTask>()
|
if (fp.size > 0) {
|
||||||
taskNames.forEach { taskName ->
|
failedProjects.add(project.name)
|
||||||
val ti = TaskInfo(taskName)
|
kobaltError("Not building project ${project.name} since it depends on failed projects "
|
||||||
if (! tasksByNames.keys().contains(ti.taskName)) {
|
+ fp.joinToString(","))
|
||||||
throw KobaltException("Unknown task: $taskName")
|
} else {
|
||||||
|
val projectName = project.name
|
||||||
|
// There can be multiple tasks by the same name (e.g. PackagingPlugin and AndroidPlugin both
|
||||||
|
// define "install"), so use a multimap
|
||||||
|
val tasksByNames = ArrayListMultimap.create<String, PluginTask>()
|
||||||
|
annotationTasks.filter {
|
||||||
|
it.project.name == project.name
|
||||||
|
}.forEach {
|
||||||
|
tasksByNames.put(it.name, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ti.matches(projectName)) {
|
log(3, "Tasks:")
|
||||||
tasksByNames[ti.taskName].forEach { task ->
|
tasksByNames.keys().forEach {
|
||||||
if (task != null && task.plugin.accept(project)) {
|
log(3, " $it: " + tasksByNames.get(it))
|
||||||
val reverseAfter = hashMapOf<String, String>()
|
}
|
||||||
alwaysRunAfter.keys().forEach { from ->
|
val graph = DynamicGraph<PluginTask>()
|
||||||
val tasks = alwaysRunAfter.get(from)
|
taskNames.forEach { taskName ->
|
||||||
tasks.forEach {
|
val ti = TaskInfo(taskName)
|
||||||
reverseAfter.put(it, from)
|
if (!tasksByNames.keys().contains(ti.taskName)) {
|
||||||
}
|
throw KobaltException("Unknown task: $taskName")
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
if (ti.matches(projectName)) {
|
||||||
// If the current target is free, add it as a single node to the graph
|
tasksByNames[ti.taskName].forEach { task ->
|
||||||
//
|
if (task != null && task.plugin.accept(project)) {
|
||||||
val allFreeTasks = calculateFreeTasks(tasksByNames, reverseAfter)
|
val reverseAfter = hashMapOf<String, String>()
|
||||||
val currentFreeTask = allFreeTasks.filter {
|
alwaysRunAfter.keys().forEach { from ->
|
||||||
TaskInfo(projectName, it.name).taskName == task.name
|
val tasks = alwaysRunAfter.get(from)
|
||||||
}
|
tasks.forEach {
|
||||||
if (currentFreeTask.size == 1) {
|
reverseAfter.put(it, from)
|
||||||
currentFreeTask[0].let {
|
|
||||||
graph.addNode(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Add the transitive closure of the current task as edges to the graph
|
|
||||||
//
|
|
||||||
val transitiveClosure = calculateTransitiveClosure(project, tasksByNames, ti)
|
|
||||||
transitiveClosure.forEach { pluginTask ->
|
|
||||||
val rb = runBefore.get(pluginTask.name)
|
|
||||||
rb.forEach {
|
|
||||||
val tos = tasksByNames[it]
|
|
||||||
if (tos != null && tos.size > 0) {
|
|
||||||
tos.forEach { to ->
|
|
||||||
graph.addEdge(pluginTask, to)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log(1, "Couldn't find node $it: not applicable to project ${project.name}")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// If any of the nodes in the graph has an "alwaysRunAfter", add that edge too
|
// If the current target is free, add it as a single node to the graph
|
||||||
//
|
//
|
||||||
val allNodes = arrayListOf<PluginTask>()
|
val allFreeTasks = calculateFreeTasks(tasksByNames, reverseAfter)
|
||||||
allNodes.addAll(graph.nodes)
|
val currentFreeTask = allFreeTasks.filter {
|
||||||
allNodes.forEach { node ->
|
TaskInfo(projectName, it.name).taskName == task.name
|
||||||
val other = alwaysRunAfter.get(node.name)
|
}
|
||||||
other?.forEach { o ->
|
if (currentFreeTask.size == 1) {
|
||||||
tasksByNames[o]?.forEach {
|
currentFreeTask[0].let {
|
||||||
graph.addEdge(it, node)
|
graph.addNode(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Add the transitive closure of the current task as edges to the graph
|
||||||
|
//
|
||||||
|
val transitiveClosure = calculateTransitiveClosure(project, tasksByNames, ti)
|
||||||
|
transitiveClosure.forEach { pluginTask ->
|
||||||
|
val rb = runBefore.get(pluginTask.name)
|
||||||
|
rb.forEach {
|
||||||
|
val tos = tasksByNames[it]
|
||||||
|
if (tos != null && tos.size > 0) {
|
||||||
|
tos.forEach { to ->
|
||||||
|
graph.addEdge(pluginTask, to)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log(1, "Couldn't find node $it: not applicable to project ${project.name}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// If any of the nodes in the graph has an "alwaysRunAfter", add that edge too
|
||||||
|
//
|
||||||
|
val allNodes = arrayListOf<PluginTask>()
|
||||||
|
allNodes.addAll(graph.nodes)
|
||||||
|
allNodes.forEach { node ->
|
||||||
|
val other = alwaysRunAfter.get(node.name)
|
||||||
|
other?.forEach { o ->
|
||||||
|
tasksByNames[o]?.forEach {
|
||||||
|
graph.addEdge(it, node)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Now that we have a full graph, run it
|
// Now that we have a full graph, run it
|
||||||
//
|
//
|
||||||
log(3, "About to run graph:\n ${graph.dump()} ")
|
log(3, "About to run graph:\n ${graph.dump()} ")
|
||||||
|
|
||||||
val factory = object : IThreadWorkerFactory<PluginTask> {
|
val factory = object : IThreadWorkerFactory<PluginTask> {
|
||||||
override public fun createWorkers(nodes: List<PluginTask>): List<IWorker<PluginTask>> {
|
override public fun createWorkers(nodes: List<PluginTask>): List<IWorker<PluginTask>> {
|
||||||
// val tr = nodes.reduce { workers: List<TaskWorker>, node: PluginTask ->
|
// val tr = nodes.reduce { workers: List<TaskWorker>, node: PluginTask ->
|
||||||
// val result: List<TaskWorker> = workers + TaskWorker(listOf(node), args.dryRun, messages)
|
// val result: List<TaskWorker> = workers + TaskWorker(listOf(node), args.dryRun, messages)
|
||||||
// result
|
// result
|
||||||
// }
|
// }
|
||||||
val thisResult = arrayListOf<IWorker<PluginTask>>()
|
val thisResult = arrayListOf<IWorker<PluginTask>>()
|
||||||
nodes.forEach {
|
nodes.forEach {
|
||||||
thisResult.add(TaskWorker(listOf(it), args.dryRun, messages))
|
thisResult.add(TaskWorker(listOf(it), args.dryRun, messages))
|
||||||
|
}
|
||||||
|
return thisResult
|
||||||
}
|
}
|
||||||
return thisResult
|
}
|
||||||
|
|
||||||
|
val executor = DynamicGraphExecutor(graph, factory)
|
||||||
|
val thisResult = executor.run()
|
||||||
|
if (result == 0) {
|
||||||
|
result = thisResult
|
||||||
|
}
|
||||||
|
if (result != 0) {
|
||||||
|
failedProjects.add(project.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val executor = DynamicGraphExecutor(graph, factory)
|
|
||||||
val thisResult = executor.run()
|
|
||||||
if (result == 0) {
|
|
||||||
result = thisResult
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return RunTargetResult(result, messages)
|
return RunTargetResult(result, messages)
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,9 +114,9 @@ public class DependencyManager @Inject constructor(val executors: KobaltExecutor
|
||||||
/**
|
/**
|
||||||
* @return the compile dependencies for this project, including the contributors.
|
* @return the compile dependencies for this project, including the contributors.
|
||||||
*/
|
*/
|
||||||
fun dependencies(project: Project, context: KobaltContext,
|
fun dependencies(project: Project, context: KobaltContext) : List<IClasspathDependency> {
|
||||||
projects: List<ProjectDescription>) : List<IClasspathDependency> {
|
|
||||||
val result = arrayListOf<IClasspathDependency>()
|
val result = arrayListOf<IClasspathDependency>()
|
||||||
|
val projects = listOf(ProjectDescription(project, project.projectInfo.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) {
|
||||||
|
@ -131,9 +131,9 @@ public class DependencyManager @Inject constructor(val executors: KobaltExecutor
|
||||||
/**
|
/**
|
||||||
* @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,
|
fun testDependencies(project: Project, context: KobaltContext) : List<IClasspathDependency> {
|
||||||
projects: List<ProjectDescription>) : List<IClasspathDependency> {
|
|
||||||
val result = arrayListOf<IClasspathDependency>()
|
val result = arrayListOf<IClasspathDependency>()
|
||||||
|
val projects = listOf(ProjectDescription(project, project.projectInfo.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) {
|
||||||
|
|
|
@ -30,6 +30,8 @@ fun Any.warn(text: String) {
|
||||||
KobaltLogger.logger.warn(javaClass.simpleName, text)
|
KobaltLogger.logger.warn(javaClass.simpleName, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Any.kobaltError(text: String, e: Throwable? = null) = error(text, e)
|
||||||
|
|
||||||
fun Any.error(text: String, e: Throwable? = null) {
|
fun Any.error(text: String, e: Throwable? = null) {
|
||||||
KobaltLogger.logger.error(javaClass.simpleName, text, e)
|
KobaltLogger.logger.error(javaClass.simpleName, text, e)
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ class ApplicationPlugin @Inject constructor(val executors: KobaltExecutors,
|
||||||
val runContributor = ActorUtils.selectAffinityActor(project, context,
|
val runContributor = ActorUtils.selectAffinityActor(project, context,
|
||||||
context.pluginInfo.runnerContributors)
|
context.pluginInfo.runnerContributors)
|
||||||
if (runContributor != null && runContributor.affinity(project, context) > 0) {
|
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 {
|
} else {
|
||||||
warn("Couldn't find a runner for project ${project.name}")
|
warn("Couldn't find a runner for project ${project.name}")
|
||||||
return TaskResult()
|
return TaskResult()
|
||||||
|
|
|
@ -75,10 +75,10 @@ class JavaPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
public fun javaProject(vararg project: Project, init: JavaProject.() -> Unit): JavaProject {
|
public fun javaProject(vararg projects: Project, init: JavaProject.() -> Unit): JavaProject {
|
||||||
return JavaProject().apply {
|
return JavaProject().apply {
|
||||||
init()
|
init()
|
||||||
(Kobalt.findPlugin(JavaPlugin.PLUGIN_NAME) as BasePlugin).addProject(this, project)
|
(Kobalt.findPlugin(JavaPlugin.PLUGIN_NAME) as JvmCompilerPlugin).addDependentProjects(this, projects.toList())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import com.beust.kobalt.internal.BaseProjectInfo
|
||||||
import com.google.inject.Singleton
|
import com.google.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class JavaProjectInfo : BaseProjectInfo {
|
class JavaProjectInfo : BaseProjectInfo() {
|
||||||
override val sourceDirectory = "java"
|
override val sourceDirectory = "java"
|
||||||
override val defaultSourceDirectories = hashSetOf("src/main/java", "src/main/resources", "src/main/res")
|
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")
|
override val defaultTestDirectories = hashSetOf("src/test/java", "src/test/resources", "src/test/res")
|
||||||
|
|
|
@ -82,7 +82,7 @@ class KotlinPlugin @Inject constructor(
|
||||||
|
|
||||||
val result =
|
val result =
|
||||||
if (sourceFiles.size > 0) {
|
if (sourceFiles.size > 0) {
|
||||||
compilePrivate(project, dependencyManager.testDependencies(project, context, projects()),
|
compilePrivate(project, dependencyManager.testDependencies(project, context),
|
||||||
sourceFiles,
|
sourceFiles,
|
||||||
KFiles.makeOutputTestDir(project))
|
KFiles.makeOutputTestDir(project))
|
||||||
} else {
|
} else {
|
||||||
|
@ -153,10 +153,10 @@ class KotlinPlugin @Inject constructor(
|
||||||
* @param project: the list of projects that need to be built before this one.
|
* @param project: the list of projects that need to be built before this one.
|
||||||
*/
|
*/
|
||||||
@Directive
|
@Directive
|
||||||
fun kotlinProject(vararg project: Project, init: KotlinProject.() -> Unit): KotlinProject {
|
fun kotlinProject(vararg projects: Project, init: KotlinProject.() -> Unit): KotlinProject {
|
||||||
return KotlinProject().apply {
|
return KotlinProject().apply {
|
||||||
init()
|
init()
|
||||||
(Kobalt.findPlugin(KotlinPlugin.PLUGIN_NAME) as BasePlugin).addProject(this, project)
|
(Kobalt.findPlugin(KotlinPlugin.PLUGIN_NAME) as JvmCompilerPlugin).addDependentProjects(this, projects.toList())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import com.beust.kobalt.internal.BaseProjectInfo
|
||||||
import com.google.inject.Singleton
|
import com.google.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class KotlinProjectInfo : BaseProjectInfo {
|
class KotlinProjectInfo : BaseProjectInfo() {
|
||||||
override val sourceDirectory = "kotlin"
|
override val sourceDirectory = "kotlin"
|
||||||
override val defaultSourceDirectories = hashSetOf("src/main/kotlin", "src/main/resources", "src/main/res")
|
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")
|
override val defaultTestDirectories = hashSetOf("src/test/kotlin", "src/test/resources", "src/test/res")
|
||||||
|
|
|
@ -142,7 +142,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
|
||||||
val inf = arrayListOf<IncludedFile>()
|
val inf = arrayListOf<IncludedFile>()
|
||||||
packages.filter { it.project.name == project.name }.forEach { pkg ->
|
packages.filter { it.project.name == project.name }.forEach { pkg ->
|
||||||
pkg.jars.forEach { inf.addAll(jarGenerator.findIncludedFiles(pkg.project, context, it)) }
|
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)) }
|
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)
|
project.projectProperties.put(PACKAGES, packages)
|
||||||
packages.filter { it.project.name == project.name }.forEach { pkg ->
|
packages.filter { it.project.name == project.name }.forEach { pkg ->
|
||||||
pkg.jars.forEach { jarGenerator.generateJar(pkg.project, context, it) }
|
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) }
|
pkg.zips.forEach { zipGenerator.generateZip(pkg.project, context, it) }
|
||||||
if (pkg.generatePom) {
|
if (pkg.generatePom) {
|
||||||
pomFactory.create(project).generate()
|
pomFactory.create(project).generate()
|
||||||
|
|
|
@ -18,8 +18,7 @@ import java.util.jar.JarOutputStream
|
||||||
|
|
||||||
class WarGenerator @Inject constructor(val dependencyManager: DependencyManager){
|
class WarGenerator @Inject constructor(val dependencyManager: DependencyManager){
|
||||||
|
|
||||||
fun findIncludedFiles(project: Project, context: KobaltContext, war: War,
|
fun findIncludedFiles(project: Project, context: KobaltContext, war: War) : List<IncludedFile> {
|
||||||
projects: List<ProjectDescription>) : List<IncludedFile> {
|
|
||||||
//
|
//
|
||||||
// src/main/web app and classes
|
// 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.
|
// 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 allDependencies = dependencyManager.calculateDependencies(project, context, projects,
|
val dependentProjects = listOf(ProjectDescription(project, project.projectInfo.dependsOn))
|
||||||
|
val allDependencies = dependencyManager.calculateDependencies(project, context, dependentProjects,
|
||||||
project.compileDependencies)
|
project.compileDependencies)
|
||||||
|
|
||||||
val WEB_INF = "WEB-INF/lib"
|
val WEB_INF = "WEB-INF/lib"
|
||||||
|
@ -65,15 +65,14 @@ class WarGenerator @Inject constructor(val dependencyManager: DependencyManager)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun generateWar(project: Project, context: KobaltContext, war: War,
|
fun generateWar(project: Project, context: KobaltContext, war: War) : File {
|
||||||
projects: List<ProjectDescription>) : File {
|
|
||||||
|
|
||||||
val manifest = java.util.jar.Manifest()//FileInputStream(mf))
|
val manifest = java.util.jar.Manifest()//FileInputStream(mf))
|
||||||
war.attributes.forEach { attribute ->
|
war.attributes.forEach { attribute ->
|
||||||
manifest.mainAttributes.putValue(attribute.first, attribute.second)
|
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) }
|
val jarFactory = { os: OutputStream -> JarOutputStream(os, manifest) }
|
||||||
return PackagingPlugin.generateArchive(project, context, war.name, ".war", allFiles,
|
return PackagingPlugin.generateArchive(project, context, war.name, ".war", allFiles,
|
||||||
false /* don't expand jar files */, jarFactory)
|
false /* don't expand jar files */, jarFactory)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue