1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 16:28:12 -07:00

Introduce IAssemblyContributor.

This commit is contained in:
Cedric Beust 2016-03-04 03:06:28 +04:00
parent 9f2f96e38a
commit 52183bbf0a
3 changed files with 29 additions and 5 deletions

View file

@ -25,7 +25,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
val executors: KobaltExecutors, val jarGenerator: JarGenerator, val warGenerator: WarGenerator,
val zipGenerator: ZipGenerator, val taskContributor: TaskContributor,
val pomFactory: PomGenerator.IFactory, val configActor: ConfigActor<InstallConfig>)
: BasePlugin(), IConfigActor<InstallConfig> by configActor, ITaskContributor {
: BasePlugin(), IConfigActor<InstallConfig> by configActor, ITaskContributor, IAssemblyContributor {
companion object {
const val PLUGIN_NAME = "Packaging"
@ -140,9 +140,8 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
runTask = { doTaskAssemble(project) })
}
@Task(name = TASK_ASSEMBLE, description = "Package the artifacts",
runAfter = arrayOf(JvmCompilerPlugin.TASK_COMPILE))
fun doTaskAssemble(project: Project) : TaskResult {
// IAssemblyContributor
override fun assemble(project: Project, context: KobaltContext) : TaskResult {
try {
project.projectProperties.put(PACKAGES, packages)
packages.filter { it.project.name == project.name }.forEach { pkg ->
@ -159,6 +158,19 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
}
}
@Task(name = TASK_ASSEMBLE, description = "Package the artifacts",
runAfter = arrayOf(JvmCompilerPlugin.TASK_COMPILE))
fun doTaskAssemble(project: Project) : TaskResult {
context.pluginInfo.assemblyContributors.forEach {
val thisResult = it.assemble(project, context)
if (! thisResult.success) {
// Abort at the first failure
return thisResult
}
}
return TaskResult()
}
fun addPackage(p: PackageConfig) {
packages.add(p)
}