{"record":{"id":"0f1bbbc2cf766d02","repo":"didi/DoKit","slug":"config-gradle-archives-type-2","errorCode":null,"errorMessage":"执行当前打包上传任务必须修改config.gradle配置中的archives_type = 2。","messagePattern":"执行当前打包上传任务必须修改config\\.gradle配置中的archives_type = 2。","errorType":"console","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"Android/build.gradle","lineNumber":134,"sourceCode":"        println(\"===copy Plugin Source start===\")\n    }\n\n    from \"${project.rootDir}/buildSrc/src/main/kotlin\"\n    into \"${project.rootDir}/dokit-plugin/src/main/kotlin\"\n    include('**/*')\n\n    doLast {\n        println(\"===copy Plugin Source end===\")\n    }\n}\n\n/**\n * 打包上传配置检查\n */\ntask checkUploadConfig4Maven() {\n    doLast {\n        if (rootProject.ext.publish_config[\"archives_type\"] != 2) {\n            throw new RuntimeException(\"执行当前打包上传任务必须修改config.gradle配置中的archives_type = 2。\")\n        }\n\n        //仓库检查\n        def repositories = new ArrayList<String>()\n\n        rootProject.repositories.forEach {\n            if (it instanceof MavenArtifactRepository) {\n                repositories.add((it as MavenArtifactRepository).url.toString())\n            }\n        }\n\n        //相关模块检查\n        def modules = new ArrayList<String>()\n\n        rootProject.allprojects.forEach {\n            modules.add(it.name)\n        }\n","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/build.gradle#L116-L152","documentation":"The checkUploadConfig4Maven Gradle task in Android/build.gradle runs before a Maven upload and throws a RuntimeException if rootProject.ext.publish_config['archives_type'] != 2. It is a deliberate guard asserting that config.gradle is configured for publishing to Maven Central before the upload task proceeds.","triggerScenarios":"Running the Maven upload task (upload/uploadArchives wired to checkUploadConfig4Maven) while config.gradle still has archives_type = 0 (local) or 1 (Didi internal repository).","commonSituations":"A developer who previously published to the local Maven repo or Didi's internal repo forgets to flip archives_type back to 2 before running the Maven Central upload; CI sharing one config.gradle across different upload targets.","solutions":["Open Android/config.gradle and set archives_type = 2, then re-run the upload task","If you meant a different target: archives_type = 0 for local, 1 for Didi internal, 2 for Maven — pick the one matching the task you run","Keep per-environment config files or CI env injection instead of hand-editing config.gradle"],"exampleFix":"// before (config.gradle)\next.publish_config = [archives_type: 0, ...]\n\n// after (config.gradle)\next.publish_config = [archives_type: 2, ...]","handlingStrategy":"validation","validationCode":"// check before running the upload task\ndef t = rootProject.ext.publish_config[\"archives_type\"]\nassert t == 2 : \"set archives_type = 2 in config.gradle for Maven upload\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Flip archives_type before switching upload targets; re-verify with a quick grep of config.gradle","Consider injecting archives_type via -P property per CI job instead of editing the file"],"tags":["gradle","build-config","publishing","maven"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}