You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Gradle Release Plugin 无法禁用Build任务问题求助

Solution for Skipping Compile/Build in Gradle Release Plugin

Hey there, I’ve run into this exact headache with the Gradle Release Plugin before—just setting buildTasks = [] doesn’t always do the trick because the plugin has implicit task dependencies and default steps that still trigger build/compile tasks behind the scenes. Here’s how I fixed it for my Jenkins automation workflow:

1. Override Default Release Steps & Clear Build Tasks

The plugin runs a predefined sequence of steps for releases. To skip build-related work entirely, you need to explicitly define only the versioning, commit, and tagging steps you care about, while cutting out any build/compile triggers.

Add this to your build.gradle (or build.gradle.kts for Kotlin):

Groovy DSL:

release {
    // Empty out default build tasks to prevent implicit triggers
    buildTasks = []
    
    // Skip check tasks (they often trigger compile tasks indirectly)
    skipChecks = true
    
    // Define only the release steps you need—no build/compile here
    steps = [
        'checkSnapshotDependencies',
        'incrementVersion',
        'commitReleaseVersion',
        'tagRelease',
        'incrementVersion',
        'commitNewVersion'
    ]
}

Kotlin DSL:

release {
    buildTasks.set(emptyList())
    skipChecks.set(true)
    steps.set(listOf(
        "checkSnapshotDependencies",
        "incrementVersion",
        "commitReleaseVersion",
        "tagRelease",
        "incrementVersion",
        "commitNewVersion"
    ))
}

2. Remove Implicit Task Dependencies (If Needed)

If the above still doesn’t stop build tasks from running, the release task might have hidden dependencies on build/compile tasks. Explicitly strip those out:

Groovy DSL:

tasks.named('release') {
    // Remove any dependencies that trigger build/compile/check
    dependsOn.removeAll { task ->
        task.name.contains('build') || task.name.contains('compile') || task.name == 'check'
    }
}

Why Your Initial Setup Didn’t Work

The buildTasks property only controls which tasks run during the plugin’s "build phase," but the default step sequence includes tasks like check that indirectly trigger compilation. By defining your own slimmed-down steps and skipping checks, you break that chain entirely.

Since you have a separate Jenkins task for builds, this setup lets the release plugin handle only version bumping, commits, and tagging—no unnecessary compilation or building cluttering up your workflow.

内容的提问来源于stack exchange,提问作者sudhir

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:26:46