我有一個Android庫gradle項目。我需要將一些文件複製到資產文件夾以進行robolectric單元測試。如何複製單元測試的調試資產
要做到這一點,我定義副本任務:
task copyDebugAssets(type: Copy) {
from "${projectDir}/somewhere"
into "${buildDir}/intermediates/bundles/debug/assets"
}
但我不能添加此任務,作爲一個依賴於processDebugResources
任務:
processDebugResources.dependsOn copyDebugAssets
,因爲這個錯誤的:
Could not get unknown property 'processDebugResources' for object of type com.android.build.gradle.LibraryExtension.
現在我必須在單元測試之前手動執行此任務:
./gradlew clean copyDebugAssets test
我該如何解決?
非常感謝,它的作品!你認爲,用定製任務複製資產是否正確,或者我應該選擇另一種方法? – g4s8
我同意@commonsware,將項目設置更改爲指向資產的位置,比複製更好。 – RaGe