IntelliJ IDEA和Gradle:为什么每个子模块有3个模块? [英] IntelliJ IDEA and Gradle: Why there are 3 modules per sub-module?

查看:1167
本文介绍了IntelliJ IDEA和Gradle:为什么每个子模块有3个模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




  • 为什么有3个模块用于每个gradle子项目(client,client_main和client_test)?

  • 有没有办法摆脱父模块?每次删除它时,我的构建都会以混乱的方式破解。





UPDATE




  • 第三个模块的内容根目录)总是设置为整个文件夹,如下所示。这意味着我不能将构建中的目录标记为生成的源,因为默认情况下排除了这些目录。



解决方案

现在可以在导入IDEA中的gradle项目时取消选择该选项,并在2016年检查.2 Ultimate IDE。首先进入导入gradle选项并选择您的gradle文件。





然后在出现的对话框中,确保取消选中为每个源集合创建单独模块的选项。这是默认选择的。现在继续像往常一样导入项目。





就是这样,你可以享受你的项目,只需要为多项目gradle构建中的每个子项目创建一个模块。



这个选项只对你有用在像我这样的测试中有一个单独的子项目。否则,默认方式的效果非常好,因为我发现它更容易启动单元测试。



希望这有助于。


I am rather confused by IntelliJ IDEA's gradle integration and the mapping of gradle subprojects to IDEA's modules.

  • Why are there 3 modules for every gradle subproject (client, client_main and client_test)?
  • Is there a way to get rid of the "parent" module? Every time I delete it my build breaks in confusing ways.

UPDATE

  • The content root of the third module ("server") is always set to the entire folder like seen below. This means I can't mark directories in build as generated sources, since the are excluded by default.

解决方案

It is now possible to deselect that option when importing the gradle project in IDEA, checked in 2016.1.2 Ultimate IDE. First go to the import gradle option and select your gradle file.

Then in the dialog that appears, make sure you deselect the option that says create separate module per source set. This is selected by default. Now continue with importing the project as you normally would.

And that's it, you can enjoy your project, just one module will be created for each sub project in the multi project gradle build.

This option is only useful if you are having a separate sub project in gradle for the tests like me. Otherwise, the default way works pretty much good, as I found it more easy to launch unit tests.

Hope this helps.

这篇关于IntelliJ IDEA和Gradle:为什么每个子模块有3个模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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