我正在嘗試從我的 Gradle 腳本中洗掉不推薦使用的內容。我注意到archivePath應該被替換為archiveFile.
轉換archiveFile為絕對路徑的“正確”方法是什么?
這是我的 Gradle 任務:
task buildZip(type: Zip){
...
doLast {
// ZipUtil.normaliseZipDates(archivePath.absolutePath)
ZipUtil.normaliseZipDates(archiveFile.get().asFile.absolutePath)
}
normaliseZipDates接受一個字串,我不能只傳遞它archiveFile并archiveFile.absolutePath給出“沒有這樣的屬性:absolutePath”。
目前,如上所示,我正在使用archiveFile.get().asFile.absolutePath,但這似乎很冗長 - 正確的方法是什么?
背景:目前使用 Gradle 6.9,很快升級到 7.x。
uj5u.com熱心網友回復:
println archiveFile.get().toString()似乎也給出了完整的檔案路徑 -
> Task :buildZip
/Users/xyz/Projects/gradle-scala/build/distributions/gradle-scala-1.0-SNAPSHOT.zip
但我建議堅持archiveFile.get().asFile.absolutePath
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/445979.html
標籤:毕业典礼
