Gradle 5.0 Milestone 1 釋出,專案自動化構建工具
Gradle 5.0 首個里程碑版本 ofollow,noindex">Milestone 1 釋出了 ,並帶來了不少優秀的新功能和改進。
首先,Gradle Kotlin DSL 1.0 現已釋出,並可用於生成環境。使用 Kotlin 編寫構建邏輯可在 IDE 中提供重要的額外編輯幫助,包括改進的自動完成、高亮顯示錯誤資訊和重構工具。如果你更喜歡 Groovy 的靈活性和動態性,可以使用 Groovy DSL,官方表示它不會被遺棄。
在 5.0 M1 中,我們可以指定任務的超時持續時間,之後它將會被中斷。 點此閱讀更多相關資訊 。
這個版本的 Gradle 還為依賴引入了版本對齊( dependency version alignment)。這允許屬於同一邏輯組(平臺)的不同模組在依賴圖中具有相同的版本。可以匯入 Maven BOM 以定義平臺。
dependencies { // import a BOM. The versions used in this file will override any other version found in the graph implementation(dependencies.enforcedPlatform("org.springframework.boot:spring-boot-dependencies:1.5.8.RELEASE")) // define dependencies without versions implementation("com.google.code.gson:gson") implementation("dom4j:dom4j") // this version will be overriden by the one found in the BOM implementation("org.codehaus.groovy:groovy:1.8.6") }
此外,5.0 M1 已對 gradle init 功能進行了升級:現在具有可選擇性的互操作,包括新的 kotlin-library 和 kotlin-application 專案型別,提供配置專案和包名稱的選項等。
interactive gradle init
該版本為外掛和自定義任務作者引入了有用的更改,包括用於建立 SourceDirectorySet 的 API,對 Provider API 的改進以及改進的構建快取相容性。
最後,因為這是 Gradle 新的主要版本,所以在 Gradle 4.x 版本中被棄用的許多內容都已被刪除。例如,執行 Gradle 現在需要 Java 8 或更高版本(儘管可以使用 Java 6 或 7 執行測試)。建議:
-
閱讀從 Gradle 4.x 升級到 5.0 的文件
-
升級到 Gradle 4.10.2
-
執行 gradle help --scan 並檢視"Deprecations"檢視
-
也可以使用 gradle help --warning-mode = all,但這可能不會報告詳細資訊
查詢並修復所有已棄用的構建邏輯。
詳情請檢視 https://github.com/gradle/gradle/releases/tag/v5.0.0-M1