如何使用Gradle设置多项目IntelliJ工作区? [英] How to setup multi-project IntelliJ workspace with Gradle?
问题描述
您好,我正在使用Gradle构建一些服务.对于每个代码包",我倾向于有单独的存储库.即图书馆或服务.
Hello I am working on using Gradle to build a few services. I tend to have seperate repositories for each "code package" i.e. library or service.
在IntelliJ中,我的设置通常如下:
In IntelliJ, my setup tends to be the following:
- IntelliJ Workspace
-- Service A
--- pom.xml
-- Service B
--- pom.xml
-- Library A
--- pom.xml
-- Library B
--- pom.xml
服务A&B都依赖于库A和A.B.这很好用,在一个IntelliJ工作区中,我可以修改库A和B并启动服务,一切都很好.
Service A & B both depend on Library A & B. This works great, within a single IntelliJ Workspace I can modify Library A and B and startup the services and all is well.
我知道您可以使用Gradle进行复合构建和多模块构建,但是就像我说的那样,上述所有4个模块都是单独的存储库,因此无法正常工作.
I know you can do composite builds and multi-module builds with Gradle but like I said all the 4 modules above are seperate repositories so this won't work well.
IntelliJ将通过Gradle支持与上述类似的设置,从而重新识别Library A&B是服务A和服务库.B靠什么?还是每个人都为此一贯地向Maven local发布手册?
谢谢!
推荐答案
重述您的问题-
有3个单独的gradle项目service1,lib1,lib2
service1取决于lib1和lib2
Rephrasing your question -
there are 3 separate gradle projects service1, lib1, lib2
service1 depends on lib1 and lib2
期望是什么
- 用于本地开发-在本地存在所有三个项目的源-使用本地代码构建
- 如果本地源不存在,请参考存储库工件
假设这样的简单文件夹结构.
Assuming a simple folder structure like this.
app-code
- service1
- lib1
- lib2
service1-settings.gradle
service1 - settings.gradle
rootProject.name = 'service1'
include ':lib1'
project(':lib1').projectDir = new File('../lib1')
include ':lib2'
project(':lib2').projectDir = new File('../lib2')
service1-build.gradle
service1 - build.gradle
dependencies {
implementation (project(':lib1').projectDir.exists() ? project(':lib1') : 'com.lib1:lib1:1.0.0')
implementation (project(':lib2').projectDir.exists() ? project(':lib2') : 'com.lib2:lib2:1.0.0')
}
intellij导入的外观
how intellij import looks
这篇关于如何使用Gradle设置多项目IntelliJ工作区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!