private static void compileJavaSources(Path sourceDir, Path binDir) throws IOException {
        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
        List<File> sourceFiles;
        try (Stream<Path> stream = Files.walk(sourceDir)) {
            sourceFiles = stream
                    .filter(Files::isRegularFile)
                    .map(Path::toFile)
                    .filter(file -> file.getName().endsWith(".java"))
                    .collect(Collectors.toList());
        }
        StringWriter writer = new StringWriter();
        List<String> options = Arrays.asList(
            "-d", binDir.toString() // Write class output to a different directory.
        );

        try (StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null)) {
            boolean success = compiler.getTask(
                writer,
                fileManager,
                null,
                options,
                null,
                fileManager.getJavaFileObjectsFromFiles(sourceFiles)
            ).call();
            if (!success) {
                throw new RuntimeException("Failed to compile test plugin:\n" + writer);
            }
        }
    }
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