gradle/gradle · error · UnsupportedOperationException

Resolving artifacts by type is not yet supported for project

Error message

Resolving artifacts by type is not yet supported for project modules

What it means

ProjectDependencyResolver resolves artifacts for project components one at a time, but resolveArtifactsWithType throws UnsupportedOperationException when asked for by-type artifact resolution on a project module: queries that select all artifacts of a given ArtifactTypeAttribute are only implemented for module repositories, not for local projects.

Source

Thrown at platforms/software/dependency-management/src/main/java/org/gradle/api/internal/artifacts/ivyservice/projectmodule/ProjectDependencyResolver.java:98

    @Override
    public void resolve(ComponentIdentifier identifier, ComponentOverrideMetadata componentOverrideMetadata, final BuildableComponentResolveResult result) {
        if (isProjectModule(identifier)) {
            ProjectComponentIdentifier projectId = (ProjectComponentIdentifier) identifier;
            LocalComponentGraphResolveState component = localComponentRegistry.getComponent(projectId);
            result.resolved(component, ComponentGraphSpecificResolveState.EMPTY_STATE);
        }
    }

    @Override
    public boolean isFetchingMetadataCheap(ComponentIdentifier identifier) {
        return true;
    }

    @Override
    public void resolveArtifactsWithType(ComponentArtifactResolveMetadata component, ArtifactType artifactType, BuildableArtifactSetResolveResult result) {
        if (isProjectModule(component.getId())) {
            throw new UnsupportedOperationException("Resolving artifacts by type is not yet supported for project modules");
        }
    }

    @Override
    public void resolveArtifact(ComponentArtifactResolveMetadata component, ComponentArtifactMetadata artifact, BuildableArtifactResolveResult result) {
        if (isProjectModule(artifact.getComponentId())) {
            artifactResolver.resolveArtifact(component, artifact, result);
        }
    }

    private static boolean isProjectModule(ComponentIdentifier componentId) {
        return componentId instanceof ProjectComponentIdentifier;
    }
}

View on GitHub (pinned to 534f27719b)

Solutions

  1. Request artifacts without the type filter and produce the type via an artifact transform (ArtifactActionContainer.registerArtifactTransform)
  2. Use a lenient view (configuration.incoming.artifactView { lenient(true) }) so unsupported project components are skipped instead of failing
  3. If by-type bulk resolution is essential, resolve against published modules (repository) rather than substituted projects

Example fix

// before
configurations.runtimeClasspath.incoming.artifactView {
    attributes { attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, 'jar') }
}.files // throws for project modules
// after
configurations.runtimeClasspath.incoming.artifactView {
    lenient(true)
    attributes { attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, 'jar') }
}.files
Defensive patterns

Strategy: fallback

Validate before calling

// Skip by-type artifact resolution when project modules are involved
def hasProjectModules = configuration.resolvedConfiguration.resolvedArtifacts.any {
    it.id.componentIdentifier instanceof org.gradle.api.artifacts.component.ProjectComponentIdentifier
}
if (!hasProjectModules) {
    doTypedArtifactQuery(configuration)
} else {
    doLenientOrTransformBasedQuery(configuration)
}

Type guard

// Narrow component identifiers before by-type resolution
static boolean isProjectModule(org.gradle.api.artifacts.component.ComponentIdentifier id) {
    return id instanceof org.gradle.api.artifacts.component.ProjectComponentIdentifier;
}

Try / catch

catch UnsupportedOperationException with message 'Resolving artifacts by type is not yet supported for project modules': switch the caller to a lenient artifact view (skip unsupported) or register an artifact transform, then retry.

Prevention

When it happens

Trigger: Resolving a configuration containing project dependencies through an artifact view filtered by artifact type (attributes { attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, 'jar') } or a custom type), which routes a per-type bulk query to the project resolver.

Common situations: IDE plugins or build logic consuming typed artifacts (jars, classes, android-variants) from configurations that resolve local projects; code assuming repository-style by-type resolution works everywhere.

Related errors


AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22). Data as JSON: /api/errors/73847d2c57482833. Report an issue: GitHub.