This page is no longer maintained — Please continue to the home page at www.scala-lang.org

m2eclipse multi module

8 replies
tim tim
Joined: 2009-09-15,
User offline. Last seen 42 years 45 weeks ago.

Hello

I have a problem with multi module scala projects in eclipse.

The project consists of a main project with a submodule with scala
code (there is no java code in the scala submodule).
I created the scala project from the scala-archetype-simple and
changed the scala version. The whole project is attached.

Most things work fine.
The problem is that errors and warnings are only shown in the main
project and not the scala submodule / project. I attached a picture of my
eclipse workspace - you can see: the red error markers are only
added to the project explorer view of the main project.

If I double click an error in the Problems-View the file is opened in
the context of the main project which of course has no scala nature
and the source is not syntax highlightened and not always up to date
with the view of the same file in the context of the scala sub
project.

Is there any configuration I could put into my pom or which i could
set in eclipse so that the errors appear where they really are?

I did not find a bug in the Scala trac that seems to relate to my problem.

My configuration is Ubuntu 9.4 64bit, Eclipse 3.5, Scala IDE for
Eclipse 2.7.6-final, m2eclipse 0.9.200905041414,
maven 2.0.9, sun java 1.6.0_16-b01

Does anyone use multi module maven projects with scala and m2eclipse?
I can not put all source files into one big project as I am working
with a Java project that is already split into multiple modules. But I
would love to implement new modules using Scala.

Using the eclipse maven plugin for creating the eclipse projects is
unfortunately also not an option as multiple developers are working
with the codebase and I can not make them all abandon the m2eclipse
plugin.

Thanks, Tim

Joshua.Suereth
Joined: 2008-09-02,
User offline. Last seen 32 weeks 5 days ago.
Re: m2eclipse multi module

Did you use the context menu "Scala -> add Scala Nature" on the scala
project?

I believe what you're seeing is errors from m2e running the maven build.

When I have a real computer, I'll look at your project.

Sent from my iPhone

On Sep 14, 2009, at 10:48 PM, tim tim
wrote:

> Hello
>
> I have a problem with multi module scala projects in eclipse.
>
> The project consists of a main project with a submodule with scala
> code (there is no java code in the scala submodule).
> I created the scala project from the scala-archetype-simple and
> changed the scala version. The whole project is attached.
>
> Most things work fine.
> The problem is that errors and warnings are only shown in the main
> project and not the scala submodule / project. I attached a picture
> of my
> eclipse workspace - you can see: the red error markers are only
> added to the project explorer view of the main project.
>
> If I double click an error in the Problems-View the file is opened in
> the context of the main project which of course has no scala nature
> and the source is not syntax highlightened and not always up to date
> with the view of the same file in the context of the scala sub
> project.
>
> Is there any configuration I could put into my pom or which i could
> set in eclipse so that the errors appear where they really are?
>
> I did not find a bug in the Scala trac that seems to relate to my
> problem.
>
> My configuration is Ubuntu 9.4 64bit, Eclipse 3.5, Scala IDE for
> Eclipse 2.7.6-final, m2eclipse 0.9.200905041414,
> maven 2.0.9, sun java 1.6.0_16-b01
>
> Does anyone use multi module maven projects with scala and m2eclipse?
> I can not put all source files into one big project as I am working
> with a Java project that is already split into multiple modules. But I
> would love to implement new modules using Scala.
>
> Using the eclipse maven plugin for creating the eclipse projects is
> unfortunately also not an option as multiple developers are working
> with the codebase and I can not make them all abandon the m2eclipse
> plugin.
>
>
> Thanks, Tim
>
>

milessabin
Joined: 2008-08-11,
User offline. Last seen 33 weeks 3 days ago.
Re: m2eclipse multi module

On Mon, Sep 14, 2009 at 7:48 PM, tim tim
wrote:
> The problem is that errors and warnings are only shown in the main
> project and not the scala submodule / project. I attached a picture of my
> eclipse workspace - you can see: the red error markers are only
> added to the project explorer view of the main project.

