我正在寻找一种将特定配置的项目依赖项提取到工作区文件夹中的方法。由于可能存在多个依赖关系,因此我想将每个工件提取到带有工件名称的文件夹中。我正在尝试在python的上下文中解决这个问题,但是这个问题与python并没有真正的关系...
目前,我的gradle文件如下所示:
configurations { python }
dependencies {
python group: 'github.dpeger', name: 'py-utils', version: '1.6', ext: 'zip'
python group: 'github.dpeger', name: 'py-test', version: '1.6', ext: 'zip'
}
task cleanPythonDependencies(type: Delete) { delete 'lib/python' }
tasks.clean.dependsOn cleanPythonDependencies
task importPythonDependencies(type: Copy) {
dependsOn cleanPythonDependencies
from {
configurations.python.collect { zipTree(it) }
}
into 'lib/python'
}
但是,这会将python
配置中的所有依赖关系提取到文件夹中,lib\pyhton
而无需使用工件的名称。
我想的是,py-utils
被提取lib\pyhton\py-utils
并py-test
到lib\pyhton\py-test
。
假设您要将py-utils提取到lib \ pyhton \ py-utils并将py-test提取到lib \ pyhton \ py-test,这应该可以完成工作:
task importPythonDependencies() {
dependsOn cleanPythonDependencies
String collectDir = 'lib/python'
outputs.dir collectDir
doLast {
configurations.python.resolvedConfiguration.resolvedArtifacts.each { artifact ->
copy {
from zipTree( artifact.getFile() )
into collectDir + '/' + artifact.name
}
}
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句