简体   繁体   English

Sbt的创想总是创建两个IntelliJ项目

[英]Sbt's gen-idea always creates two IntelliJ projects

I am new to SBT. 我是SBT的新手。 Just be curious that why does sbt's gen-idea always generate two IntelliJ projects: 很好奇为什么sbt的gen-idea总是生成两个IntelliJ项目:

 .idea
 .idea_modules

When I open the generated project, the "project" directory is always there as a separate project different with the top level project. 当我打开生成的项目时,“ project”目录始终作为与顶层项目不同的单独项目存在。 The name is "myproject-build". 名称是“ myproject-build”。

Just wondering whether this is normal? 只想知道这是否正常?

Thanks. 谢谢。

Yes this is normal, this is the default behavior. 是的,这是正常现象,这是默认行为。 You can change it by excluding some folders (see the doc available here : https://github.com/mpeltonen/sbt-idea at Exclude some folders ) 您可以通过排除某些文件夹来进行更改(请参阅此处的文档: https : //github.com/mpeltonen/sbt-idea,位于“ 排除某些文件夹”

So what is the difference between .idea and .idea_modules? 那么.idea和.idea_modules有什么区别?

.idea_module generates an IDEA module while .idea generates an IDEA project. .idea_module生成一个IDEA模块,而.idea生成一个IDEA项目。

In short a project can be multi-module or single-module and also contains IntelliJ libraries. 简而言之 ,项目可以是多模块或单模块,并且还包含IntelliJ库。

In longer version from the doc ( http://confluence.jetbrains.com/display/IDEADEV/Structure+of+IntelliJ+IDEA+Project ) 文档的更长版本中http://confluence.jetbrains.com/display/IDEADEV/Structure+of+IntelliJ+IDEA+Project

Project 项目

In IntelliJ IDEA, a project encapsulates all your source code, libraries, build instructions into a single organizational unit. 在IntelliJ IDEA中,一个项目将所有源代码,库,构建说明封装到一个组织单位中。 Everything you do in IntelliJ IDEA, is done within the context of a project. 您在IntelliJ IDEA中所做的所有事情都是在项目上下文中完成的。 A project defines some collections referred to as modules and libraries. 一个项目定义了一些称为模块和库的集合。 Depending on the logical and functional requirements to the project, you can create a single-module or a multi-module project. 根据项目的逻辑和功能要求,可以创建单模块或多模块项目。

Module 模组

A module is a discrete unit of functionality that can be run, tested, and debugged independently. 模块是可以独立运行,测试和调试的离散功能单元。 Modules includes such things as source code, build scripts, unit tests, deployment descriptors, etc. In the project, each module can use a specific SDK or inherit SDK defined on the project level (see the SDK section later in this document). 模块包括诸如源代码,构建脚本,单元测试,部署描述符等内容。在项目中,每个模块都可以使用特定的SDK或继承在项目级别定义的SDK(请参阅本文档后面的“ SDK”部分)。 A module can depend on other modules of the project. 一个模块可以依赖于项目的其他模块。

Yes, it is ok for that SBT plugin for IDEA. 是的,对于IDEA的SBT插件没问题。

Usually IDEA project consists of top-level .idea directory (which contains configuration common to the project) and several *.iml files, one for each module in the project (module-specific configuration, like facets, excluded directories, custom dependencies). 通常,IDEA项目由顶级.idea目录(包含项目通用的配置)和几个*.iml文件组成,每个文件用于项目中的每个模块(特定于模块的配置,例如构面,排除目录,自定义依赖项)。 These files are usually located in the top-level directories of corresponding modules. 这些文件通常位于相应模块的顶级目录中。

On the other hand, SBT plugin does something unusual. 另一方面,SBT插件做了一些不寻常的事情。 It creates standard .idea directory, but it stores all project modules in one location, namely .idea_modules directory in the top-level directory of the project. 它创建标准的.idea目录,但将所有项目模块存储在一个位置,即项目.idea_modules目录中的.idea_modules目录。 This is fully supported by IDEA project structure, which is a set of XMLs after all. IDEA项目结构完全支持此功能,IDEA项目结构毕竟是一组XML。

As for project directory/module, it is a standard feature of SBT builds. 对于project目录/模块,这是SBT构建的标准功能。 It contains your build configuration. 它包含您的构建配置。 See SBT manual on this. 参见SBT手册

The foregoing was about SBT plugin which is currently present in plugins repo. 前面的内容是关于SBT插件的,它当前存在于插件存储库中。 There is an official SBT plugin in active development which keeps familiar modules structure (no .idea_modules directory) and has higher integration with SBT. 在积极开发中有一个官方的SBT插件 ,可以保持熟悉的模块结构(没有.idea_modules目录),并且与SBT的集成度更高。 The latter is most prominent in dependency management - official plugin extracts dependencies, even unmanaged, and makes them available for the IDE; 后者在依赖关系管理中最为突出-官方插件会提取依赖关系,甚至是不受管理的依赖关系,并使其可用于IDE。 current SBT plugin cannot do that. 当前的SBT插件无法做到这一点。

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

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