From that screenshot it looks like you have two Eclipse projects
nested one inside the other ... I'd be surprised if that worked
correctly whether or not Scala was involved.

I suggest rearranging things so that you have two non-nested top-level
project and get back to me if that doesn't solve the problem.

Cheers,

Miles

tim tim
Joined: 2009-09-15,
User offline. Last seen 42 years 45 weeks ago.
Re: m2eclipse multi module

Thanks Miles,

> From that screenshot it looks like you have two Eclipse projects
> nested one inside the other ...

yes that is true,
one project is part of an other one.
But that is a typical maven setup and it works fine with java projects.

> I'd be surprised if that worked
> correctly whether or not Scala was involved.

I added a java project parallel to the scala project. Both are
submodules of the main module. The java project works as expected, the
scala project does not.

@Josh:
And closing the main project does not help either.

I attached a screenshot that shows the problem.

If I make the scala project a top level maven project and not a
submodule of a bigger project, as you suggest, everything works fine.

But that is exactly the problem that I have: I would like the scala
module to be part of a bigger java project which gets build via
maven2.
The maven2 build part works fine with the setup as I have it now. But
then eclipse does not work as expected. And if I make the scala
project a top level maven project eclipse works fine, but the maven2
build does not...

Thanks again for your kind help,

Tim

On Wed, Sep 16, 2009 at 9:38 PM, Miles Sabin wrote:
> On Mon, Sep 14, 2009 at 7:48 PM, tim tim
> wrote:
>> The problem is that errors and warnings are only shown in the main
>> project and not the scala submodule / project. I attached a picture of my
>> eclipse workspace - you can see: the red error markers are only
>> added to the project explorer view of the main project.
>
> From that screenshot it looks like you have two Eclipse projects
> nested one inside the other ... I'd be surprised if that worked
> correctly whether or not Scala was involved.
>
> I suggest rearranging things so that you have two non-nested top-level
> project and get back to me if that doesn't solve the problem.
>
> Cheers,
>
>
> Miles
>
> --
> Miles Sabin
> tel: +44 (0)7813 944 528
> skype:  milessabin
> http://www.chuusai.com/
> http://twitter.com/milessabin
>

Joshua.Suereth
Joined: 2008-09-02,
User offline. Last seen 32 weeks 5 days ago.
Re: m2eclipse multi module
I highly doubt the nested projects is the problem as I use this style setup everyday at work.  It's also how both maven plugins do eclipse integration. 

I'm wondering if m2e is doing something strange.  Like I said, I have not used m2e for a long time.

- Josh

On Wed, Sep 16, 2009 at 9:38 AM, Miles Sabin <miles@milessabin.com> wrote:
On Mon, Sep 14, 2009 at 7:48 PM, tim tim
<timbaermannextra@googlemail.com> wrote:
> The problem is that errors and warnings are only shown in the main
> project and not the scala submodule / project. I attached a picture of my
> eclipse workspace - you can see: the red error markers are only
> added to the project explorer view of the main project.

From that screenshot it looks like you have two Eclipse projects
nested one inside the other ... I'd be surprised if that worked
correctly whether or not Scala was involved.

I suggest rearranging things so that you have two non-nested top-level
project and get back to me if that doesn't solve the problem.

Cheers,


Miles

--
Miles Sabin
tel: +44 (0)7813 944 528
skype:  milessabin
http://www.chuusai.com/
http://twitter.com/milessabin

Joshua.Suereth
Joined: 2008-09-02,
User offline. Last seen 32 weeks 5 days ago.
Re: m2eclipse multi module
Oh, can I also see your pom?

On Wed, Sep 16, 2009 at 11:47 AM, Josh Suereth <joshua.suereth@gmail.com> wrote:
I highly doubt the nested projects is the problem as I use this style setup everyday at work.  It's also how both maven plugins do eclipse integration. 

I'm wondering if m2e is doing something strange.  Like I said, I have not used m2e for a long time.

- Josh

