简体   繁体   中英

IntelliJ SBT - Module naming

What does

IntelliJ IDEA 2016.1.1
Build #IU-145.597, built on March 29, 2016
JRE: 1.8.0_40-release-b132 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Scala Plugin Version: 3.0.2

use to determine the name of the root module?

I always thought it used the name := "[name]" defined inside the build.sbt file for the naming of the root module but my current SBT project (which uses Scala.JS CrossProject ) falls-back/uses the parent directory name (see pictures 1 through 3).

Is there any way I can change this behavior?

  • Is there a master override of any sort?
  • Is this a result of using CrossProject ?
  • If yes, how can create the same effect without the use of CrossProject ?

SBT 模块概述

文件夹结构概述

<code>build.sbt</code> 片段

It appears that the issue at hand is not a bug in IntelliJ, but rather a "feature" in SBT. When there is no project that uses the root path, SBT automatically creates one for you that aggregates all sub projects and names it after the parent directory. Defining a root project like this:

lazy val root = project in file(".").
    aggregate(cross.js, cross.jvm).
    settings(...)

lazy val cross = CrossProject("jvm", "js", file("."), FullWithSrc).
    settings(...)

will fix this problem and use the correct naming.

CrossProject only specifies two projects and creates an unmanagedSources entry in the settings for any shared code. The two projects that were created by CrossProject are accessible by CrossProject#js and CrossProject#jvm . Setting the aggregate property on the SBT project will make any commands issued for the root, trickle down to the sub projects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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