简体   繁体   English

Gradle:如何使用并行项目配置多项目设置

[英]Gradle: How to configure multiproject setup with side-by-side projects

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.这个想法是customizationProject 是交付应用程序的最终组装发生的地方,实际上可能有多个customizationProjects ,它们可能包括多个配置。 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.我想让customizationProject 成为gradle 项目的逻辑根项目。 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, eg just running the tests of one subproject, while also allowing all tests to be executed accross all the projects?我如何配置单个项目,以便它们 a) 知道它们是多项目构建的一部分 b) 可以在不同的范围内正确执行,例如只运行一个子项目的测试,同时还允许执行所有测试跨所有项目?

This is a fairly easy structure to support with Gradle.这是一个相当容易用 Gradle 支持的结构。 Add a settings.gradle file to your customizationProject directory with this content:使用以下内容将 settings.gradle 文件添加到您的自定义项目目录:

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 . includeFlat 方法的描述可在Gradle 文档 中找到

Hope that helps!希望有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM