摇篮依赖条件:由相对路径编制项目 [英] Gradle dependecies: compile project by relative path
问题描述
有没有可能到当前项目边界以外指定摇篮的依赖关系(在机器人工作室)到另一个摇篮的项目?例如使用相对路径是这样的:
相关性{
编制项目(../../ STDLIB /匕首)
}
所以我线索是这样的:
我有一个Android应用程序。其结构是这样的:
- 在MyApp的(路径为/用户/富/工作区/ MyApp的)
- 在应用程序(路径为/用户/富/工作区/ MyApp的/应用程序)
和我有摇篮的Android库项目包含3子模块:
- STDLIB(路径为/用户/富/工作区/ STDLIB)
- 匕首(路径为/用户/富/工作区/ STDLIB /匕首)
- 在utils的(路径为/用户/富/工作区/ STDLIB / utils的)
- 在HTTP(路径为/用户/富/工作区/ STDLIB / HTTP)
我要的是编译匕首,utils的,HTTP模块到MyApp项目。
在STDLIB库模块都是在沉重的发展中,将成长为MyApp的增长。因此,我不希望他们推到一个Maven仓库,每次我稍作改动。
那么,有没有可能以某种方式连接其他摇篮项目? 进出口寻找一个即暂时的解决方案。我会在std库推入Maven仓库一旦源是稳定的。
此外,作为解决办法,与sourceSet一个解决办法是可行的。我也考虑过做一个库文件夹中的MyApp谁是一个符号链接STDLIB,但我没有得到它的工作预期:
- 在MyApp的(路径为/用户/富/工作区/ MyApp的)
- 在应用程序(路径为/用户/富/工作区/ MyApp的/应用程序)
- 在库(符号链接到/用户/富/工作区/ STDLIB)
相关性{ 编制项目(':库:匕首) }
不知道如何解决摇篮这种依赖?
您可以包括使用从您的主项目settings.gradle'文件的根目录外项目模块。它必须是一个摇篮的项目也是一样,在特定的Android建设情况,必须要配置的每个模块作为机器人库插件项目。
例如,在MyApp的项目settings.gradle哟可以试试这个:
包括应用程序
包括匕首
项目(:匕首)。PROJECTDIR =新的文件(/用户/富/工作区/ STDLIB /匕首)
您MyApp的build.gradle一定要体现出匕首模块的相对路径摇篮方式需要:
相关性{
编制项目(:匕首)
}
就是这样。重复此步骤,你需要每一个外部模块,你就会有一个合适的摇篮多项目配置。
is it possible to specify a dependency in Gradle (in android studio) to another gradle project outside of the current project boundaries? For example with a relative path something like this:
dependencies {
compile project('../../stdlib/dagger')
}
So what I trie is something like this:
I have an Android Application. The structure looks like this:
- MyApp (path is /Users/foo/workspace/MyApp)
- app (path is /Users/foo/workspace/MyApp/app)
And I have a gradle android library project containing 3 submodules:
- stdlib (path is /Users/foo/workspace/stdlib)
- dagger (path is /Users/foo/workspace/stdlib/dagger)
- utils (path is /Users/foo/workspace/stdlib/utils)
- http (path is /Users/foo/workspace/stdlib/http)
What I want is to compile the dagger, utils, http module into MyApp project.
The stdlib libraries modules are under heavy development and will grow as MyApp grow. Hence I do not want to push them into a maven repository everytime I make a little change.
So is there a possibility to link other gradle projects somehow? Im looking for a temporarly solution. I will push the std library into maven repository once the source is stable.
Also, as workaround, a solution with sourceSet would be possible. I have also considered to make a libraries folder in MyApp who is a symlink to stdlib, but I didnt get it to work as expected:
- MyApp (path is /Users/foo/workspace/MyApp)
- app (path is /Users/foo/workspace/MyApp/app)
- libraries (symlink to /Users/foo/workspace/stdlib)
dependencies { compile project(':libraries:dagger') }
Any idea how to solve such a dependency in gradle?
You can include an outside root project module using 'settings.gradle' file from your main project. It must to be a gradle project too and in the specific Android building situation, you must to config every module as an "android-library" plugin project.
For example, in 'MyApp' project settings.gradle yo can try this:
include 'app'
include 'dagger'
project(':dagger').projectDir = new File('/Users/foo/workspace/stdlib/dagger')
Your 'MyApp' build.gradle must to reflect the need of the 'dagger' module in a relative path Gradle way:
dependencies {
compile project(':dagger')
}
And that's it. Repeat this step with every external module you need and you'll have a proper Gradle multi-project configuration.
这篇关于摇篮依赖条件:由相对路径编制项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!