# 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 runtimeClasspath
```
>>>
```
runtimeClasspath - Runtime classpath of 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 runtimeClasspath
```
>>>
```
runtimeClasspath - Runtime classpath of 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 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依赖包的spring依赖
共2000个文件
java:16284个
html:2407个
gradle:1976个
需积分: 0 0 下载量 98 浏览量
2022-10-31
22:54:47
上传
评论
收藏 445.71MB 7Z 举报
温馨提示
spring依赖包
资源推荐
资源详情
资源评论
收起资源包目录
Gradle依赖包的spring依赖 (2000个子文件)
gradle_cunit_main.c 1KB
gradle_cunit_main.c 1KB
suite_operators.c 395B
suite_operators.c 395B
main.c 348B
main.c 348B
platform-windows.c 229B
platform-windows.c 229B
platform-mac.c 188B
platform-mac.c 188B
platform-linux.c 186B
platform-linux.c 186B
test_minus.c 165B
test_minus.c 165B
test_plus.c 161B
test_plus.c 161B
plus.c 115B
main.c 115B
main.c 115B
plus.c 115B
hello.c 92B
hello.c 92B
hello.c 92B
hello.c 92B
minus.c 70B
minus.c 70B
main.c 63B
main.c 63B
main.c 59B
main.c 59B
main.cpp 615B
main.cpp 615B
main.cpp 615B
main.cpp 615B
hello.cpp 528B
hello.cpp 528B
util.cpp 211B
test_minus.cpp 211B
util.cpp 211B
test_minus.cpp 211B
test_plus.cpp 208B
test_plus.cpp 208B
hello.cpp 190B
hello.cpp 190B
hello.cpp 190B
hello.cpp 190B
main.cpp 189B
main.cpp 189B
test_main.cpp 153B
test_main.cpp 153B
hello.cpp 122B
hello.cpp 122B
plus.cpp 115B
plus.cpp 115B
hello.cpp 111B
hello.cpp 111B
hello.cpp 101B
hello.cpp 101B
hello.cpp 101B
hello.cpp 101B
hello.cpp 100B
hello.cpp 100B
main.cpp 92B
main.cpp 92B
main.cpp 92B
main.cpp 92B
hello.cpp 83B
hello.cpp 83B
main.cpp 78B
main.cpp 78B
minus.cpp 70B
minus.cpp 70B
main.cpp 63B
main.cpp 63B
main.cpp 59B
main.cpp 59B
main.cpp 59B
main.cpp 59B
main.cpp 59B
main.cpp 59B
main.cpp 59B
main.cpp 59B
bootstrap.min.css 104KB
bootstrap.min.css 104KB
manual.css 89KB
manual.css 89KB
base.css 32KB
base.css 32KB
javadoc.css 27KB
javadoc.css 27KB
javadoc.css 27KB
jquery-ui.css 20KB
jquery-ui.min.css 17KB
main.css 13KB
main.css 13KB
tree.css 5KB
tree.css 5KB
instant-execution-report.css 5KB
instant-execution-report.css 5KB
base-style.css 3KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
aleil_cc
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功