亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在所有子項目中的所有測試之前運行子項目中的 checkstyles

在所有子項目中的所有測試之前運行子項目中的 checkstyles

阿晨1998 2023-07-13 14:15:41
我有 gradle 項目,有 4 個子項目。我有當前的根 gradle.build 和 checkstyle:allprojects {  apply plugin: "checkstyle"  checkstyle {  ...  }}因此,當我在主文件夾中運行 ./gradlew build 時,我會得到下一個:第一個子項目的 checkstyle,然后是測試。然后它為第二個子項目運行 checkstyle,然后測試第二個子項目,依此類推。問題是:如果我在第一個子項目中有很長的測試,我可以等待很多時間,然后發現我在第四個項目中有2個空格,所以 checkstyle 失敗,但我等待了很多時間。我真正想要的是:對所有子項目運行所有檢查(checkstyle,我也有 pmd),然后在所有子項目中運行所有測試。這將為團隊中的每個人節省大量時間。除了制作 2 個不同的管道并單獨運行它們之外,我可以這樣做嗎?像: ./gradlew allMyCheckstyles && ./gradlew build. 我很想只使用 ./gradlew build 謝謝!我嘗試了很多dependOn、runAfter,但沒有成功。
查看完整描述

1 回答

?
ITMISS

TA貢獻1871條經驗 獲得超8個贊

抱歉,此答案的先前版本誤解了此問題的要求。


這是一個應該可以滿足您要求的解決方案:



// Create a lifecycle task in the root project.

// We'll make this depend on all checkstyle tasks from subprojects (see below)

def checkstyleAllTask = task("checkstyleAll")


// Make 'check' task depend on our new lifecycle task

check.dependsOn(checkstyleAllTask)


allProjects {


? ? // Ensure all checkstyle tasks are a dependency of the "checkstyleAll" task

? ? checkstyleAllTask.dependsOn(tasks.withType(Checkstyle))


? ? tasks.withType(Test) {


? ? ? ? // Indicate that testing tasks should run after the "checkstyleAll" task

? ? ? ? shouldRunAfter(checkstyleAllTask)


? ? ? ? // Indicate that testing tasks should run after any checksytle tasks.

? ? ? ? // This is useful for when you only want to run an individual

? ? ? ? // subproject's checks (e.g. ./gradlew ::subprojA::check)

? ? ? ? shouldRunAfter(tasks.withType(Checkstyle))

? ? }

}

查看完整回答
反對 回復 2023-07-13
  • 1 回答
  • 0 關注
  • 129 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號