On Wed, Sep 16, 2009 at 9:38 AM, Miles Sabin <miles@milessabin.com> wrote:
On Mon, Sep 14, 2009 at 7:48 PM, tim tim
<timbaermannextra@googlemail.com> wrote:
> The problem is that errors and warnings are only shown in the main
> project and not the scala submodule / project. I attached a picture of my
> eclipse workspace - you can see: the red error markers are only
> added to the project explorer view of the main project.

From that screenshot it looks like you have two Eclipse projects
nested one inside the other ... I'd be surprised if that worked
correctly whether or not Scala was involved.

I suggest rearranging things so that you have two non-nested top-level
project and get back to me if that doesn't solve the problem.

Cheers,


Miles

--
Miles Sabin
tel: +44 (0)7813 944 528
skype:  milessabin
http://www.chuusai.com/
http://twitter.com/milessabin


Joshua.Suereth
Joined: 2008-09-02,
User offline. Last seen 32 weeks 5 days ago.
Re: m2eclipse multi module
Try disabling the maven builder, so only the scala builder runs.  I'm curious if there's some conflicts between the two.  I'm going to start monitor the m2e lists to see if I can figure out what/how they're doing integration.

- Josh

On Wed, Sep 16, 2009 at 11:28 AM, tim tim <timbaermannextra@googlemail.com> wrote:
Thanks Miles,

> From that screenshot it looks like you have two Eclipse projects
> nested one inside the other ...

yes that is true,
one project is part of an other one.
But that is a typical maven setup and it works fine with java projects.

> I'd be surprised if that worked
> correctly whether or not Scala was involved.

I added a java project parallel to the scala project. Both are
submodules of the main module. The java project works as expected, the
scala project does not.

@Josh:
And closing the main project does not help either.

I attached a screenshot that shows the problem.

If I make the scala project a top level maven project and not a
submodule of a bigger project, as you suggest, everything works fine.

But that is exactly the problem that I have: I would like the scala
module to be part of a bigger java project which gets build via
maven2.
The maven2 build part works fine with the setup as I have it now. But
then eclipse does not work as expected. And if I make the scala
project a top level maven project eclipse works fine, but the maven2
build does not...

Thanks again for your kind help,

Tim


On Wed, Sep 16, 2009 at 9:38 PM, Miles Sabin <miles@milessabin.com> wrote:
> On Mon, Sep 14, 2009 at 7:48 PM, tim tim
> <timbaermannextra@googlemail.com> wrote:
>> The problem is that errors and warnings are only shown in the main
>> project and not the scala submodule / project. I attached a picture of my
>> eclipse workspace - you can see: the red error markers are only
>> added to the project explorer view of the main project.
>
> From that screenshot it looks like you have two Eclipse projects
> nested one inside the other ... I'd be surprised if that worked
> correctly whether or not Scala was involved.
>
> I suggest rearranging things so that you have two non-nested top-level
> project and get back to me if that doesn't solve the problem.
>
> Cheers,
>
>
> Miles
>
> --
> Miles Sabin
> tel: +44 (0)7813 944 528
> skype:  milessabin
> http://www.chuusai.com/
> http://twitter.com/milessabin
>

tim tim
Joined: 2009-09-15,
User offline. Last seen 42 years 45 weeks ago.
Re: m2eclipse multi module

Disabling the m2e builder in eclipse did not help.

my poms are :

for the main project:

4.0.0
testGroup
mainProj
pom
1.0-SNAPSHOT
mainProj
http://maven.apache.org

junit
junit
3.8.1
test

scalaModule
javaProj

and for the scala project :

<?xml version="1.0"?>

mainProj
testGroup
1.0-SNAPSHOT

4.0.0
testGrp
scalaModule
1.0-SNAPSHOT

src/main/scala
src/test/scala

org.scala-tools
maven-scala-plugin

compile
testCompile

${scala.version}

-target:jvm-1.5

maven-eclipse-plugin

true

ch.epfl.lamp.sdt.core.scalabuilder

