Issues with IntelliJ support for Scalatra

466 views
Skip to first unread message

Ebot Tabi

unread,
May 9, 2013, 6:49:58 AM5/9/13
to scalat...@googlegroups.com
Hi there
i am new to scalatra, recently i had scalatra setup successfully on my system, and i added the plugin for IntelliJ and did the build with sbt but when i load the project on IntelliJ via importing it, i get errors on scalatra package imports. I will be grateful for advice and help.

Ebot

Ali Makki

unread,
May 9, 2013, 8:09:59 AM5/9/13
to scalat...@googlegroups.com
Perhaps you haven't added the scalatra libraries to your project's classpath, hence the errors.

Check out the gen-idea plugin for sbt, which generates intellij project files for you https://github.com/mpeltonen/sbt-idea

Once you have it configured in sbt all you do is run: sbt gen-idea; idea projects are generated for you and all dependencies listed in your build file will be set up in intellij.

Good luck!

Ebot Tabi

unread,
May 9, 2013, 8:58:38 AM5/9/13
to scalat...@googlegroups.com
Hi Ali
i added the sbt-idea on the plugin.sbt file and did the sbt gen-idea and still came up with the errors.

Ali Makki

unread,
May 10, 2013, 3:30:40 AM5/10/13
to scalat...@googlegroups.com
Hello Ebot

Did itellij prompt you to restart your IDE after running gen-idea? 

The location of the idea project file should be in the same directory where your scalatra project is setup.

Ali

Sam Mueller

unread,
May 10, 2013, 7:58:31 AM5/10/13
to scalat...@googlegroups.com
Hello,

I'm also having trouble getting started with scalatra and intellij.  I'm coming from the microsoft world of .NET, and making the jump to scala has been challenging.  I feel like I could start learning much more quickly if I managed to setup the IDE as lean as possible, so I don't get confused with extraneous libraries and/or concepts until I'm ready for them. This is what I've accomplished so far:

  1. Install Xcode - Developer Tools from the app store
    1. Open Xcode, agree to terms, and install Command Line Tools in Preferences -> Downloads
  2. Install homebrew, then use it to install scala
    1. open terminal, run the following command:
    2. ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
    3. type the follow commands:
      brew doctor (this ensures homebrew is setup correctly)
      brew install scala (this will install scala to /usr/local/Cellar/scala/2.10.1)
  3. Install Java JDK 7
    1. http://www.oracle.com/technetwork/java/javase/downloads/index.html
  4. Install Intellij IDEA Ultimate
    1. Go to http://www.jetbrains.com/idea/download/
    2. For a lean installation:
      disable all VCS integration plugins except for: Git
      disable all Web/JavaEE Tech plugins 
      disable all HTML/Javascript Plugins except for: CSS, HTML Tools, Inspection-JS, JavaScript Debugger, JavaScript Intention Power Pack, JavaScript, LESS, SASS
      disable Other plugins except for: CoffeeScript, Github
  5. Install the IntelliJ Scala plugin
    1. Open Intellij, and go to Configure -> Plugins -> Browse Repositories
    2. Choose the Scala plugin, hit ok and restart the application
  6. Create new scala project
    1. Select “Scala Module”
    2. Give it a name and location
    3. Under project SDK, if <None> is selected, go to New... and choose folder /Library/Java/JavaVirtualMachines/jdk1.7.0.jdk
    4. Set Scala Home to /usr/local/Cellar/scala/2.10.1/libexec
This has gotten me to a point where i can add classes and objects to the project, and compile/run code successfully.  But how do I now take this project and get scalatra integrated?  Do I still use giter8 to generate scalatra?  How would that be injected into my project?  The tutorials I've seen have been written before IntelliJ started using SBT as an external compiler, so I'm not sure which portions of the giter8 template is redundant to the intellij scala project i've already setup.  Also, where exactly does the gen-idea plugin come in?  There really isn't that much explanation on github as to what it does or how it helps.

--Sam

Stefan Ollinger

unread,
May 10, 2013, 8:13:07 AM5/10/13
to scalat...@googlegroups.com
Hi Sam,

I usually create a SBT project first using g8 and a text editor.
The gen-idea SBT task is implemented in this SBT plugin: https://github.com/mpeltonen/sbt-idea
You can add it to the global SBT config. This will add the plugin to every SBT project configuration.
After that you can create the IDEA project configuration files with gen-idea and open the project in IDEA.
There is currently a discussion about text editors/IDEs on the scala-user mailing list, maybe this is interesting/helpful to you: https://groups.google.com/forum/?fromgroups=#!topic/scala-user/46kTWv0diVo

Regards,
Stefan


On 10.05.2013 13:58, Sam Mueller wrote:
Hello,

