private static void writeJar(JarOutputStream jar, Path inputDir, Predicate<String> removeRuntimeClasses) throws IOException {
        List<Path> paths;
        try (Stream<Path> stream = Files.walk(inputDir)) {
            paths = stream
                    .filter(Files::isRegularFile)
                    .filter(path -> !path.toFile().getName().endsWith(".java"))
                    .filter(path -> !removeRuntimeClasses.test(path.toFile().getName()))
                    .collect(Collectors.toList());
        }
        for (Path path : paths) {
            try (InputStream in = new BufferedInputStream(Files.newInputStream(path))) {
                jar.putNextEntry(new JarEntry(
                    inputDir.relativize(path)
                        .toFile()
                        .getPath()
                        .replace(File.separator, "/")
                ));
                byte[] buffer = new byte[1024];
                for (int count; (count = in.read(buffer)) != -1; ) {
                    jar.write(buffer, 0, count);
                }
                jar.closeEntry();
            }
        }
    }
Compile a directory of .java source files into .class files
.class files are placed into the same directory as their sources.

<p>Dependencies between source files in this directory are resolved against one another
and the classes present in the test environment.
See <a href="https://stackoverflow.com/questions/1563909/"/> for more information.
Additional dependencies in your plugins should be added as test scope to :connect:runtime.
@param sourceDir Directory containing java source files
@throws IOException if the files cannot be compiled
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/isolation/TestPlugins.java