Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

running the first example of playframework in IntelliJ on a Mac OSX

In my new mac OSX 10.8.3, I install scala 2.10.0, play 2.1.0 and IntelliJ12, and create a play project as follows:

#install brew
> ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
> brew --version
0.9.4

# update brew database
> cd $(brew --prefix)
> brew update
> cd $(brew --prefix) && git pull --rebase

# get scala 2.10.0
> brew versions scala
2.10.1   git checkout 79dc6f1 Library/Formula/scala.rb
2.10.0   git checkout 8ca07aa Library/Formula/scala.rb
2.9.2    git checkout 8896425 Library/Formula/scala.rb
...

> git checkout 8ca07aa Library/Formula/scala.rb   # 2.10.0
> brew install scala
> scala -version
Scala code runner version 2.10.0 -- Copyright 2002-2012, LAMP/EPFL


# install play 2.1.0
> brew versions play
2.1.0    git checkout 6a70797 Library/Formula/play.rb
...

> brew install play
> play -version
play! 2.1.0 (using Java 1.6.0_43 and Scala 2.10.0), http://www.playframework.org

and I create a play application:

> cd ~/
> play new myapp
name: myapp
Create a simple Scala application

# generate IntelliJ project:
> cd myapp
> play
> idea
[info] Created /Users/david/myapp/.idea_modules/myapp.iml
[info] Created /Users/david/myapp/.idea_modules/myapp-build.iml

and open the project in IntelliJ:

# Install IntelliJ 12 Ultimate Edition
Download it from http://www.jetbrains.com/idea/
12.0.4, Build #IU-123.169
Build on February 13, 2013

# install scala plugin in IntelliJ
run IntelliJ,
Preferences -> plugins -> Browse from repositories -> add scala.
current version: 0.7.134

# open myapp project in IntelliJ
File -> Open Project, chose the directory /Users/david/myapp

Then when I try to run the unit test:

Project -> myapp -> test -> ApplicationSpec -> (right click) -> Run

I get this error:

scala: Сompiler library for module bigbrother not found: Right(Project) / Right(scala-2.10.0) 

Actually, there are several errors:

in File -> Project Structure -> Modules, there are two modules:
-myapp
-mypp-build

File -> Project Structure -> Modules -> myapp -> Scala
   Compiler library: scala-2.10.0 [not found]
   <<< ERROR

File -> Project Structure -> Modules -> myapp-build -> Dependencies:
   scala-2.9.2
   <<< ERROR

If I correct the first error as follows,

File -> Project Structure -> Modules -> myapp -> Scala -> Compiler library
and from the dropdown list I select the second valid option “scala-2.10.0 (version 2.10.0)”.

Then, re-running the test, produces the error:

scala: Output path /Users/david/bigbrother/project/target/scala_2.9.2 is shared between: Module 'bigbrother-build' production, Module 'bigbrother-build' tests
Currently external Scala compiler prohibits output path sharing.
Either disable the external build mode or configure separate output paths.
TIP: you can use Project Artifacts to combine compiled classes.

What do I need to do to make it work?


Update: solution based on the answers from Marius and alexwriteshere

generate IntelliJ project with

> cd myapp
> play
> idea no-sbt-build-module

(instead of just 'idea')

then, Project Settings -> Libraries Select "Scala 2.9.2" and click on "-" to remove it.

then, Project Settings -> Module -> my_app -> Scala -> Scala-compiler in this dropdown list, there is selected "Scala 2.10.0" written in red. move to the top of the list, and select "Scala 2.10.0 (version 2.10.0)" written in black/grey.


Note

sometimes (I don't know why) the choice "Scala 2.10.0 (version 2.10.0)" written in black/grey is not available in the dropdown list. a workaround that works for me to make it available is as follows: Project Settings -> Global Libraries -> + -> Java select these files scala-compiler.jar, scala-library.jar and scala-reflect.jar from this directory: /usr/local/Cellar/scala/2.10.0/libexec/lib/ select Ok. Give it the name "my scala 2.10.0 bundle".

then, go again to Project Settings -> Module -> my_app -> Scala -> Scala-compiler now you have both, the one you just created "my scala 2.10.0 bundle", and the standard one: "Scala 2.10.0 (version 2.10.0)" written in black/grey. select the standard one, and delete the global library you created.

I don't know why this happens, and I really don't want to spend more time finding this out. for the moment, this workaround works for me. but feel free to add a comment if you find out.

like image 471
David Portabella Avatar asked Apr 01 '13 20:04

David Portabella


People also ask

How to add Play plugin in IntelliJ?

In the Project tool window, in the project source root directory, select New | File to create the plugins. sbt file. Open the plugins. sbt file in the editor and add the Play 2 plugin.


2 Answers

This problems can be solved by generating the idea project with:

$ play  # start play from command line
[your-play-project] $ idea no-sbt-build-module

This will enable IntelliJ's default building mechanism for Scala, which won't cause these problems.

like image 192
Marius Danila Avatar answered Oct 24 '22 22:10

Marius Danila


Here's what helped me in the past with the same errors:

  1. Remove any Scala 2.9.2 dependencies
  2. Go to Project Structure -> Global libraries. Create a new one, called, say, scala-bundle. Add scala-compiler.jar, scala-library.jar, scala-reflect.jar for 2.10.
  3. Finally, go to Project Structure -> Modules -> myapp -> Scala and select scala-bundle.

For module sharing errors, go to Project Structure -> Modules -> <each module> -> Paths and change the paths so they're not the same.

like image 32
Alex Yarmula Avatar answered Oct 24 '22 22:10

Alex Yarmula