gradle/gradle · warning
{} isn't attached to a component. Gradle metadata only suppo
Error message
{} isn't attached to a component. Gradle metadata only supports publications with software components (e.g. from component.java) What it means
Logged by the GenerateModuleMetadata task while producing Gradle Module Metadata (.module file). That format describes the variants of a software component; when a MavenPublication has no component attached (no from components.java / from components.release), computeInputState() returns ComponentMissing, so metadata generation is skipped and this warning is emitted for that publication. The publication itself (POM, artifacts) is still built and uploaded.
Source
Thrown at platforms/software/publish/src/main/java/org/gradle/api/publish/tasks/GenerateModuleMetadata.java:222
moduleMetadataWriter().writeTo(writer, moduleMetadataSpec);
} catch (IOException e) {
throw new UncheckedIOException("Could not generate metadata file " + outputFile, e);
}
}
private BufferedWriter bufferedWriterFor(File file) throws FileNotFoundException {
return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), UTF_8));
}
private GradleModuleMetadataWriter moduleMetadataWriter() {
return new GradleModuleMetadataWriter(getBuildInvocationScopeId(), getChecksumService());
}
private boolean hasAttachedComponent() {
InputState inputState = inputState();
if (inputState instanceof InputState.ComponentMissing) {
String publicationName = ((InputState.ComponentMissing) inputState).publicationName;
getLogger().warn(
publicationName + " isn't attached to a component. Gradle metadata only supports publications with software components (e.g. from component.java)"
);
return false;
}
return true;
}
private InputState computeInputState() {
return component() == null
? new InputState.ComponentMissing(publicationName())
: new InputState.Ready(moduleMetadataSpec());
}
private Try<ModuleMetadataSpec> moduleMetadataSpec() {
return Try.ofFailable(this::computeModuleMetadataSpec);
}
private ModuleMetadataSpec computeModuleMetadataSpec() {View on GitHub (pinned to 534f27719b)
Solutions
- Attach a software component: from(components["java"]) for Java, from(components["kotlin"]), or from(components["release"]) on Android
- If publishing without a component on purpose, skip the task: tasks.withType<GenerateModuleMetadata>().configureEach { enabled = false }
- For POM-only/BOM publications, confirm consumers do not rely on .module files, then disable or ignore the warning
Example fix
// before
publishing {
publications {
create<MavenPublication>("mavenJava") {
groupId = "com.example"
artifactId = "lib"
version = "1.0"
}
}
}
// after
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"]) // component attached => .module generated
groupId = "com.example"
artifactId = "lib"
version = "1.0"
}
}
} Defensive patterns
Strategy: validation
Validate before calling
// build.gradle.kts — make component attachment explicit; skip metadata when
// a publication intentionally has no component
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"]) // component present => .module generated
}
}
}
tasks.withType<GenerateModuleMetadata>().configureEach {
enabled = !providers.gradleProperty("noModuleMetadata").getOrElse("false").toBoolean()
} Prevention
- Always attach a component with from(components["java"]) unless the publication intentionally ships raw files
- Treat the warning as a signal that consumers lose variant-aware dependency metadata
- In custom plugins that create publications, verify from(...) is called exactly once
When it happens
Trigger: A publishing { publications { ... } } block that creates a MavenPublication without calling from(components["java"]) (or kotlin/android/platform components), or one populated only with loose artifacts via artifact(...). Also occurs when a custom plugin creates publications but never attaches a component.
Common situations: Legacy builds migrated from manual artifact assembly; publishing BOMs or POM-only artifacts where module metadata is unwanted; Android builds attaching one variant while declaring extra publications; multi-project builds where one subproject publishes raw files.
Related errors
- Ivy publication '%s' cannot include multiple components
- Maven publication '%s' cannot include multiple components
- Cannot publish module metadata because an artifact from the
- Could not resolve coordinates for variant '%s' of project '%
- Invalid publication '${publicationName}'
AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22).
Data as JSON: /api/errors/9e96fdbc0c972de2.
Report an issue: GitHub.