{"record":{"id":"9e96fdbc0c972de2","repo":"gradle/gradle","slug":"isn-t-attached-to-a-component-gradle-metadata","errorCode":null,"errorMessage":"{} isn't attached to a component. Gradle metadata only supports publications with software components (e.g. from component.java)","messagePattern":"(.+?) isn't attached to a component\\. Gradle metadata only supports publications with software components \\(e\\.g\\. from component\\.java\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"platforms/software/publish/src/main/java/org/gradle/api/publish/tasks/GenerateModuleMetadata.java","lineNumber":222,"sourceCode":"            moduleMetadataWriter().writeTo(writer, moduleMetadataSpec);\n        } catch (IOException e) {\n            throw new UncheckedIOException(\"Could not generate metadata file \" + outputFile, e);\n        }\n    }\n\n    private BufferedWriter bufferedWriterFor(File file) throws FileNotFoundException {\n        return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), UTF_8));\n    }\n\n    private GradleModuleMetadataWriter moduleMetadataWriter() {\n        return new GradleModuleMetadataWriter(getBuildInvocationScopeId(), getChecksumService());\n    }\n\n    private boolean hasAttachedComponent() {\n        InputState inputState = inputState();\n        if (inputState instanceof InputState.ComponentMissing) {\n            String publicationName = ((InputState.ComponentMissing) inputState).publicationName;\n            getLogger().warn(\n                publicationName + \" isn't attached to a component. Gradle metadata only supports publications with software components (e.g. from component.java)\"\n            );\n            return false;\n        }\n        return true;\n    }\n\n    private InputState computeInputState() {\n        return component() == null\n            ? new InputState.ComponentMissing(publicationName())\n            : new InputState.Ready(moduleMetadataSpec());\n    }\n\n    private Try<ModuleMetadataSpec> moduleMetadataSpec() {\n        return Try.ofFailable(this::computeModuleMetadataSpec);\n    }\n\n    private ModuleMetadataSpec computeModuleMetadataSpec() {","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/gradle/gradle/blob/534f27719b66953f95cc907aae7f2c1b12f5482d/platforms/software/publish/src/main/java/org/gradle/api/publish/tasks/GenerateModuleMetadata.java#L204-L240","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\npublishing {\n    publications {\n        create<MavenPublication>(\"mavenJava\") {\n            groupId = \"com.example\"\n            artifactId = \"lib\"\n            version = \"1.0\"\n        }\n    }\n}\n\n// after\npublishing {\n    publications {\n        create<MavenPublication>(\"mavenJava\") {\n            from(components[\"java\"]) // component attached => .module generated\n            groupId = \"com.example\"\n            artifactId = \"lib\"\n            version = \"1.0\"\n        }\n    }\n}","handlingStrategy":"validation","validationCode":"// build.gradle.kts — make component attachment explicit; skip metadata when\n// a publication intentionally has no component\npublishing {\n    publications {\n        create<MavenPublication>(\"mavenJava\") {\n            from(components[\"java\"]) // component present => .module generated\n        }\n    }\n}\ntasks.withType<GenerateModuleMetadata>().configureEach {\n    enabled = !providers.gradleProperty(\"noModuleMetadata\").getOrElse(\"false\").toBoolean()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["gradle","publishing","maven-publication","module-metadata","software-component"],"backgroundTag":"publication-missing-software-component","analyzedSha":"534f27719b66953f95cc907aae7f2c1b12f5482d","analyzedAt":"2026-08-22T08:09:12.375Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}