2016-05-10 82 views
0

我有一個libs文件夾,那裏有幾個jar文件。有名字是這樣的 - componentName + version.jar。 libs文件夾中有4個文件。現在我需要這些文件中的組件名稱,並且我想將它用於其他目的。我怎麼能在gradle中得到這個結果。我在libs文件夾中的jar文件是:bo-1.0.0.jar,so-2.2.1.jar,do-1.0.1.jar和fz-1.0.1.jar 我想獲得bo,那麼, fz在變量component_bo,component_so,component_do,component_fz中。從一個特定的文件夾中提取文件名並用它來獲取其他信息

回答

0

你可以列出該文件夾的內容並做一些簡單的字符串操作。這是一個非常天真的實現的例子,但我認爲你可以得到這個想法。

def components = fileTree('libs').collect { it.name.split('-')[0] } 
components.each { component -> 
    // do something 
} 
+0

是的,我明白了,謝謝:) – sver

相關問題