I'm also having trouble getting started with scalatra and intellij. �I'm coming from the microsoft world of .NET, and making the jump to scala has been challenging. �I feel like I could start learning much more quickly if I managed to setup the IDE as lean as possible, so I don't get confused with extraneous libraries and/or concepts until I'm ready for them. This is what I've accomplished so far:

    1. Install Xcode - Developer Tools from the app store
      1. Open Xcode, agree to terms, and install Command Line Tools in Preferences -> Downloads
    2. Install homebrew, then use it to install scala
      1. open terminal, run the following command:
      2. ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
      3. type the follow commands:
        brew doctor (this ensures homebrew is setup correctly)
        brew install scala (this will install scala to /usr/local/Cellar/scala/2.10.1)
    3. Install Java JDK 7
      1. http://www.oracle.com/technetwork/java/javase/downloads/index.html
    4. Install Intellij IDEA Ultimate
      1. For a lean installation:
        disable all VCS integration plugins except for: Git
      1. disable all Web/JavaEE Tech plugins�

      1. disable all HTML/Javascript Plugins except for: CSS, HTML Tools, Inspection-JS, JavaScript Debugger, JavaScript Intention Power Pack, JavaScript, LESS, SASS
        disable Other plugins except for: CoffeeScript, Github
    1. Install the IntelliJ Scala plugin
      1. Open Intellij, and go to Configure -> Plugins -> Browse Repositories
      2. Choose the Scala plugin, hit ok and restart the application
    2. Create new scala project
      1. Select �Scala Module�
      1. Give it a name and location
      2. Under project SDK, if <None> is selected, go to New... and choose folder /Library/Java/JavaVirtualMachines/jdk1.7.0.jdk
      3. Set Scala Home to /usr/local/Cellar/scala/2.10.1/libexec
      This has gotten me to a point where i can add classes and objects to the project, and compile/run code successfully. �But how do I now take this project and get scalatra integrated? �Do I still use giter8 to generate scalatra? �How would that be injected into my project? �The tutorials I've seen have been written before IntelliJ started using SBT as an external compiler, so I'm not sure which portions of the giter8 template is redundant to the intellij scala project i've already setup. �Also, where exactly does the gen-idea plugin come in? �There really isn't that much explanation on github as to what it does or how it helps.

      --Sam


      On Friday, May 10, 2013 3:30:40 AM UTC-4, Ali Makki wrote:
      Hello Ebot

      Did itellij prompt you to restart your IDE after running gen-idea?�

      The location of the idea project file should be in the same directory where your scalatra project is setup.

      Ali

      On Thursday, May 9, 2013 4:58:38 PM UTC+4, Ebot Tabi wrote:
      Hi Ali
      i added the sbt-idea on the plugin.sbt file and did the sbt gen-idea and still came up with the errors.

      On Thursday, May 9, 2013 1:09:59 PM UTC+1, Ali Makki wrote:
      Perhaps you haven't added the scalatra libraries to your project's classpath, hence the errors.

      Check out the gen-idea plugin for sbt, which generates intellij project files for you�https://github.com/mpeltonen/sbt-idea

      Once you have it configured in sbt all you do is run: sbt gen-idea; idea projects are generated for you and all dependencies listed in your build file will be set up in intellij.

      Good luck!

      On Thursday, May 9, 2013 2:49:58 PM UTC+4, Ebot Tabi wrote:
      Hi there
      i am new to scalatra, recently i had scalatra setup successfully on my system, and i added the plugin for IntelliJ and did the build with sbt but when i load the project on IntelliJ via importing it, i get errors on scalatra package imports. I will be grateful for advice and help.

      Ebot
      --
      You received this message because you are subscribed to the Google Groups "scalatra-user" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to scalatra-use...@googlegroups.com.
      For more options, visit https://groups.google.com/groups/opt_out.
      �
      �

      Sam Mueller

      unread,
      May 10, 2013, 3:54:52 PM5/10/13
      to scalat...@googlegroups.com
      Thanks for the quick reply, Stefan.  I did as you recommended, and now I've opened the project inside of Intellij.  This may be a more of an intellij question, but I'm not sure how to get the project to run; I've built the code successfully, but I get nothing when navigating to localhost:8080.

      Stefan Ollinger

      unread,
      May 10, 2013, 4:21:40 PM5/10/13
      to scalat...@googlegroups.com
      I would suggest to use SBT to run Jetty. Either you can use the SBT console in IDEA or run SBT in terminal.
      So IDEA is mainly used for code completion, navigation and debugging.

      Also take a look at JRebel, which allows to reload .class files without restarting Jetty. They have free licenses for Scala projects.

      Regards,
      Stefan
      Reply all
      Reply to author
      Forward
      0 new messages