ch.epfl.lamp.sdt.core.scalanature

org.eclipse.jdt.launching.JRE_CONTAINER
ch.epfl.lamp.sdt.launching.SCALA_CONTAINER

scala-tools.org
Scala-Tools Maven2 Repository
http://scala-tools.org/repo-releases

scala-tools.org
Scala-Tools Maven2 Repository
http://scala-tools.org/repo-releases

org.scala-lang
scala-library
${scala.version}

junit
junit
4.4
test

org.specs
specs
1.2.5
test

org.scala-tools
maven-scala-plugin

${scala.version}

2.7.6

best, tim

On Wed, Sep 16, 2009 at 11:49 PM, Josh Suereth wrote:
> Oh, can I also see your pom?
>
> On Wed, Sep 16, 2009 at 11:47 AM, Josh Suereth
> wrote:
>>
>> I highly doubt the nested projects is the problem as I use this style
>> setup everyday at work.  It's also how both maven plugins do eclipse
>> integration.
>>
>> I'm wondering if m2e is doing something strange.  Like I said, I have not
>> used m2e for a long time.
>>
>> - Josh
>>
>> On Wed, Sep 16, 2009 at 9:38 AM, Miles Sabin wrote:
>>>
>>> On Mon, Sep 14, 2009 at 7:48 PM, tim tim
>>> wrote:
>>> > The problem is that errors and warnings are only shown in the main
>>> > project and not the scala submodule / project. I attached a picture of
>>> > my
>>> > eclipse workspace - you can see: the red error markers are only
>>> > added to the project explorer view of the main project.
>>>
>>> From that screenshot it looks like you have two Eclipse projects
>>> nested one inside the other ... I'd be surprised if that worked
>>> correctly whether or not Scala was involved.
>>>
>>> I suggest rearranging things so that you have two non-nested top-level
>>> project and get back to me if that doesn't solve the problem.
>>>
>>> Cheers,
>>>
>>>
>>> Miles
>>>
>>> --
>>> Miles Sabin
>>> tel: +44 (0)7813 944 528
>>> skype:  milessabin
>>> http://www.chuusai.com/
>>> http://twitter.com/milessabin
>>
>
>

Joshua.Suereth
Joined: 2008-09-02,
User offline. Last seen 32 weeks 5 days ago.
Re: m2eclipse multi module
The maven-eclipse-plugin is what's setting up the scala nature.  m2eclipse makes special knowledge of this plugin and tries to set up the project appropriately.  See if Removing/Adding the Scala Nature helps.  I'm swamped for time at work.  I'll see if i can play through this and offer some help soon.

- Josh

On Thu, Sep 17, 2009 at 12:15 PM, tim tim <timbaermannextra@googlemail.com> wrote:
Disabling the m2e builder in eclipse did not help.

my poms are :

for the main project:

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>testGroup</groupId>
 <artifactId>mainProj</artifactId>
 <packaging>pom</packaging>
 <version>1.0-SNAPSHOT</version>
 <name>mainProj</name>
 <url>http://maven.apache.org</url>
 <dependencies>
   <dependency>
     <groupId>junit</groupId>
     <artifactId>junit</artifactId>
     <version>3.8.1</version>
     <scope>test</scope>
   </dependency>
 </dependencies>
 <modules>
   <module>scalaModule</module>
   <module>javaProj</module>
 </modules>
</project>

and for the scala project :

