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

More plug-ins under ConfigPlugin.

This commit is contained in:
Cedric Beust 2015-11-15 18:45:27 -08:00
parent c8cdaeda27
commit 802325c16a
4 changed files with 21 additions and 42 deletions

View file

@ -4,7 +4,7 @@ import com.beust.kobalt.IFileSpec
import com.beust.kobalt.IFileSpec.FileSpec
import com.beust.kobalt.IFileSpec.Glob
import com.beust.kobalt.TaskResult
import com.beust.kobalt.api.BasePlugin
import com.beust.kobalt.api.ConfigPlugin
import com.beust.kobalt.api.Kobalt
import com.beust.kobalt.api.KobaltContext
import com.beust.kobalt.api.Project
@ -34,7 +34,7 @@ import javax.inject.Singleton
@Singleton
class PackagingPlugin @Inject constructor(val dependencyManager : DependencyManager,
val executors: KobaltExecutors, val localRepo: LocalRepo) : BasePlugin() {
val executors: KobaltExecutors, val localRepo: LocalRepo) : ConfigPlugin<InstallConfig>() {
companion object {
const val PLUGIN_NAME = "packaging"
@ -252,7 +252,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
@Task(name = PackagingPlugin.TASK_INSTALL, description = "Install the artifacts",
runAfter = arrayOf(PackagingPlugin.TASK_ASSEMBLE))
fun taskInstall(project: Project) : TaskResult {
val config = installConfigs[project.name]
val config = configurationFor(project)
if (config != null) {
val buildDir = project.projectProperties.getString(LIBS_DIR)
log(1, "Installing from $buildDir to ${config.libDir}")
@ -265,18 +265,13 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
return TaskResult()
}
private val installConfigs = hashMapOf<String, InstallConfig>()
fun addInstallConfig(project: Project, config: InstallConfig) =
installConfigs.put(project.name, config)
}
@Directive
fun Project.install(init: InstallConfig.() -> Unit) {
InstallConfig().let {
it.init()
(Kobalt.findPlugin(PackagingPlugin.PLUGIN_NAME) as PackagingPlugin).addInstallConfig(this, it)
(Kobalt.findPlugin(PackagingPlugin.PLUGIN_NAME) as PackagingPlugin).addConfiguration(this, it)
}
}