Java gradle 编译文件树语法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18925908/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 12:33:30  来源:igfitidea点击:

gradle compile filetree syntax

javagradlebuild.gradle

提问by CQM

folder structure:

文件夹结构:

- RootProject Folder
  - MyMainProject
  - MyLibraries
       - Facebook

The root project folder has a build.gradle file, but MyMainProject has the one with all the dependencies.

根项目文件夹有一个 build.gradle 文件,但 MyMainProject 有一个包含所有依赖项的文件。

dependencies {
     compile fileTree(dir: 'libs', include: '*.jar')
     compile project(':MyLibraries:Facebook')
}

I feel like compile projectdoesn't have the correct path. Is there a way to make it look up a directory, so something like ../MyLibraries/Facebook? I don't completely understand the colon (:) syntax

我觉得compile project没有正确的路径。有没有办法让它查找目录,比如../MyLibraries/Facebook?我不完全理解冒号 (:) 语法

采纳答案by Peter Niederwieser

You need a settings.gradle, and the dependency presumably needs to be declared as project(':Facebook'). (According to the folder structure, MyLibrariesand Facebookare siblings.) For more information, see the multi-project builds chapter in the Gradle User Guide. I don't understand why you think this is connected to the fileTreesyntax, and I don't see libsin your folder structure.

您需要一个settings.gradle,并且该依赖项大概需要声明为project(':Facebook')。(根据文件夹结构,MyLibraries并且Facebook是同级。)有关更多信息,请参阅Gradle 用户指南中的多项目构建章节。我不明白你为什么认为这与fileTree语法有关,而且我libs在你的文件夹结构中没有看到。