是否有选项可以在不使用自定义配置的情况下在Gradle中获取Maven依赖项?例如,在自定义插件中只获取扩展提供的依赖项?像
这样的东西class DependencyPlugin implements Plugin<Project> {
void apply(Project project) {
project.extensions.create("deps", DepsExtension)
project.task('useDependency') {
doLast {
//use Gradle api to resolve dependency without custom configuration
project.resolve(project.deps.dependency)
}
}
}
}
class DepsExtension {
def dependency = 'custom:maven:1.0'
}
答案 0 :(得分:1)
这样的事情:
Configuration config = project.configurations.create('myPrivateConfig')
Dependency dep = project.dependencies.create('custom:maven:1.0') {
exclude group: 'foo', module: 'bar'
}
config.dependencies.add(dep)
Set<File> files = config.files
我在gradle插件here
中做了类似的事情参考