gradle存储库指向具有多个库的本地目录 [英] gradle repository points to local directory with multiple libs

查看:157
本文介绍了gradle存储库指向具有多个库的本地目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有关于build.gradle中的构建依赖关系的问题(例如使用本地目录)

 依赖关系{
编译fileTree(包括:''.jar'],dir:'libs')
}

它只解决libs目录中的依赖项,还是解决了lib目录下所有子文件夹的依赖关系?
如果它不解决子文件夹/子目录的依赖关系,如何解决依赖关系?注意:我们的项目依赖于很多jar文件(而不是为每个jar / libs提供完整的文件名),所以想知道任何替代方法。

p>

解决方案

它应该取决于传递的模式。 fileTree 上定义 Project 并返回一个 ConfigurableFileTree 。如您所见, ConfigurableFileTree 超级接口之一是 PatternFilterable ,它具有充分记录的模式,例如:

 以'jsp'结尾的所有文件(包括子目录)
** / *。jsp

所以我想包括你需要改变模式的子目录:

 依赖项{
编译fileTree(包括:['** / *。jar'],dir:'libs')
}

通常使用ant样式模式:


PatternFilterable表示某个文件容器其中Ant风格的
包含和排除模式或规格都可以应用到。



I have question regarding the build dependencies in the build.gradle for the local repository (i.e. using the local directory)

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
}

Does it solve the dependencies in the libs directory only or it is resolves the dependencies on all the subfolders of lib directory? If it does not resolve the dependencies of subfolders/subdirectories, how to resolve the dependencies?

Note: Our project depends on lot of jars files(instead of giving the full file name for each jars/libs), so wants to know any alternate way.

解决方案

It should depend on what pattern is passed. fileTree is defined on Project and returns an instance of ConfigurableFileTree. As you can see, one of ConfigurableFileTree super-interfaces is PatternFilterable which has patterns well documented e.g.:

 all files ending with 'jsp' (including subdirectories)
    **/*.jsp

So I guess to include subdirectories you just need to change the pattern:

dependencies {
    compile fileTree(include: ['**/*.jar'], dir: 'libs')
}

In general ant-style patterns are used:

A PatternFilterable represents some file container which Ant-style include and exclude patterns or specs can be applied to.

这篇关于gradle存储库指向具有多个库的本地目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