mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-25 16:07:12 -07:00
Kobalt.findPlugin()
This commit is contained in:
parent
e7bb67e0ce
commit
72a03ce157
8 changed files with 21 additions and 12 deletions
|
@ -51,8 +51,6 @@ public class Plugins @Inject constructor (val taskManagerProvider : Provider<Tas
|
|||
// return storageMap.get(pluginName)?.get(key)
|
||||
// }
|
||||
|
||||
val defaultPlugin : Plugin get() = getPlugin(DefaultPlugin.NAME)!!
|
||||
|
||||
fun addPlugin(pluginClass : Class<out Plugin>) {
|
||||
addPluginInstance(Kobalt.INJECTOR.getInstance(pluginClass))
|
||||
}
|
||||
|
@ -74,8 +72,6 @@ public class Plugins @Inject constructor (val taskManagerProvider : Provider<Tas
|
|||
}
|
||||
}
|
||||
|
||||
public fun getPlugin(name: String) : Plugin? = pluginMap.get(name)
|
||||
|
||||
public val plugins : List<Plugin>
|
||||
get() = ArrayList(pluginMap.values())
|
||||
|
||||
|
@ -83,6 +79,10 @@ public class Plugins @Inject constructor (val taskManagerProvider : Provider<Tas
|
|||
* The list of plugins found in the build file.
|
||||
*/
|
||||
public val dynamicPlugins : ArrayList<IClasspathDependency> = arrayListOf()
|
||||
|
||||
val defaultPlugin : Plugin get() = findPlugin(DefaultPlugin.NAME)!!
|
||||
|
||||
public fun findPlugin(name: String) : Plugin? = pluginMap.get(name)
|
||||
}
|
||||
|
||||
fun applyPlugins(context: KobaltContext, projects: List<Project>) {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.beust.kobalt.api
|
||||
|
||||
import com.beust.kobalt.Plugins
|
||||
import com.beust.kobalt.misc.Topological
|
||||
import com.beust.kobalt.plugins
|
||||
import com.google.common.collect.ArrayListMultimap
|
||||
import com.google.inject.Injector
|
||||
import java.io.File
|
||||
|
@ -92,5 +94,7 @@ public class Kobalt {
|
|||
*/
|
||||
fun sortProjects(allProjects: ArrayList<Project>) : List<Project>
|
||||
= topological.sort(allProjects)
|
||||
|
||||
fun findPlugin(name: String) = Plugins.findPlugin(name)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package com.beust.kobalt.api
|
||||
|
||||
import com.beust.kobalt.Args
|
||||
import com.beust.kobalt.Plugins
|
||||
|
||||
public class KobaltContext(val args: Args)
|
||||
public class KobaltContext(val args: Args) {
|
||||
fun findPlugin(name: String) = Plugins.findPlugin(name)
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public class RepoFinder @Inject constructor(val http: Http, val executors: Kobal
|
|||
val cs = ExecutorCompletionService<RepoResult>(executor)
|
||||
|
||||
try {
|
||||
log(2, "Looking for ${id}")
|
||||
log(2, "Looking for $id")
|
||||
Kobalt.repos.forEach { cs.submit(RepoFinderCallable(id, it)) }
|
||||
for (i in 0..Kobalt.repos.size() - 1) {
|
||||
try {
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.beust.kobalt.plugin.apt
|
|||
import com.beust.kobalt.Plugins
|
||||
import com.beust.kobalt.api.BasePlugin
|
||||
import com.beust.kobalt.api.Dependencies
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.api.annotation.Directive
|
||||
import com.beust.kobalt.api.annotation.Task
|
||||
|
@ -33,5 +34,5 @@ public class AptPlugin : BasePlugin(), KobaltLogger {
|
|||
|
||||
@Directive
|
||||
public fun Dependencies.apt(dep: String) {
|
||||
(Plugins.getPlugin("apt") as AptPlugin).addApt(dep)
|
||||
(Kobalt.findPlugin("apt") as AptPlugin).addApt(dep)
|
||||
}
|
|
@ -113,7 +113,7 @@ public fun kotlinProject(vararg project: Project, init: KotlinProject.() -> Unit
|
|||
|
||||
class KotlinCompilerConfig {
|
||||
fun args(vararg options: String) {
|
||||
(Plugins.getPlugin("kotlin") as KotlinPlugin).addCompilerArgs(*options)
|
||||
(Kobalt.findPlugin("kotlin") as KotlinPlugin).addCompilerArgs(*options)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.beust.kobalt.IFileSpec.Glob
|
|||
import com.beust.kobalt.IFileSpec
|
||||
import com.beust.kobalt.Plugins
|
||||
import com.beust.kobalt.api.BasePlugin
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.api.annotation.Directive
|
||||
import com.beust.kobalt.api.annotation.Task
|
||||
|
@ -239,7 +240,7 @@ class Package(val project: Project) : AttributeHolder {
|
|||
val zips = arrayListOf<Zip>()
|
||||
|
||||
init {
|
||||
(Plugins.getPlugin("packaging") as PackagingPlugin).addPackage(this)
|
||||
(Kobalt.findPlugin("packaging") as PackagingPlugin).addPackage(this)
|
||||
}
|
||||
|
||||
@Directive
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.beust.kobalt.plugin.publish
|
|||
import com.beust.klaxon.string
|
||||
import com.beust.kobalt.Plugins
|
||||
import com.beust.kobalt.api.BasePlugin
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.api.annotation.Directive
|
||||
import com.beust.kobalt.api.annotation.Task
|
||||
|
@ -87,8 +88,7 @@ public class PublishPlugin @Inject constructor(val http: Http, val files: com.be
|
|||
//
|
||||
configuration?.let { conf : JCenterConfiguration ->
|
||||
conf.files.forEach {
|
||||
val taskResult = jcenter.uploadFile(File(project.directory, it.first), it.second /* url */,
|
||||
conf)
|
||||
val taskResult = jcenter.uploadFile(File(project.directory, it.first), it.second /* url */, conf)
|
||||
success = success and taskResult.success
|
||||
if (!taskResult.success) {
|
||||
messages.add(taskResult.errorMessage!!)
|
||||
|
@ -123,6 +123,6 @@ public fun jcenter(project: Project, ini: JCenterConfiguration.() -> Unit)
|
|||
: JCenterConfiguration {
|
||||
val pd = JCenterConfiguration(project)
|
||||
pd.ini()
|
||||
(Plugins.getPlugin("publish") as PublishPlugin).addConfiguration(project.name!!, pd)
|
||||
(Kobalt.findPlugin("publish") as PublishPlugin).addConfiguration(project.name!!, pd)
|
||||
return pd
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue