Java code does not recognize some of the Scala classes

153 views
Skip to first unread message

Eyal Allweil

unread,
Apr 14, 2019, 8:27:19 AM4/14/19
to Scala IDE User
Hi guys,

I'm trying to work with a mixed Java-Scala maven project. Some of the Scala classes are recognized by the Java code, and some aren't. It looks like the Scala IDE recognizes the classes that are in the same package, but doesn't see the Scala classes that are in a different package.

This happens both in Scala IDE version 4.7.0 and in the release candidate for 4.7.1. The "regular" maven build compile successfully, but the Scala files are marked as unknown within the Java code. However, if I use F3 (open declaration) on them from within the Java code, the Scala source code is opened successfully.

Anyone have any ideas on how I can make this work?

Here is a snippet of the "effective pom" for the scala-maven-plgin and the maven-compiler-plugin.

   <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-maven-plugin</artifactId>
        <version>4.0.1</version>
        <executions>
          <execution>
            <id>scala-compile</id>
            <phase>compile</phase>
            <goals>
              <goal>add-source</goal>
              <goal>compile</goal>
            </goals>
            <configuration>
              <scalaCompatVersion>2.11</scalaCompatVersion>
              <scalaVersion>2.11.8</scalaVersion>
              <jvmArgs>
                <jvmArg>-Xms64m</jvmArg>
                <jvmArg>-Xmx1024m</jvmArg>
              </jvmArgs>
            </configuration>
          </execution>
          <execution>
            <id>scala-test-compile</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
            <configuration>
              <scalaCompatVersion>2.11</scalaCompatVersion>
              <scalaVersion>2.11.8</scalaVersion>
              <jvmArgs>
                <jvmArg>-Xms64m</jvmArg>
                <jvmArg>-Xmx1024m</jvmArg>
              </jvmArgs>
            </configuration>
          </execution>
          <execution>
            <id>scala-compile-first</id>
            <phase>process-resources</phase>
            <goals>
              <goal>add-source</goal>
              <goal>compile</goal>
            </goals>
            <configuration>
              <scalaCompatVersion>2.11</scalaCompatVersion>
              <scalaVersion>2.11.8</scalaVersion>
              <jvmArgs>
                <jvmArg>-Xms64m</jvmArg>
                <jvmArg>-Xmx1024m</jvmArg>
              </jvmArgs>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <scalaCompatVersion>2.11</scalaCompatVersion>
          <scalaVersion>2.11.8</scalaVersion>
          <jvmArgs>
            <jvmArg>-Xms64m</jvmArg>
            <jvmArg>-Xmx1024m</jvmArg>
          </jvmArgs>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <executions>
          <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <source>1.8</source>
              <target>1.8</target>
              <optimize>true</optimize>
              <showDeprecation>true</showDeprecation>
              <encoding>UTF-8</encoding>
            </configuration>
          </execution>
          <execution>
            <id>default-testCompile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
            <configuration>
              <source>1.8</source>
              <target>1.8</target>
              <optimize>true</optimize>
              <showDeprecation>true</showDeprecation>
              <encoding>UTF-8</encoding>
            </configuration>
          </execution>
          <execution>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <source>1.8</source>
              <target>1.8</target>
              <optimize>true</optimize>
              <showDeprecation>true</showDeprecation>
              <encoding>UTF-8</encoding>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
          <optimize>true</optimize>
          <showDeprecation>true</showDeprecation>
          <encoding>UTF-8</encoding>
        </configuration>
      </plugin>

eyal.a...@gmail.com

unread,
May 1, 2019, 2:03:05 AM5/1/19
to Scala IDE User
Since this hasn't gotten a response, let me ask a different question - how do I open a bug? I signed up for Assembla according to the instructions here


But I couldn't open a new bug. If there's a chance someone will help me, I will try to create a simple project that replicates the problem.

Eyal Allweil

unread,
Jun 13, 2019, 4:47:52 AM6/13/19
to Scala IDE User
It turns out that the problem was the existence of Java classes with identical package names as the Scala classes (that didn't work). Because F3 (open declaration) on the references to these classes opened the Scala classes, I didn't realize their was a Java class that was "shadowing it". Removing these (old, unnecessary) Java classes solved the problem.


On Sunday, April 14, 2019 at 3:27:19 PM UTC+3, Eyal Allweil wrote:
Reply all
Reply to author
Forward
0 new messages