quarkusio/quarkus · error · BootstrapDependencyProcessingException

Failed to collect compile-only dependencies of ${artifact}

Error message

Failed to collect compile-only dependencies of ${artifact}

What it means

collectCompileOnly asks the Maven Resolver to build a dependency graph restricted to compile-only scope. If DependencyCollectionException occurs while collecting the graph, it is wrapped in a BootstrapDependencyProcessingException naming the root artifact whose dependencies could not be collected.

Source

Thrown at independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ApplicationDependencyResolver.java:423

                    depStack.add(node.getChildren());
                }
            }
            children = depStack.poll();
        }
        final CollectRequest request = new CollectRequest()
                .setDependencies(collectCompileOnly)
                .setManagedDependencies(new ArrayList<>(managedDeps.values()))
                .setRepositories(collectRtDepsRequest.getRepositories());
        if (collectRtDepsRequest.getRoot() != null) {
            request.setRoot(collectRtDepsRequest.getRoot());
        } else {
            request.setRootArtifact(collectRtDepsRequest.getRootArtifact());
        }

        try {
            root = resolver.getSystem().collectDependencies(resolver.getSession(), request).getRoot();
        } catch (DependencyCollectionException e) {
            throw new BootstrapDependencyProcessingException(
                    "Failed to collect compile-only dependencies of " + root.getArtifact(), e);
        }
        children = root.getChildren();
        int flags = DependencyFlags.DIRECT | DependencyFlags.COMPILE_ONLY;
        while (children != null) {
            for (DependencyNode node : children) {
                if (hasWinner(node)) {
                    continue;
                }
                var extInfo = getExtensionInfoOrNull(node.getArtifact(), node.getRepositories());
                var dep = appBuilder.getDependency(getKey(node.getArtifact()));
                if (dep == null) {
                    dep = newDependencyBuilder(node, resolver).setFlags(flags);
                    if (extInfo != null) {
                        dep.setFlags(DependencyFlags.RUNTIME_EXTENSION_ARTIFACT);
                        if (dep.isFlagSet(DependencyFlags.DIRECT)) {
                            dep.setFlags(DependencyFlags.TOP_LEVEL_RUNTIME_EXTENSION_ARTIFACT);
                        }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Inspect the wrapped DependencyCollectionException cause to identify the problematic node in the graph.
  2. Exclude or fix the offending dependency (check for cycles, invalid scopes, missing versions).
  3. Refresh the local cache for the affected artifacts (`mvn -U` or delete from ~/.m2/repository).
  4. Ensure all parents/BOMs referenced in the compile graph are resolvable from configured repositories.

Example fix

// before
<dependency>
  <groupId>com.example</groupId><artifactId>bad-lib</artifactId>
  <version>[2.0,)</version> <!-- range resolves to nothing -->
</dependency>
// after
<dependency>
  <groupId>com.example</groupId><artifactId>bad-lib</artifactId>
  <version>2.3.1</version>
</dependency>
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate dependency metadata sanity before collection:
for (var d : compileDeps) {
    if (d.getVersion() != null && d.getVersion().startsWith("[")) {
        throw new IllegalStateException("Dependency ranges may fail collection: " + d);
    }
}

Type guard

static boolean hasConcreteVersion(org.eclipse.aether.graph.Dependency d) {
    String v = d.getArtifact().getVersion();
    return v != null && !v.isEmpty() && !v.startsWith("[") && !v.startsWith("(");
}

Try / catch

try {
    appModel = resolver.resolve(...);
} catch (BootstrapDependencyProcessingException e) {
    if (e.getMessage().startsWith("Failed to collect compile-only dependencies")) {
        log.error("Inspect graph: " + e.getCause().getMessage(), e);
    }
    throw e;
}

Prevention

When it happens

Trigger: collectCompileOnly (invoked from resolve) calls resolver.getSystem().collectDependencies(...) and catches DependencyCollectionException — e.g. a dependency in the graph cannot be described, a conflicting/invalid POM, or an unresolvable dependency range.

Common situations: Cyclic or malformed dependency metadata in a third-party artifact; dependency ranges that resolve to nothing; POMs referencing missing parents somewhere in the compile graph.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/5f92bfb1a3dbd1ce. Report an issue: GitHub.