diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Args.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Args.kt index 7eca0631..e79e6cb4 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Args.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/Args.kt @@ -39,6 +39,9 @@ class Args { const val DEFAULT_SERVER_PORT = 1234 } + @Parameter(names = arrayOf("--plugins"), description = "Comma-separated list of plug-in Maven id's") + var pluginIds: String? = null + @Parameter(names = arrayOf("--port"), description = "Port, if --server was specified") var port: Int = DEFAULT_SERVER_PORT diff --git a/src/main/kotlin/com/beust/kobalt/Main.kt b/src/main/kotlin/com/beust/kobalt/Main.kt index 9096b885..f59f1a31 100644 --- a/src/main/kotlin/com/beust/kobalt/Main.kt +++ b/src/main/kotlin/com/beust/kobalt/Main.kt @@ -15,11 +15,13 @@ import com.beust.kobalt.internal.KobaltSettings import com.beust.kobalt.internal.PluginInfo 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.misc.* import com.google.common.collect.HashMultimap import com.google.inject.Guice import java.io.File +import java.net.URLClassLoader import java.nio.file.Paths import java.util.* import javax.inject.Inject @@ -60,12 +62,18 @@ private class Main @Inject constructor( val server: KobaltServer, val pluginInfo: PluginInfo, val projectGenerator: ProjectGenerator, + val depFactory: DepFactory, val resolveDependency: ResolveDependency) { data class RunInfo(val jc: JCommander, val args: Args) public fun run(jc: JCommander, args: Args, argv: Array): Int { -// github.uploadRelease("kobalt", "0.101", File("/Users/beust/t/a.zip")) + // Install plug-ins requested from the command line + args.pluginIds?.let { + val dependencies = it.split(",").map { depFactory.create(it) } + val urls = dependencies.map { it.jarFile.get().toURI().toURL() } + plugins.installPlugins(dependencies, URLClassLoader(urls.toTypedArray())) + } // // Add all the plugins read in kobalt-plugin.xml to the Plugins singleton, so that code diff --git a/src/main/kotlin/com/beust/kobalt/app/ProjectGenerator.kt b/src/main/kotlin/com/beust/kobalt/app/ProjectGenerator.kt index 945e19e8..8686dea4 100644 --- a/src/main/kotlin/com/beust/kobalt/app/ProjectGenerator.kt +++ b/src/main/kotlin/com/beust/kobalt/app/ProjectGenerator.kt @@ -14,9 +14,13 @@ public class ProjectGenerator @Inject constructor(val pluginInfo: PluginInfo){ File(args.buildFile).parentFile.mkdirs() args.archetypes?.let { archetypes -> val contributors = pluginInfo.initContributors.filter { archetypes.contains(it.archetypeName) } - contributors.forEach { - log(2, "Running archetype ${it.archetypeName}") - it.generateArchetype(args) + if (contributors.size > 0) { + contributors.forEach { + log(2, "Running archetype ${it.archetypeName}") + it.generateArchetype(args) + } + } else { + log(1, "Couldn't find any archetype named ${args.archetypes}") } } }