diff --git a/README.md b/README.md index 1b0c7d0a844a2..61b851098197f 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,16 @@ IntelliJ, using `$MODULE_DIR$` accomplishes this automatically. If `VM options` doesn't exist in the dialog, you need to select `Modify options` and enable `Add VM options`. +To adjust which plugins are enabled for the development server, adjust the value of +`plugin.bundles` in `config.properties`. Each entry in this list must represent a plugin +specified by one of the following options: +* A path to a `pom.xml` or `*.pom` file describing a Maven project that produces a plugin. +* Maven coordinates, in the form `:[:[:]]:`. The plugin will be loaded via Maven and therefore must be available in your local repository or a remote repository. +* A path to a plugin directory containing JAR files. See [Deploying a custom plugin](https://trino.io/docs/current/develop/spi-overview.html#deploying-a-custom-plugin) for more details. + +If you want to use a plugin in a catalog, you must add a corresponding +`.properties` file to `testing/trino-server-dev/etc/catalog`. + ### Running the CLI Start the CLI to connect to the server and run SQL queries: diff --git a/testing/trino-server-dev/src/main/java/io/trino/server/DevelopmentPluginsProvider.java b/testing/trino-server-dev/src/main/java/io/trino/server/DevelopmentPluginsProvider.java index ccd8c67574b80..df05f1e8e730b 100644 --- a/testing/trino-server-dev/src/main/java/io/trino/server/DevelopmentPluginsProvider.java +++ b/testing/trino-server-dev/src/main/java/io/trino/server/DevelopmentPluginsProvider.java @@ -24,13 +24,17 @@ import java.io.File; import java.io.IOException; import java.io.UncheckedIOException; +import java.net.MalformedURLException; import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.Executor; import java.util.function.Function; +import java.util.stream.Stream; import static com.google.common.collect.ImmutableList.toImmutableList; import static io.trino.server.PluginDiscovery.discoverPlugins; @@ -83,7 +87,12 @@ private PluginClassLoader doBuildClassLoader(String plugin, Function, if (file.isFile() && (file.getName().equals("pom.xml") || file.getName().endsWith(".pom"))) { return buildClassLoaderFromPom(file, classLoaderFactory); } - return buildClassLoaderFromCoordinates(plugin, classLoaderFactory); + else if (file.isDirectory()) { + return buildClassLoaderFromDirectory(file, classLoaderFactory); + } + else { + return buildClassLoaderFromCoordinates(plugin, classLoaderFactory); + } } private PluginClassLoader buildClassLoaderFromPom(File pomFile, Function, PluginClassLoader> classLoaderFactory) @@ -103,6 +112,24 @@ private PluginClassLoader buildClassLoaderFromPom(File pomFile, Function, PluginClassLoader> classLoaderFactory) + throws IOException + { + Function pathToUrl = path -> { + try { + return path.toUri().toURL(); + } + catch (MalformedURLException e) { + throw new UncheckedIOException(e); + } + }; + List jars; + try (Stream paths = Files.list(pluginDirectory.toPath())) { + jars = paths.map(pathToUrl).collect(toImmutableList()); + } + return classLoaderFactory.apply(jars); + } + private PluginClassLoader buildClassLoaderFromCoordinates(String coordinates, Function, PluginClassLoader> classLoaderFactory) throws IOException {