沒有測試的Gradle構建

我想在不執行單元測試的狀況下執行gradle build 。 我試過了: 單元測試

$ gradle -Dskip.tests build

這彷佛沒有作任何事情。 我能夠使用其餘命令嗎? 測試


#1樓

參考 gradle

要從gradle中排除任何任務,請使用-x命令行選項。 請參閱如下示例 ui

task compile << {
    println 'task compile'
}

task compileTest(dependsOn: compile) << {
    println 'compile test'
}

task runningTest(dependsOn: compileTest) << {
    println 'running test'
}
task dist(dependsOn:[runningTest, compileTest, compile]) << {
    println 'running distribution job'
}

輸出: gradle -q dist -x runningTest this

task compile
compile test
running distribution job

但願這會給你基本的 spa


#2樓

gradle build -x test --parallel

若是您的計算機有多個核心。 可是,不建議使用平行清潔。 命令行


#3樓

嘗試: code

gradle assemble

要列出項目的全部可用任務,請嘗試: ip

gradle tasks

更新: get

這可能看起來不是最正確的答案,但請仔細閱讀gradle tasks輸出或docs。

Build tasks
-----------
assemble - Assembles the outputs of this project.
build - Assembles and tests this project.

#4樓

接受的答案是正確的答案。

OTOH,我以前解決這個問題的方法是將如下內容添加到全部項目中:

test.onlyIf { ! Boolean.getBoolean('skip.tests') }

使用-Dskip.tests=true運行構建,將跳過全部測試任務。


#5樓

您應該使用-x命令行參數來排除任何任務。

嘗試:

gradle build -x test

更新:

彼得評論中的連接發生了變化。 如下是Gradle用戶指南中圖表

相關文章
相關標籤/搜索