<?xml version="1.0"?><project>
 <parent>
   <artifactId>mainProj</artifactId>
   <groupId>testGroup</groupId>
   <version>1.0-SNAPSHOT</version>
 </parent>
 <modelVersion>4.0.0</modelVersion>
 <groupId>testGrp</groupId>
 <artifactId>scalaModule</artifactId>
 <version>1.0-SNAPSHOT</version>

 <build>
   <sourceDirectory>src/main/scala</sourceDirectory>
   <testSourceDirectory>src/test/scala</testSourceDirectory>
   <plugins>
     <plugin>
       <groupId>org.scala-tools</groupId>
       <artifactId>maven-scala-plugin</artifactId>
       <executions>
         <execution>
           <goals>
             <goal>compile</goal>
             <goal>testCompile</goal>
           </goals>
         </execution>
       </executions>
       <configuration>
         <scalaVersion>${scala.version}</scalaVersion>
         <args>
           <arg>-target:jvm-1.5</arg>
         </args>
       </configuration>
     </plugin>
     <plugin>
       <artifactId>maven-eclipse-plugin</artifactId>
       <configuration>
         <downloadSources>true</downloadSources>
         <buildcommands>
           <buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand>
         </buildcommands>
         <additionalProjectnatures>
           <projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature>
         </additionalProjectnatures>
         <classpathContainers>
           <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
           <classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
         </classpathContainers>
       </configuration>
     </plugin>
   </plugins>
 </build>
 <repositories>
   <repository>
     <id>scala-tools.org</id>
     <name>Scala-Tools Maven2 Repository</name>
     <url>http://scala-tools.org/repo-releases</url>
   </repository>
 </repositories>
 <pluginRepositories>
   <pluginRepository>
     <id>scala-tools.org</id>
     <name>Scala-Tools Maven2 Repository</name>
     <url>http://scala-tools.org/repo-releases</url>
   </pluginRepository>
 </pluginRepositories>
 <dependencies>
   <dependency>
     <groupId>org.scala-lang</groupId>
     <artifactId>scala-library</artifactId>
     <version>${scala.version}</version>
   </dependency>
   <dependency>
     <groupId>junit</groupId>
     <artifactId>junit</artifactId>
     <version>4.4</version>
     <scope>test</scope>
   </dependency>
   <dependency>
     <groupId>org.specs</groupId>
     <artifactId>specs</artifactId>
     <version>1.2.5</version>
     <scope>test</scope>
   </dependency>
 </dependencies>
 <reporting>
   <plugins>
     <plugin>
       <groupId>org.scala-tools</groupId>
       <artifactId>maven-scala-plugin</artifactId>
       <configuration>
         <scalaVersion>${scala.version}</scalaVersion>
       </configuration>
     </plugin>
   </plugins>
 </reporting>
 <properties>
   <scala.version>2.7.6</scala.version>
 </properties>
</project>



best, tim


On Wed, Sep 16, 2009 at 11:49 PM, Josh Suereth <joshua.suereth@gmail.com> wrote:
> Oh, can I also see your pom?
>
> On Wed, Sep 16, 2009 at 11:47 AM, Josh Suereth <joshua.suereth@gmail.com>
> wrote:
>>
>> I highly doubt the nested projects is the problem as I use this style
>> setup everyday at work.  It's also how both maven plugins do eclipse
>> integration.
>>
>> I'm wondering if m2e is doing something strange.  Like I said, I have not
>> used m2e for a long time.
>>
>> - Josh
>>
>> On Wed, Sep 16, 2009 at 9:38 AM, Miles Sabin <miles@milessabin.com> wrote:
>>>
>>> On Mon, Sep 14, 2009 at 7:48 PM, tim tim
>>> <timbaermannextra@googlemail.com> wrote:
>>> > The problem is that errors and warnings are only shown in the main
>>> > project and not the scala submodule / project. I attached a picture of
>>> > my
>>> > eclipse workspace - you can see: the red error markers are only
>>> > added to the project explorer view of the main project.
>>>
>>> From that screenshot it looks like you have two Eclipse projects
>>> nested one inside the other ... I'd be surprised if that worked
>>> correctly whether or not Scala was involved.
>>>
>>> I suggest rearranging things so that you have two non-nested top-level
>>> project and get back to me if that doesn't solve the problem.
>>>
>>> Cheers,
>>>
>>>
>>> Miles
>>>
>>> --
>>> Miles Sabin
>>> tel: +44 (0)7813 944 528
>>> skype:  milessabin
>>> http://www.chuusai.com/
>>> http://twitter.com/milessabin
>>
>
>

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland