首页 > 解决方案 > Gradle exec 任务因“execCommand == null!”而失败

问题描述

我正在尝试在我的 build.gradle.kts 上创建一个版本缓冲和标签创建器,但是我收到了这个错误,有人可以帮助我吗?谢谢!

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':gitTag'.
> execCommand == null!

我的 build.gradle.kts

tasks {
    val gitIsDirty by registering(Exec::class) {
        description = "Fails if git has uncommitted changes."
        group = "verification"
        commandLine("git", "diff", "--quiet", "--exit-code")
    }

    val gitTag by registering(Exec::class) {
        description = "Tags the local repository with version ${project.version}"
        group = PublishingPlugin.PUBLISH_TASK_GROUP
        dependsOn(gitIsDirty)
        if (isRelease) {
            commandLine("git", "commit", "-am", "Publishing version ${project.version}")
            commandLine("git", "tag", "-a", project.version, "-m", "Version ${project.version}")
            commandLine("git", "push", "origin", "${project.version}")
        }
    }

    val publishLocalMajor by registering(Exec::class) {
        group = PublishingPlugin.PUBLISH_TASK_GROUP
        dependsOn(incrementMajor, gitTag,publishToMavenLocal)
    }
}

标签: gradlekotlin

解决方案


推荐阅读