mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Introduce IAssemblyContributor.
This commit is contained in:
parent
9f2f96e38a
commit
52183bbf0a
3 changed files with 29 additions and 5 deletions
|
@ -0,0 +1,10 @@
|
|||
package com.beust.kobalt.api
|
||||
|
||||
import com.beust.kobalt.TaskResult
|
||||
|
||||
/**
|
||||
* Plug-ins that will be invoked during the "assemble" task.
|
||||
*/
|
||||
interface IAssemblyContributor {
|
||||
fun assemble(project: Project, context: KobaltContext) : TaskResult
|
||||
}
|
|
@ -3,7 +3,6 @@ package com.beust.kobalt.internal
|
|||
import com.beust.kobalt.api.*
|
||||
import com.beust.kobalt.misc.log
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
import javax.xml.bind.JAXBContext
|
||||
import javax.xml.bind.annotation.XmlElement
|
||||
|
@ -74,6 +73,7 @@ class PluginInfo(val xml: KobaltPluginXml, val classLoader: ClassLoader?) {
|
|||
val testSourceDirContributors = arrayListOf<ITestSourceDirectoryContributor>()
|
||||
val buildConfigFieldContributors = arrayListOf<IBuildConfigFieldContributor>()
|
||||
val taskContributors = arrayListOf<ITaskContributor>()
|
||||
val assemblyContributors = arrayListOf<IAssemblyContributor>()
|
||||
|
||||
// Not documented yet
|
||||
val buildConfigContributors = arrayListOf<IBuildConfigContributor>()
|
||||
|
@ -161,6 +161,7 @@ class PluginInfo(val xml: KobaltPluginXml, val classLoader: ClassLoader?) {
|
|||
if (this is IMavenIdInterceptor) mavenIdInterceptors.add(this)
|
||||
if (this is ITestSourceDirectoryContributor) testSourceDirContributors.add(this)
|
||||
if (this is IBuildConfigContributor) buildConfigContributors.add(this)
|
||||
if (this is IAssemblyContributor) assemblyContributors.add(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -191,6 +192,7 @@ class PluginInfo(val xml: KobaltPluginXml, val classLoader: ClassLoader?) {
|
|||
testSourceDirContributors.addAll(pluginInfo.testSourceDirContributors)
|
||||
mavenIdInterceptors.addAll(pluginInfo.mavenIdInterceptors)
|
||||
buildConfigContributors.addAll(pluginInfo.buildConfigContributors)
|
||||
assemblyContributors.addAll(pluginInfo.assemblyContributors)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue