apache/maven · error · PluginConfigurationException

Unable to inject field '${resolution.getField()}' annotated

Error message

Unable to inject field '${resolution.getField()}' annotated with @Dependencies. Unsupported type ${field.getGenericType()}

What it means

For a @Dependencies-annotated field Maven performs dependency collection and then assigns the result only when the field type is DependencyResolverResult (or Node for the graph root); any other declared type leaves the result null, so Maven throws PluginConfigurationException naming the field and its unsupported generic type.

Source

Thrown at impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java:664

                            && ptv.getActualTypeArguments()[0] == Path.class) {
                        result = res.getDispatchedPaths();
                    } else if (k == Dependency.class && v == Path.class) {
                        result = res.getDependencies();
                    }
                }
            } else {
                // collection
                DependencyResolverResult res = sessionV4
                        .getService(DependencyResolver.class)
                        .collect(sessionV4, project, PathScope.MAIN_RUNTIME);
                if (field.getType() == DependencyResolverResult.class) {
                    result = res;
                } else if (field.getType() == Node.class) {
                    result = res.getRoot();
                }
            }
            if (result == null) {
                throw new PluginConfigurationException(
                        pluginDescriptor,
                        "Unable to inject field '" + resolution.getField()
                                + "' annotated with @Dependencies. Unsupported type " + field.getGenericType());
            }
            try {
                field.set(mojo, result);
            } catch (IllegalAccessException e) {
                throw new PluginConfigurationException(
                        pluginDescriptor,
                        "Unable to inject field '" + resolution.getField() + "' annotated with @Dependencies",
                        e);
            }
        }

        return mojo;
    }

    private <T> T loadV3Mojo(

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Change the field type to DependencyResolverResult for the full result, or Node for the collected graph root.
  2. Derive whatever collection you need from result.getRoot().getChildren() or result.getDependencies() instead of asking the annotation for it.
  3. Remove the annotation if you resolve dependencies yourself via the DependencyResolver service.

Example fix

// before
@Dependencies
private List<Node> nodes;
// after
@Dependencies
private DependencyResolverResult result;
// then: result.getRoot().getChildren()
Defensive patterns

Strategy: type-guard

Type guard

static boolean dependenciesFieldSupported(Field f) {
    Class<?> t = f.getType();
    return t == DependencyResolverResult.class || t == org.eclipse.aether.graph.Node.class;
}

Try / catch

try {
    mojo = pluginManager.getConfiguredMojo(mojoInterface, session, mojoExecution);
} catch (PluginConfigurationException e) {
    if (e.getMessage() != null && e.getMessage().contains("@Dependencies")) {
        // field type unsupported: switch to DependencyResolverResult/Node, then rebuild
    }
    throw e;
}

Prevention

When it happens

Trigger: Declaring the annotated field as List<Node>, Collection<Artifact>, Path, or any type other than DependencyResolverResult/Node - the injection machinery cannot map the collected graph onto it.

Common situations: Plugin developers adopting the Maven 4 @Dependencies annotation and guessing at collection types for the field.

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/cc5b2b7e1377c700. Report an issue: GitHub.