讓我想想驗證庫,它存在於.jar中,我們應該下載。在其他情況下,您可以提供幾種類型的產品口味。之後,您只需選擇Build Flavors即可。
productFlavors {
fastDebug {
applicationIdSuffix ".jar"
}
regularDegub {
applicationIdSuffix ".regular"
}
....
// Other Configuration
}
dependencies {
...
// Jar Debug by adding only Jar
fastDegubCompile fileTree(dir: 'libs', include: '*.jar')
fastDegubCompile 'com.android.support:support-v4:23.1.1'
...
// Regular Debug with downloading all libraries
// Including only specific from project files
regularDegubCompile 'com.squareup.picasso:picasso:2.5.2'
regularDegubCompile 'com.android.support:support-v4:23.1.1'
regularDegubCompile files('libs/specific1.jar', 'libs/specific2.jar')
}
|更新|
因此,在一些解決方法之後,我看到Gradle將庫收集到某個緩存中,在那裏我可以看到源代碼。但我仍然在尋找具有項目配置的正確驗證庫。
現在我寫了從Gradle緩存位置收集文件的腳本。並將它們複製到新的位置,在那裏我們可以使用構建口味。這種方法非常快速(200個庫的時間少於7秒),但仍需要改進(見上文)。
如果我沒有時間,請在下次更新時自由填寫以擴展解決方案。感謝您的理解。
// Task for calling from Gradle Scripts
// -----------------------------------
task gatheringJarFilesTask << {
println("Gathering Jars Start...")
gatheringJarFiles(gradleCacheLocation, foundedJarsList)
println("------------------------------")
println("Gathering Jars End! Start copying!")
copyFiles(projectJarsLocation, foundedJarsList)
}
// Constants, which might be optimized too
// -----------------------------------
def gradleCacheLocation = '/home/kasyangenka/.gradle/caches/modules-2/files-2.1'
def projectJarsLocation = '/home/kasyangenka/Projects/GradleScriptsTest/app/libs'
List<String> foundedJarsList = []
// Main Script Methods
// -----------------------------------
def gatheringJarFiles(baseDirPath, gatheredList) {
new File(baseDirPath).eachFile {file ->
println("-> Current file: " + file.getName())
if (file.isDirectory()) {
gatheringJarFiles(file.getAbsolutePath(), gatheredList)
}
def containsLib = (file.getName().contains(".jar")
|| file.getName().contains(".aar"));
if (containsLib) {
println("->> Adding Jar file: " + file.getAbsolutePath())
gatheredList.add(file.getAbsolutePath())
}
}
}
def copyFiles (destiny, List sourceList) {
sourceList.each {filePath ->
copy {
from filePath
into destiny
}
}
}
難道僅僅是純粹的Java庫,否則你會在Android的庫拉呢? – tynn
主要是android庫... – prom85
所以實際上大多是'.aar'文件? – tynn