# Using composite builds in a hierarchical multirepo project
This sample demonstrates how composite builds can be used to develop a hierarchical project that is composed from different Git repositories. Instead of Gradle subprojects in a multiproject build, this example uses separate Gradle builds included into a composite.
In addition to the benefits of a multirepo architecture, using a Gradle composite build in this way allows a developer to easily choose which modules to develop as source dependencies and which to integrate via a binary repository.
### Running `multirepo-app` with dependencies from included builds
In the first instance, all of the required dependencies are present as builds in the `modules` directory. In a real-world example, these could well be clones of different Git repositories.
In order to avoid hard-coding the included builds to load, the `settings.gradle` file in `multirepo-app` loads each of these builds dynamically:
```
file('modules').listFiles().each { File moduleBuild ->
includeBuild moduleBuild
}
```
When the `multirepo-app` build is executed, these module builds are used to generate the dependent artifacts:
```
gradle run
```
And the 'dependencies' report shows the dependency substitution in action:
```
gradle dependencies --configuration compile
```
>>>
```
compile - Dependencies for source set 'main'.
+--- org.sample:number-utils:1.0 -> project :number-utils
\--- org.sample:string-utils:1.0 -> project :string-utils
\--- org.apache.commons:commons-lang3:3.4
```
### Switching to use binary dependency
As long as the modules are available in a binary repository, the `multirepo-app` build will continue to work even if you don't have some modules available locally. In this case Gradle will use a binary dependency downloaded from a repository instead.
#### Preparing the binary repository
To demonstrate this functionality, we first need to publish each module to a binary repository. In this case we use a local file repository for this purpose:
```
gradle :publishDeps
```
The `publishDeps` creates and uploads the artifacts for each included build. It is defined in `multirepo-app` as follows:
```
task publishDeps {
dependsOn gradle.includedBuilds*.task(':uploadArchives')
}
```
#### Removing the local module source
With module artifacts available in a repository, we can now remove the module sources from the build. Since the composite is configured to automatically load available modules, this is as easy as deleting one or more module directories.
```
rm -r modules/string-utils
gradle run
```
Note that the `number-utils` dependency is still satisfied by the included build, while the `string-utils` dependency is now resolved from the repository.
The 'dependencies' report shows the dependency substitution in action:
```
gradle dependencies --configuration compile
```
>>>
```
compile - Dependencies for source set 'main'.
+--- org.sample:number-utils:1.0 -> project :number-utils
\--- org.sample:string-utils:1.0
\--- org.apache.commons:commons-lang3:3.4
```
### Including an external library as a submodule
The power of this configuration can be demonstrated by adding the external 'commons-lang' build directly to the composite.
```
git clone http://git-wip-us.apache.org/repos/asf/commons-lang.git modules/commons-lang --branch master --depth 1
gradle --project-dir modules/commons-lang --no-search-upward init
gradle run
```
You can see the external transitive dependency `commons-lang` being replaced with the local project dependency by running:
```
gradle dependencies --configuration compile
```
没有合适的资源?快使用搜索试试~ 我知道了~
gradle-4.1-all.zip,完整版-解压即可使用
共9995个文件
java:6209个
html:2154个
gradle:468个
3星 · 超过75%的资源 需积分: 21 87 下载量 116 浏览量
2017-11-07
16:32:12
上传
评论 2
收藏 86.27MB ZIP 举报
温馨提示
官网下载不成功的,嫌官网下载速度慢的,可以直接在这里下载。 官网原下载地址:https://services.gradle.org/distributions/
资源推荐
资源详情
资源评论
收起资源包目录
gradle-4.1-all.zip,完整版-解压即可使用 (9995个子文件)
libgtest.a 911KB
libgtest.a 782KB
libcunit.a 95KB
libcunit.a 79KB
org.codehaus.groovy.transform.ASTTransformation 34B
gradle.bat 2KB
org.gradle.initialization.buildsrc.BuildSrcProjectConfigurationAction 76B
gradle_cunit_main.c 1KB
suite_operators.c 395B
main.c 348B
platform-windows.c 229B
platform-mac.c 188B
platform-linux.c 186B
test_minus.c 165B
test_plus.c 162B
plus.c 115B
main.c 115B
hello.c 92B
hello.c 92B
minus.c 70B
main.c 63B
main.c 59B
squareit.coffee 165B
console.coffee 36B
application.conf 2KB
application.conf 2KB
application.conf 2KB
application.conf 2KB
application.conf 2KB
application.conf 2KB
application.conf 2KB
application.conf 590B
application.conf 75B
application.conf 74B
org.gradle.tooling.internal.protocol.ConnectionVersion4 54B
main.cpp 615B
main.cpp 615B
hello.cpp 528B
util.cpp 211B
test_minus.cpp 211B
test_plus.cpp 208B
hello.cpp 190B
hello.cpp 190B
main.cpp 189B
test_main.cpp 154B
hello.cpp 122B
plus.cpp 115B
hello.cpp 111B
hello.cpp 101B
hello.cpp 101B
hello.cpp 100B
main.cpp 92B
main.cpp 92B
hello.cpp 83B
main.cpp 78B
minus.cpp 70B
main.cpp 63B
main.cpp 59B
main.cpp 59B
main.cpp 59B
main.cpp 59B
main.cpp 59B
base.css 847KB
base.css 847KB
bootstrap.min.css 104KB
javadoc.css 14KB
javadoc.css 14KB
javadoc.css 14KB
tree.css 5KB
base-style.css 3KB
release-notes.css 3KB
release-notes.css 3KB
print.css 2KB
print.css 2KB
userguide.css 2KB
userguide.css 2KB
dsl.css 2KB
dsl.css 2KB
style.css 2KB
docs.css 2KB
docs.css 2KB
style.css 2KB
style.css 1KB
style.css 50B
style.css 36B
main.css 0B
main.css 0B
main.css 0B
main.css 0B
main.css 0B
main.css 0B
main.css 0B
data.csv 29B
org.gradle.api.internal.artifacts.DependencyManagementServices 69B
default.vcxproj.filters 658B
Calculator.g 212B
console-animation.gif 141KB
titlebar.gif 10KB
d.gif 3KB
background.gif 2KB
共 9995 条
- 1
- 2
- 3
- 4
- 5
- 6
- 100
资源评论
- 冲锋的炮灰2017-11-13不错不错哦
泡泡泡你
- 粉丝: 18
- 资源: 128
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- J211-T1B-A-VB一款SOT23封装P-Channel场效应MOS管
- J210-VB一款SOT23封装P-Channel场效应MOS管
- content_1713924059748.zip
- J210-T1B-A-VB一款SOT23封装P-Channel场效应MOS管
- Suno V3 AI音乐生成神器,助你秒变音乐大师,suno AI音乐使用教程
- 自适应极化滤波完成P/S波分离
- 0b40adff-950d-44cf-88e6-f4a64292b638.apk
- J209-VB一款SOT23封装P-Channel场效应MOS管
- OLED12864模块(IIC接口)中文说明书.pdf
- 22304010116工管余文贤.bak
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功