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

Add -pluginFiles.

This commit is contained in:
Cedric Beust 2016-02-14 19:42:06 -08:00
parent abfda1b451
commit 8d8bdad9e2
2 changed files with 26 additions and 6 deletions

View file

@ -16,7 +16,7 @@ class Args {
@Parameter(names = arrayOf("--client"))
var client: Boolean = false
@Parameter(names = arrayOf("--dev"), description = "Turn of dev mode, resulting in a more verbose log output")
@Parameter(names = arrayOf("--dev"), description = "Turn on dev mode, resulting in a more verbose log output")
var dev: Boolean = false
@Parameter(names = arrayOf("--download"), description = "Force a download from the downloadUrl in the wrapper")
@ -45,6 +45,9 @@ class Args {
@Parameter(names = arrayOf("--plugins"), description = "Comma-separated list of plug-in Maven id's")
var pluginIds: String? = null
@Parameter(names = arrayOf("--pluginJarFiles"), description = "Comma-separated list of plug-in jar files")
var pluginJarFiles: String? = null
@Parameter(names = arrayOf("--port"), description = "Port, if --server was specified")
var port: Int = DEFAULT_SERVER_PORT

View file

@ -1,7 +1,10 @@
package com.beust.kobalt
import com.beust.jcommander.JCommander
import com.beust.kobalt.api.*
import com.beust.kobalt.api.IClasspathDependency
import com.beust.kobalt.api.Kobalt
import com.beust.kobalt.api.PluginTask
import com.beust.kobalt.api.Project
import com.beust.kobalt.app.*
import com.beust.kobalt.app.remote.KobaltClient
import com.beust.kobalt.app.remote.KobaltServer
@ -11,8 +14,8 @@ import com.beust.kobalt.internal.TaskManager
import com.beust.kobalt.internal.build.BuildFile
import com.beust.kobalt.maven.DepFactory
import com.beust.kobalt.maven.Http
import com.beust.kobalt.maven.dependency.FileDependency
import com.beust.kobalt.misc.*
import com.google.common.collect.ArrayListMultimap
import com.google.common.collect.HashMultimap
import com.google.inject.Guice
import java.io.File
@ -66,16 +69,30 @@ private class Main @Inject constructor(
data class RunInfo(val jc: JCommander, val args: Args)
public fun run(jc: JCommander, args: Args, argv: Array<String>): Int {
// Install plug-ins requested from the command line
private fun installCommandLinePlugins(args: Args) : ClassLoader {
var pluginClassLoader = javaClass.classLoader
val dependencies = arrayListOf<IClasspathDependency>()
args.pluginIds?.let {
val dependencies = it.split(",").map { depFactory.create(it) }
dependencies.addAll(it.split(",").map { depFactory.create(it) })
}
args.pluginJarFiles?.let {
dependencies.addAll(it.split(",").map { FileDependency(it) })
}
if (dependencies.size > 0) {
val urls = dependencies.map { it.jarFile.get().toURI().toURL() }
pluginClassLoader = URLClassLoader(urls.toTypedArray())
plugins.installPlugins(dependencies, pluginClassLoader)
}
return pluginClassLoader
}
public fun run(jc: JCommander, args: Args, argv: Array<String>): Int {
//
// Install plug-ins requested from the command line
//
val pluginClassLoader = installCommandLinePlugins(args)
//
// Add all the plugins read in kobalt-plugin.xml to the Plugins singleton, so that code
// in the build file that calls Plugins.findPlugin() can find them (code in the