2016-04-19 82 views
1

我有些依賴聲明:搖籃 - 附加信息的依賴

runtime 'org.apache.commons:commons-lang3:3.4' 
runtime 'commons-collections:commons-collections:3.2.2' 
runtime 'commons-io:commons-io:1.3.2' 

我有一個副本的依賴任務:

task copyRuntimeLibs(type: Copy) { 
    into "build/dependencies" 
    from configurations.runtime 
} 

我希望能夠「標記」一些依賴於以便稍後在不同文件夾中的copyRuntimeLibs中路由它們。例如:

runtime 'commons-io:commons-io:1.3.2' { subdir='dir1' } 
runtime 'commons-collections:commons-collections:3.2.2' { subdir='dir2' } 
runtime 'commons-io:commons-io:1.3.2' { subdir='dir3' } 

這可能嗎?

回答

0

可以定義多個自定義配置,然後所有對運行貢獻:

configurations{ 
    subRun1 
    subRun2 
    subRun3 
    runtime.extendsFrom(subRun1, subRun2, subRun3) 
} 

在你的副本任務,你可以從每個子結構複製到各自的文件夾:

task copySubRun1Libs(type: Copy) { 
    into "build/dependencies/dir1" 
    from configurations.subRun1 
} 

等上。

+0

謝謝,這就是我的想法,但我希望有一種比定義每個自定義行爲1配置更短的方式。如果我想將第二條信息附加到我的依賴項上,它會使它非常麻煩。 – bananasplit