Skip to content

Commit

Permalink
Merge pull request quarkusio#43169 from ChristianKernDev/fix-42908
Browse files Browse the repository at this point in the history
Fixes error if annotation processing directories do not exist
  • Loading branch information
gsmet authored Sep 10, 2024
2 parents fa0920b + dd8ae2c commit 26e5053
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ protected QuarkusFileManager(StandardJavaFileManager fileManager, Context contex
this.fileManager.setLocation(StandardLocation.SOURCE_OUTPUT, List.of(context.getGeneratedSourcesDirectory()));
}
if (context.getAnnotationProcessorPaths() != null) {
// Paths might be missing! (see: https://github.com/quarkusio/quarkus/issues/42908)
ensureDirectories(context.getAnnotationProcessorPaths());
this.fileManager.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH, context.getAnnotationProcessorPaths());
}
} catch (IOException e) {
Expand All @@ -39,13 +41,26 @@ public void reset(Context context) {
this.fileManager.setLocation(StandardLocation.SOURCE_OUTPUT, List.of(context.getGeneratedSourcesDirectory()));
}
if (context.getAnnotationProcessorPaths() != null) {
// Paths might be missing! (see: https://github.com/quarkusio/quarkus/issues/42908)
ensureDirectories(context.getAnnotationProcessorPaths());
this.fileManager.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH, context.getAnnotationProcessorPaths());
}
} catch (IOException e) {
throw new RuntimeException("Cannot reset file manager", e);
}
}

private void ensureDirectories(Iterable<File> directories) {
for (File directory : directories) {
if (!directory.exists()) {
final boolean success = directory.mkdirs();
if (!success) {
throw new RuntimeException("Cannot create directory " + directory);
}
}
}
}

@Override
public void close() throws IOException {
super.close();
Expand Down

0 comments on commit 26e5053

Please sign in to comment.