gradle repository points to local directory with multiple libs

僤鯓⒐⒋嵵緔 提交于 2019-12-13 12:29:26

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/38059123/gradle-repository-points-to-local-directory-with-multiple-libs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!