snehashisp commented on code in PR #18325: URL: https://github.com/apache/kafka/pull/18325#discussion_r2069326619
########## connect/runtime/src/test/java/org/apache/kafka/connect/runtime/isolation/TestPlugins.java: ########## @@ -477,6 +480,27 @@ private static void compileJavaSources(Path sourceDir, Path binDir) throws IOExc if (!success) { throw new RuntimeException("Failed to compile test plugin:\n" + writer); } + } finally { + if (!replacements.isEmpty()) { + sourceFiles.forEach(File::delete); + } + } + } + + private static File copyAndReplace(File source, Map<String, String> replacements) throws RuntimeException { + if (replacements.isEmpty()) { + return source; + } + try { + String content = Files.readString(source.toPath()); + for (Map.Entry<String, String> entry : replacements.entrySet()) { + content = content.replace(entry.getKey(), entry.getValue()); + } + File tmpFile = new File(System.getProperty("java.io.tmpdir") + File.separator + source.getName()); Review Comment: Tried this but it unfortunately always adds a random numerical id to the file generated, even with both prefix and suffix (with one of them as `""`). It will add the id in between the prefix and suffix. This fails compilation as the file name of the class is required to have the same name as the class with the `.java` suffix. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org