didi/DoKit · error · RuntimeException

执行当前打包上传任务必须修改config.gradle配置中的archives_type = 2。

Error message

执行当前打包上传任务必须修改config.gradle配置中的archives_type = 2。

What it means

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.

Source

Thrown at Android/build.gradle:134

        println("===copy Plugin Source start===")
    }

    from "${project.rootDir}/buildSrc/src/main/kotlin"
    into "${project.rootDir}/dokit-plugin/src/main/kotlin"
    include('**/*')

    doLast {
        println("===copy Plugin Source end===")
    }
}

/**
 * 打包上传配置检查
 */
task checkUploadConfig4Maven() {
    doLast {
        if (rootProject.ext.publish_config["archives_type"] != 2) {
            throw new RuntimeException("执行当前打包上传任务必须修改config.gradle配置中的archives_type = 2。")
        }

        //仓库检查
        def repositories = new ArrayList<String>()

        rootProject.repositories.forEach {
            if (it instanceof MavenArtifactRepository) {
                repositories.add((it as MavenArtifactRepository).url.toString())
            }
        }

        //相关模块检查
        def modules = new ArrayList<String>()

        rootProject.allprojects.forEach {
            modules.add(it.name)
        }

View on GitHub (pinned to 626827cddb)

Solutions

  1. Open Android/config.gradle and set archives_type = 2, then re-run the upload task
  2. 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
  3. Keep per-environment config files or CI env injection instead of hand-editing config.gradle

Example fix

// before (config.gradle)
ext.publish_config = [archives_type: 0, ...]

// after (config.gradle)
ext.publish_config = [archives_type: 2, ...]
Defensive patterns

Strategy: validation

Validate before calling

// check before running the upload task
def t = rootProject.ext.publish_config["archives_type"]
assert t == 2 : "set archives_type = 2 in config.gradle for Maven upload"

Prevention

When it happens

Trigger: Running the Maven upload task (upload/uploadArchives wired to checkUploadConfig4Maven) while config.gradle still has archives_type = 0 (local) or 1 (Didi internal repository).

Common situations: 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.

Related errors


AI-assisted analysis of didi/DoKit@626827cddb (2026-08-14). Data as JSON: /api/errors/0f1bbbc2cf766d02. Report an issue: GitHub.