{"record":{"id":"097a999cbda49333","repo":"Blankj/AndroidUtilCode","slug":"the-module-of-dep-name-should-set-groupi","errorCode":null,"errorMessage":"The module of <\" + dep.name + \"> should set groupId & version.","messagePattern":"The module of <\" \\+ dep\\.name \\+ \"> should set groupId & version\\.","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"config/publish.gradle","lineNumber":132,"sourceCode":"        sign publishing.publications\r\n    }\r\n}\r\n\r\nprivate void addDependency(Project project, def dependenciesNode, Dependency dep, String scope) {\r\n    if (dep.group == null || dep.version == null || dep.name == null || dep.name == \"unspecified\") {\r\n        return\r\n    }\r\n\r\n    final dependencyNode = dependenciesNode.appendNode('dependency')\r\n    dependencyNode.appendNode('scope', scope)\r\n\r\n    if (dep.version == 'unspecified') {\r\n        // 检测 module 中的 dependencies 是否有源码依赖\r\n        // 如果是源码依赖，而且没有在 config 中配置 remotePath，\r\n        // 那么发布到仓库，其他地方依赖该库时会找不到源码的那个库\r\n        println \"publish -> module(unspecified) <${dep.group}:${dep.name}:${dep.version}>\"\r\n        if (project.ext.groupId || project.ext.version) {\r\n            throw new GradleException(\"The module of <\" + dep.name + \"> should set groupId & version.\")\r\n        }\r\n        // 源码依赖，但配置了 remotePath，让 pom 中写入 remotePath\r\n        println(\"publish -> module(wrapped) <${project.ext.groupId}:${name}:${project.ext.version}>\")\r\n\r\n        dependencyNode.appendNode('groupId', project.ext.pomGroupID)\r\n        dependencyNode.appendNode('artifactId', dep.name)\r\n        dependencyNode.appendNode('version', project.ext.pomVersion)\r\n    } else {\r\n        dependencyNode.appendNode('groupId', dep.group)\r\n        dependencyNode.appendNode('artifactId', dep.name)\r\n        dependencyNode.appendNode('version', dep.version)\r\n        println(\"publish -> library <${dep.group}:${dep.name}:${dep.version}>\")\r\n    }\r\n\r\n    if (!dep.transitive) {\r\n        // In case of non transitive dependency,\r\n        // all its dependencies should be force excluded from them POM file\r\n        final exclusionNode = dependencyNode.appendNode('exclusions').appendNode('exclusion')\r","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/Blankj/AndroidUtilCode/blob/7b4caf9e5440046b3fefb63b6b6e2ead7ebaf809/config/publish.gradle#L114-L150","documentation":"config/publish.gradle's addDependency() builds the published pom. When a dependency resolves with version 'unspecified' (a local/source module rather than a published artifact) and the module being published has its own ext.groupId or ext.version set (signaling publish mode), it throws GradleException. A source dependency cannot be correctly represented in a published pom unless that dependency module itself has publish coordinates.","triggerScenarios":"A publishable module (sets ext.groupId/ext.version and applies publish.gradle) has an api/implementation dependency on another local Gradle module (project(':other')) whose version is 'unspecified' and which has no groupId/version/remotePath configured.","commonSituations":"Multi-module mono-repo where one library depends on a sibling local module but only the leaf is published; converting a remote dependency to a source dependency without setting publish metadata on the sibling; publishing a single module out of a normally-composite build.","solutions":["Set ext.groupId and ext.version (plus the publish block / remotePath) on the local source dependency module that resolves to 'unspecified', so its coordinates can be written into the pom.","If the sibling is meant to be consumed remotely, configure remotePath so addDependency() writes the wrapped remote coordinates instead of throwing.","If the dependency should not appear in the pom, make it non-transitive or move it out of the api configuration so it is excluded from pom generation."],"exampleFix":"// before - lib_a is published and depends on local :lib_b (version 'unspecified')\n// lib_a/build.gradle\next { groupId = 'com.example'; artifactId = 'lib-a'; version = '1.0.0' }\napply from: \"${rootDir}/config/publish.gradle\"\ndependencies { api project(':lib_b') }   // lib_b has no groupId/version -> error\n\n// after - publish lib_b too (or point lib_a's pom at lib_b's remote coordinates)\n// lib_b/build.gradle\next { groupId = 'com.example'; artifactId = 'lib-b'; version = '1.0.0' }\napply from: \"${rootDir}/config/publish.gradle\"","handlingStrategy":"validation","validationCode":"tasks.named('publish2Local').configure {\n    doFirst {\n        ['api', 'implementation'].each { cfg ->\n            configurations.findByName(cfg)?.dependencies?.each { d ->\n                if (d.version == 'unspecified') {\n                    throw new GradleException(\n                        \"Source dep <${d.name}> has no groupId/version; publish it or set remotePath.\")\n                }\n            }\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Before publishing a module, ensure every local/source dependency is itself publishable (groupId + version).","Prefer remote coordinates (remotePath) for source deps so the pom stays resolvable by consumers.","Keep publish metadata consistent across all modules in the composite, not just the published leaf."],"tags":["gradle","publishing","maven","pom","build"],"backgroundTag":null,"analyzedSha":"7b4caf9e5440046b3fefb63b6b6e2ead7ebaf809","analyzedAt":"2026-08-14T02:26:54.956Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}