2017-04-25 1 views
0

私は、複数のスケーラ/ Javaモジュールが混在した標準のマルチプロジェクトmavenを持つプロジェクトを持っています。Intellijはマルチモジュールのスケーラプロジェクトではうまく機能しません

IntelliJでこのプロジェクトを開くと、scalaフォルダがソース/テストソースのルートフォルダとして認識されません。

. 
|-- pom.xml 
`-- src 
    |-- it 
    | |-- resources 
    | | `-- data.csv 
    | `-- scala #### TEST SOURCES ### 
    |  `-- com 
    |   `-- my 
    |    `-- example 
    |     `-- jetty 
    |      `-- JettyBasedServerIT.scala 
    |-- main 
    | `-- scala #### SOURCES ### 
    |  `-- com 
    |   `-- my 
    |    `-- example 
    |     `-- jetty 
    |      `-- JettyBasedServer.scala 
    `-- test 
     `-- scala #### TEST SOURCES ### 
      `-- com 
       `-- my 
        `-- example 
         `-- jetty 
          `-- MainArgumentsTest.scala 

結果として、相互依存性は認識されません。

私はモジュールでモジュールに移動し、手動でソースフォルダを設定する必要があります。

あなたはそれを自動で行う方法を知っていますか?

答えて

3

intelliJにスカラを持つmavenサブモジュールを設定したかったとき、同様の問題が発生しました。私は最終的に特定のpom.xmlで成功します。あなたはこのように調査するかもしれません。ちょうど私があなたに役に立つかもしれない私のpom.xmlからいくつかの抽出物をあげる情報について

親のpom.xml

<pluginManagement> 
    <plugins> 
      <!-- configure scala style --> 
      <plugin> 
       <groupId>org.scalastyle</groupId> 
       <artifactId>scalastyle-maven-plugin</artifactId> 
       <version>0.8.0</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>check</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <verbose>false</verbose> 
        <failOnViolation>true</failOnViolation> 
        <includeTestSourceDirectory>true</includeTestSourceDirectory> 
        <failOnWarning>false</failOnWarning> 
        <sourceDirectory>${basedir}/src/main/scala</sourceDirectory> 
        <testSourceDirectory>${basedir}/src/test/scala</testSourceDirectory> 
        <outputFile>${project.basedir}/target/scalastyle-output.xml</outputFile> 
        <outputEncoding>UTF-8</outputEncoding> 
       </configuration> 
      </plugin> 

      <!-- set scala maven plugin version --> 
      <plugin> 
       <groupId>net.alchim31.maven</groupId> 
       <artifactId>scala-maven-plugin</artifactId> 
       <version>3.2.2</version> 
       <configuration> 
        <scalaCompatVersion>${scala.binary.version}</scalaCompatVersion> 
        <scalaVersion>${scala.version}</scalaVersion> 
       </configuration> 

      </plugin> 
    </plugins> 
</pluginManagement> 

子のpom.xml

<build> 
     <plugins> 

      <!-- Scala Compiler --> 
      <plugin> 
       <groupId>net.alchim31.maven</groupId> 
       <artifactId>scala-maven-plugin</artifactId> 
       <executions> 
        <!-- Run scala compiler in the process-resources phase, so that dependencies on 
         scala classes can be resolved later in the (Java) compile phase --> 
        <execution> 
         <id>scala-compile-first</id> 
         <phase>process-resources</phase> 
         <goals> 
          <goal>compile</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <jvmArgs> 
         <jvmArg>-Xms128m</jvmArg> 
         <jvmArg>-Xmx512m</jvmArg> 
        </jvmArgs> 
       </configuration> 
      </plugin> 

      <!-- Adding scala source directories to build path --> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>build-helper-maven-plugin</artifactId> 
       <version>1.7</version> 
       <executions> 
        <!-- Add src/main/scala to eclipse build path --> 
        <execution> 
         <id>add-source</id> 
         <phase>generate-sources</phase> 
         <goals> 
          <goal>add-source</goal> 
         </goals> 
         <configuration> 
          <sources> 
           <source>src/main/scala</source> 
          </sources> 
         </configuration> 
        </execution> 
        <!-- Add src/test/scala to eclipse build path --> 
        <execution> 
         <id>add-test-source</id> 
         <phase>generate-test-sources</phase> 
         <goals> 
          <goal>add-test-source</goal> 
         </goals> 
         <configuration> 
          <sources> 
           <source>src/test/scala</source> 
          </sources> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 

      <!-- Scala Code Style, most of the configuration done via plugin management --> 
      <plugin> 
       <groupId>org.scalastyle</groupId> 
       <artifactId>scalastyle-maven-plugin</artifactId> 
       <configuration> 
        <configLocation>${project.basedir}/../../tools/maven/scalastyle-config.xml</configLocation> 
       </configuration> 
      </plugin> 

残念なことに、残念ながら、どの部分が重要であるかを正確に言うことはできませんでした。それが助けてくれることを願って。

1

奇妙なことに、この問題はMavenインポータのメモリの問題に関連していました。 インポートメモリの設定を増やしてプロジェクトを再インポートしたところ、魔法のように機能しました。 enter image description here

+0

このオプションは、自分のpom.xmlで設定できます。 – ImbaBalboa

+0

@ImbaBalboaあなたの答えをありがとう。私はあなたが既に持っていて、intellijに影響しなかったjava-maven-pluginのJVM argsを具体的に設定しているのを見る。 –

関連する問題