private static PluginLocation setupLocation(Path path, PluginLocationType type, TestPlugins.TestPlugin plugin) {
        try {
            Path jarPath = TestPlugins.pluginPath(plugin).stream().findFirst().get();
            switch (type) {
                case CLASS_HIERARCHY: {
                    try (JarFile jarFile = new JarFile(jarPath.toFile())) {
                        jarFile.stream().forEach(jarEntry -> {
                            Path entryPath = path.resolve(jarEntry.getName());
                            try {
                                entryPath.getParent().toFile().mkdirs();
                                Files.copy(jarFile.getInputStream(jarEntry), entryPath, StandardCopyOption.REPLACE_EXISTING);
                            } catch (IOException e) {
                                throw new UncheckedIOException(e);
                            }
                        });
                    }
                    return new PluginLocation(path);
                }
                case SINGLE_JAR: {
                    Path outputJar = path.resolveSibling(path.getFileName() + ".jar");
                    outputJar.getParent().toFile().mkdirs();
                    Files.copy(jarPath, outputJar, StandardCopyOption.REPLACE_EXISTING);
                    outputJar.toUri().toURL().openConnection().setDefaultUseCaches(false);
                    disableCaching(outputJar);
                    return new PluginLocation(outputJar);
                }
                case MULTI_JAR: {
                    Path outputJar = path.resolve(jarPath.getFileName());
                    outputJar.getParent().toFile().mkdirs();
                    Files.copy(jarPath, outputJar, StandardCopyOption.REPLACE_EXISTING);
                    disableCaching(outputJar);
                    return new PluginLocation(path);
                }
                default:
                    throw new IllegalArgumentException("Unknown PluginLocationType");
            }
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }
Populate a writable disk path to be usable as a single plugin location.
The returned path will be usable as a single path.
@param path A non-existent path immediately within a writable directory, suggesting a location for this plugin.
@param type The format to which the on-disk plugin should conform
@param plugin The plugin which should be written to the specified path
@return The final usable path name to this location, in case it is different from the suggested input path.
tools/src/test/java/org/apache/kafka/tools/ConnectPluginPathTest.java