in src/it/setup_annotation-verify-plugin/src/main/java/org.apache.maven.plugins.compiler.it/SourcePathReadGoal.java [59:87]
private void assertGeneratedSourceFileFor(String sourceClass, List<String> sourceRoots)
throws MojoFailureException, MojoExecutionException {
String sourceFile = sourceClass.replace('.', '/').concat(".txt");
boolean found = false;
for (String root : sourceRoots) {
File f = new File(root, sourceFile);
getLog().info("Looking for: " + f);
if (f.exists()) {
try {
String[] nameParts = sourceClass.split("\\.");
String content = new String(Files.readAllBytes(f.toPath()));
if (!nameParts[nameParts.length - 1].equals(content)) {
throw new MojoFailureException("Non-matching content in: " + f + "\n expected: '" + sourceClass
+ "'\n found: '" + content + "'");
}
found = true;
break;
} catch (IOException e) {
throw new MojoExecutionException("Cannot read contents of: " + f, e);
}
}
}
if (!found) {
throw new MojoFailureException(
"Cannot find generated source file: " + sourceFile + " in:\n " + String.join("\n ", sourceRoots));
}
}