mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Add "update" and "checkVersions" as tasks.
This commit is contained in:
parent
8d72cfd12b
commit
de09321727
4 changed files with 30 additions and 4 deletions
|
@ -21,6 +21,8 @@ class KobaltContext(val args: Args) {
|
|||
|
||||
fun findPlugin(name: String) = Plugins.findPlugin(name)
|
||||
|
||||
val allProjects = arrayListOf<Project>()
|
||||
|
||||
/** For internal use only */
|
||||
val internalContext = InternalContext()
|
||||
|
||||
|
|
|
@ -235,6 +235,7 @@ private class Main @Inject constructor(
|
|||
}
|
||||
|
||||
val allProjects = findProjectResult.projects
|
||||
findProjectResult.context.allProjects.addAll(allProjects)
|
||||
|
||||
//
|
||||
// Now that we have projects, add all the repos from repo contributors that need a Project
|
||||
|
|
|
@ -42,6 +42,7 @@ public class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val b
|
|||
fun compileBuildFiles(args: Args): FindProjectResult {
|
||||
//
|
||||
// Create the KobaltContext
|
||||
// Note: can't use apply{} here or each field will refer to itself instead of the constructor field
|
||||
//
|
||||
val context = KobaltContext(args)
|
||||
context.pluginInfo = pluginInfo
|
||||
|
@ -61,7 +62,7 @@ public class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val b
|
|||
|
||||
val parsedBuildFiles = arrayListOf<ParsedBuildFile>()
|
||||
|
||||
class FindProjectResult(val projects: List<Project>, val pluginUrls: List<URL>,
|
||||
class FindProjectResult(val context: KobaltContext, val projects: List<Project>, val pluginUrls: List<URL>,
|
||||
val taskResult: TaskResult)
|
||||
|
||||
private fun findProjects(context: KobaltContext): FindProjectResult {
|
||||
|
@ -107,7 +108,8 @@ public class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val b
|
|||
|
||||
}
|
||||
val pluginUrls = parsedBuildFiles.flatMap { it.pluginUrls }
|
||||
return FindProjectResult(projects, pluginUrls, if (errorTaskResult != null) errorTaskResult!! else TaskResult())
|
||||
return FindProjectResult(context, projects, pluginUrls,
|
||||
if (errorTaskResult != null) errorTaskResult!! else TaskResult())
|
||||
}
|
||||
|
||||
private fun maybeCompileBuildFile(context: KobaltContext, buildFile: BuildFile, buildScriptJarFile: File,
|
||||
|
|
|
@ -1,16 +1,37 @@
|
|||
package com.beust.kobalt.plugin
|
||||
|
||||
import com.beust.kobalt.TaskResult
|
||||
import com.beust.kobalt.api.BasePlugin
|
||||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.api.annotation.Task
|
||||
import com.beust.kobalt.app.UpdateKobalt
|
||||
import com.beust.kobalt.misc.CheckVersions
|
||||
import com.google.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
/**
|
||||
* This plugin is used to gather tasks defined in build files, since these tasks don't really belong to any plugin.
|
||||
*/
|
||||
@Singleton
|
||||
public class KobaltPlugin : BasePlugin() {
|
||||
class KobaltPlugin @Inject constructor(val checkVersions: CheckVersions, val updateKobalt: UpdateKobalt)
|
||||
: BasePlugin () {
|
||||
|
||||
companion object {
|
||||
public val PLUGIN_NAME = "Kobalt"
|
||||
val PLUGIN_NAME = "Kobalt"
|
||||
}
|
||||
|
||||
override val name: String get() = PLUGIN_NAME
|
||||
|
||||
@Task(name = "checkVersions", description = "Display all the outdated dependencies")
|
||||
fun taskCheckVersions(project: Project) : TaskResult {
|
||||
checkVersions.run(context.allProjects)
|
||||
return TaskResult()
|
||||
}
|
||||
|
||||
@Task(name = "update", description = "Update Kobalt to the latest version")
|
||||
fun taskUpdate(project: Project) : TaskResult {
|
||||
updateKobalt.updateKobalt()
|
||||
return TaskResult()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue