Can I keep my java and scala code both in src/main/java

122 views
Skip to first unread message

Rajat Khandelwal

unread,
Mar 4, 2019, 5:05:45 AM3/4/19
to Scala IDE User
Hi 

So this is my project structure:

My project is a maven project, with most of the code being in java, and some of it in scala. The thing to note here is that my source directory for both is same, i.e. src/main/java. I don't want to create src/main/scala since then classes in the same package would reside in different directories and I don't want that. 

For building via maven, I use scala-maven-plugin like below:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.4.4</version>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile-first</id>
<phase>process-test-resources</phase>
<goals>
<goal>add-source</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>

For IDE, I use IntelliJ and that has a very good scala plugin, which handles everything smoothly. 
My colleagues use Eclipse and for them, they have to install Scala IDE for eclipse to be able to handle scala code. 

Now the problem is that because my scala code resides inside src/main/java, it's not "detected" and java code depending on those shows the error "symbol so and so could not be resolved". I tried moving scala files to src/main/scala and it seems to pick them up fine after that. So I do have a workaround, but as I mentioned earlier, I don't want classes of same package residing in different directories. 

So essentially my question is: Is there a way for Scala IDE to pick up scala code from src/main/java? Any pointers are appreciated. 



David Bernard

unread,
Mar 4, 2019, 7:13:07 AM3/4/19
to scala-i...@googlegroups.com
Yes, try to remove
<goal>add-source</goal>

--
You received this message because you are subscribed to the Google Groups "Scala IDE User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-ide-user/fcc27ee9-12b5-4c62-8b14-c4d8eb47682f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages