Gradle:如何使用并行项目配置多项目设置 [英] Gradle: How to configure multiproject setup with side-by-side projects

查看:29
本文介绍了Gradle:如何使用并行项目配置多项目设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个旧项目是这样设置的:

<预><代码>.├── 定制项目│ ├── ejb│ └── 服务├──项目A│ ├── ejb│ └── 分享├──项目B│ └── ejb└── 项目C├── ejb└── 服务

这个想法是,customizationProject 是所交付应用程序的最终组装发生的地方,实际上可能有多个 customizationProjects 并且它们可能包含多个配置.然而,这并不是我想要解决的问题.

我想让customizationProject成为gradle项目的逻辑根项目.我如何配置单个项目,以便它们a) 知道它们是多项目构建的一部分b) 可以正确执行,具有不同的范围,例如只运行一个子项目的测试,同时还允许在所有项目中执行所有测试?

解决方案

这是 Gradle 支持的相当简单的结构.使用以下内容将 settings.gradle 文件添加到您的自定义项目目录:

includeFlat 'projectA', 'projectB', 'projectC'

并且您可以从命令行确认项目结构:

$ gradle 项目:项目------------------------------------------------------------根项目------------------------------------------------------------根项目customizationProject"+--- 项目 ':projectA'+--- 项目 ':projectB'--- 项目 ':projectC'

includeFlat 方法的描述可在 Gradle 文档.

希望有帮助!

We have an old project that is set up like this:

.
├── customizationProject
│   ├── ejb
│   └── services
├── projectA
│   ├── ejb
│   └── shared
├── projectB
│   └── ejb
└── projectC
    ├── ejb
    └── services

The idea is that the customizationProject is where the final assembly of the delivered application happends, there might in fact be multiple customizationProjects and they might include multiple configurations. That, however is not the problem I'm tyring to solve.

I want to make the customizationProject the logical root project of the gradle projects. How do I configure the individual projects, so that they a) know they're part of a multiproject build b) can be properly executed, with different scopes, e.g. just running the tests of one subproject, while also allowing all tests to be executed accross all the projects?

解决方案

This is a fairly easy structure to support with Gradle. Add a settings.gradle file to your customizationProject directory with this content:

includeFlat 'projectA', 'projectB', 'projectC'

And you can confirm the project structure from the command line:

$ gradle projects
:projects

------------------------------------------------------------
Root Project
------------------------------------------------------------

Root project 'customizationProject'
+--- Project ':projectA'
+--- Project ':projectB'
--- Project ':projectC'

The description of the includeFlat method is available in the Gradle documentation.

Hope that helps!

这篇关于Gradle:如何使用并行项目配置多项目设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