Setting up scala with IntelliJ

前端 未结 7 593
萌比男神i
萌比男神i 2020-12-04 06:37

I have Intellij ultimate 11.1, with the scala plugin installed.

I installed scala 2.9.2 using homebrew, which put scala in:

/usr/local/Cellar/scala/2         


        
相关标签:
7条回答
  • 2020-12-04 07:13

    The latest Brew has already realized this problem and created automatic symlinks upon installing Scala.

    Firstly, install Scala with Documentation

    brew install scala --with-docs
    

    Secondly, provide the following path in IntelliJ

    /usr/local/opt/scala/idea
    
    0 讨论(0)
  • 2020-12-04 07:21

    Updated for Intellij 11.1.5

    Here's a step by step for any of those who are trying to get Scala in IntelliJ up and running.

    Download Scala Plugin

    IntelliJ > Preferences > Plugins > Browse Repositories... > Scala Click Ok and allow IntelliJ to restart

    Download Scala

    In Terminal enter

    brew install scala --with-docs
    

    Setup symbolic links for IntelliJ discovery process

    ln -s /usr/local/Cellar/scala/<version>/libexec/src /usr/local/Cellar/scala/<version>/src
    ln -s /usr/local/Cellar/scala/<version>/libexec/lib /usr/local/Cellar/scala/<version>/lib
    mkdir -p /usr/local/Cellar/scala/<version>/doc/scala-devel-docs
    ln -s /usr/local/Cellar/scala/<version>/share/doc/scala /usr/local/Cellar/scala/<version>/doc/scala-devel-docs/api
    

    Create Project in IntelliJ

    Here you are going to create a Java project from scratch as you normally would. However, in the last step, you will select Scala in the "Technologies" page.

    In the Use Scala Distribution enter /usr/local/Cellar/scala/<version>

    In the Compiler dropdown select scala-compiler

    Click Ok and you are ready to create your first Scala object

    For reference -> http://scalacookbook.blogspot.com/2012/09/scala-for-intellij.html

    0 讨论(0)
  • 2020-12-04 07:21

    Rather than downloading the docs separately you can use the --with-docs option when installing scala with homebrew:

    brew install scala --with-docs
    

    Then in IntelliJ point your JavaDocs path in the scala-library to /usr/local/Cellar/scala/2.9.2/share/doc.

    0 讨论(0)
  • 2020-12-04 07:21

    I'm just found another way to configure scala with intelJIdea. If scala installed with brew then just write in terminal:

    brew info scala
    

    you will see smth like that:

    scala: stable 2.11.4 (bottled)
    http://www.scala-lang.org/
    /usr/local/Cellar/scala/2.11.4 (3401 files, 433M) *
      Built from source with: --with-docs
    From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/scala.rb
    ==> Options
    --with-docs
        Also install library documentation
    --with-src
        Also install sources for IDE support
    ==> Caveats
    To use with IntelliJ, set the Scala home to:
      /usr/local/opt/scala/idea
    
    Bash completion has been installed to:
      /usr/local/etc/bash_completion.d
    

    Then just include /usr/local/opt/scala/idea into your idea config panel.

    0 讨论(0)
  • 2020-12-04 07:22

    I am using Yosemite, and the following worked for me.

    brew install scala --with-docs
    

    Then I tested IntelliJ by creating a new project, using the Java SDK, and for compiler putting in:

    /usr/local/Cellar/scala/[insertversion]/libexec
    

    Here is what I see in IntelliJ when I created a new project with these settings

    I tested compiling a Hello World program via this and it compiled correctly to the console.

    Note, I ignored what @Zagorulkin said above even though it seems logical that if Homebrew is saying so my compile path should be different to the above.

    0 讨论(0)
  • 2020-12-04 07:22

    Change /usr/local/Cellar/scala/2.9.2 to /usr/local/Cellar/scala/ and you are good to go.

    0 讨论(0)
提交回复
热议问题