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

Add "update" and "checkVersions" as tasks.

This commit is contained in:
Cedric Beust 2016-06-27 01:52:17 -08:00
parent 8d72cfd12b
commit de09321727
4 changed files with 30 additions and 4 deletions

View file

@ -21,6 +21,8 @@ class KobaltContext(val args: Args) {
fun findPlugin(name: String) = Plugins.findPlugin(name) fun findPlugin(name: String) = Plugins.findPlugin(name)
val allProjects = arrayListOf<Project>()
/** For internal use only */ /** For internal use only */
val internalContext = InternalContext() val internalContext = InternalContext()

View file

@ -235,6 +235,7 @@ private class Main @Inject constructor(
} }
val allProjects = findProjectResult.projects 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 // Now that we have projects, add all the repos from repo contributors that need a Project

View file

@ -42,6 +42,7 @@ public class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val b
fun compileBuildFiles(args: Args): FindProjectResult { fun compileBuildFiles(args: Args): FindProjectResult {
// //
// Create the KobaltContext // 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) val context = KobaltContext(args)
context.pluginInfo = pluginInfo context.pluginInfo = pluginInfo
@ -61,7 +62,7 @@ public class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val b
val parsedBuildFiles = arrayListOf<ParsedBuildFile>() 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) val taskResult: TaskResult)
private fun findProjects(context: KobaltContext): FindProjectResult { 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 } 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, private fun maybeCompileBuildFile(context: KobaltContext, buildFile: BuildFile, buildScriptJarFile: File,

View file

@ -1,16 +1,37 @@
package com.beust.kobalt.plugin package com.beust.kobalt.plugin
import com.beust.kobalt.TaskResult
import com.beust.kobalt.api.BasePlugin 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 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. * This plugin is used to gather tasks defined in build files, since these tasks don't really belong to any plugin.
*/ */
@Singleton @Singleton
public class KobaltPlugin : BasePlugin() { class KobaltPlugin @Inject constructor(val checkVersions: CheckVersions, val updateKobalt: UpdateKobalt)
: BasePlugin () {
companion object { companion object {
public val PLUGIN_NAME = "Kobalt" val PLUGIN_NAME = "Kobalt"
} }
override val name: String get() = PLUGIN_NAME 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()
}
} }