quarkusio/quarkus · error · MojoExecutionException
Unable to collect the target directories
Error message
Unable to collect the target directories
What it means
findTargetDirectories walks the scan directory looking for extension target directories; any IOException during that walk is wrapped in a MojoExecutionException 'Unable to collect the target directories'. This happens before any generation work starts.
Source
Thrown at devtools/config-doc-maven-plugin/src/main/java/io/quarkus/maven/config/doc/GenerateConfigDocMojo.java:311
// a directory containing a .git file or directory is the root of a separate checkout
// (e.g. a git worktree for another branch kept inside the project directory); its
// target/ directories belong to a different build and must not be merged into this one.
// this doesn't apply to the scan root itself, which is normally the project's own repo root.
if (!dir.equals(scanDirectory) && Files.exists(dir.resolve(".git"))) {
return FileVisitResult.SKIP_SUBTREE;
}
return FileVisitResult.CONTINUE;
}
});
// Make sure we are deterministic
Collections.sort(targets);
return targets;
} catch (IOException e) {
throw new MojoExecutionException("Unable to collect the target directories", e);
}
}
private static Engine initializeQuteEngine(Formatter formatter, Set<String> duplicatePropertyPaths, Format format,
String theme) {
EngineBuilder engineBuilder = Engine.builder()
.addDefaults()
.addSectionHelper(new UserTagSectionHelper.Factory("configProperty", "configProperty"))
.addSectionHelper(new UserTagSectionHelper.Factory("configSection", "configSection"))
.addSectionHelper(new UserTagSectionHelper.Factory("envVar", "envVar"))
.addSectionHelper(new UserTagSectionHelper.Factory("durationNote", "durationNote"))
.addSectionHelper(new UserTagSectionHelper.Factory("memorySizeNote", "memorySizeNote"))
.addValueResolver(new ReflectionValueResolver())
.addValueResolver(ValueResolver.builder()
.applyToBaseClass(String.class)
.applyToName("escapeCellContent")
.applyToNoParameters()
.resolveSync(ctx -> formatter.escapeCellContent((String) ctx.getBase()))View on GitHub (pinned to e1c734241f)
Solutions
- Verify the configured scanDirectory exists and is readable
- Run the plugin from the repository root of a Quarkus extensions checkout
- Check directory permissions and remove broken symlinks before retrying
Example fix
// before (dir missing)
mvn quarkus:generate-config-doc -DscanDirectory=./missing-extensions
// after
mvn quarkus:generate-config-doc -DscanDirectory=${project.basedir}/extensions Defensive patterns
Strategy: validation
Validate before calling
Path scan = Paths.get(scanDirectory);
if (!Files.isDirectory(scan) || !Files.isReadable(scan)) {
throw new IllegalStateException("Invalid scanDirectory: " + scan);
} Try / catch
try {
mojo.execute();
} catch (MojoExecutionException e) {
if (e.getMessage().contains("Unable to collect the target directories")) {
logger.error("Check scanDirectory exists and is readable", e.getCause());
}
} Prevention
- Run the plugin from the repo root of a full Quarkus checkout
- Avoid broken symlinks in scanned trees
- Verify CI checkout completeness before doc generation
When it happens
Trigger: findTargetDirectories (invoked via targetDirectories) cannot traverse scanDirectory — it does not exist, lacks read permission, or an I/O error occurs during Files.walk/DirectoryStream iteration.
Common situations: Running the plugin outside a Quarkus multi-module checkout so the scan directory is missing; CI checkouts with restricted permissions; symlink loops or deleted directories mid-scan.
Related errors
- Unable to create directory: ${directory}
- Could not create directory ${outputDirectory}
- Could not create directory ${outputDirectory}
- Failed to create <classesDir>
- Failed to create the output dir ${projectFile}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/f6e2f2a6e6985607.
Report an issue: GitHub.