{"record":{"id":"73847d2c57482833","repo":"gradle/gradle","slug":"resolving-artifacts-by-type-is-not-yet-supported-f","errorCode":null,"errorMessage":"Resolving artifacts by type is not yet supported for project modules","messagePattern":"Resolving artifacts by type is not yet supported for project modules","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"platforms/software/dependency-management/src/main/java/org/gradle/api/internal/artifacts/ivyservice/projectmodule/ProjectDependencyResolver.java","lineNumber":98,"sourceCode":"\n    @Override\n    public void resolve(ComponentIdentifier identifier, ComponentOverrideMetadata componentOverrideMetadata, final BuildableComponentResolveResult result) {\n        if (isProjectModule(identifier)) {\n            ProjectComponentIdentifier projectId = (ProjectComponentIdentifier) identifier;\n            LocalComponentGraphResolveState component = localComponentRegistry.getComponent(projectId);\n            result.resolved(component, ComponentGraphSpecificResolveState.EMPTY_STATE);\n        }\n    }\n\n    @Override\n    public boolean isFetchingMetadataCheap(ComponentIdentifier identifier) {\n        return true;\n    }\n\n    @Override\n    public void resolveArtifactsWithType(ComponentArtifactResolveMetadata component, ArtifactType artifactType, BuildableArtifactSetResolveResult result) {\n        if (isProjectModule(component.getId())) {\n            throw new UnsupportedOperationException(\"Resolving artifacts by type is not yet supported for project modules\");\n        }\n    }\n\n    @Override\n    public void resolveArtifact(ComponentArtifactResolveMetadata component, ComponentArtifactMetadata artifact, BuildableArtifactResolveResult result) {\n        if (isProjectModule(artifact.getComponentId())) {\n            artifactResolver.resolveArtifact(component, artifact, result);\n        }\n    }\n\n    private static boolean isProjectModule(ComponentIdentifier componentId) {\n        return componentId instanceof ProjectComponentIdentifier;\n    }\n}\n","sourceCodeStart":80,"sourceCodeEnd":113,"githubUrl":"https://github.com/gradle/gradle/blob/534f27719b66953f95cc907aae7f2c1b12f5482d/platforms/software/dependency-management/src/main/java/org/gradle/api/internal/artifacts/ivyservice/projectmodule/ProjectDependencyResolver.java#L80-L113","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Request artifacts without the type filter and produce the type via an artifact transform (ArtifactActionContainer.registerArtifactTransform)","Use a lenient view (configuration.incoming.artifactView { lenient(true) }) so unsupported project components are skipped instead of failing","If by-type bulk resolution is essential, resolve against published modules (repository) rather than substituted projects"],"exampleFix":"// before\nconfigurations.runtimeClasspath.incoming.artifactView {\n    attributes { attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, 'jar') }\n}.files // throws for project modules\n// after\nconfigurations.runtimeClasspath.incoming.artifactView {\n    lenient(true)\n    attributes { attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, 'jar') }\n}.files","handlingStrategy":"fallback","validationCode":"// Skip by-type artifact resolution when project modules are involved\ndef hasProjectModules = configuration.resolvedConfiguration.resolvedArtifacts.any {\n    it.id.componentIdentifier instanceof org.gradle.api.artifacts.component.ProjectComponentIdentifier\n}\nif (!hasProjectModules) {\n    doTypedArtifactQuery(configuration)\n} else {\n    doLenientOrTransformBasedQuery(configuration)\n}","typeGuard":"// Narrow component identifiers before by-type resolution\nstatic boolean isProjectModule(org.gradle.api.artifacts.component.ComponentIdentifier id) {\n    return id instanceof org.gradle.api.artifacts.component.ProjectComponentIdentifier;\n}","tryCatchPattern":"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.","preventionTips":["Prefer artifact transforms over ARTIFACT_TYPE-filtered artifact views for local projects","Use lenient(true) on artifact views that may include project dependencies","Test artifact-consuming build logic on builds with project substitution enabled"],"tags":["artifact-resolution","project-dependency","artifact-type","artifact-view"],"backgroundTag":"unsupported-artifact-type-resolution","analyzedSha":"534f27719b66953f95cc907aae7f2c1b12f5482d","analyzedAt":"2026-08-22T08:09:12.375Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}