How to install scala sdk using gradle in Idea module?

My build.gradle file

idea { project { vcs { vcs = 'Git' } jdkName = '1.8' languageLevel = '1.8' } } 

I would also like to install the scala SDK in the module using gradle. Right now I have to manually install it from Project Structure in the Idea interface. Ideally, I would prefer to install it in the build.gradle file, so that at startup

gradle idea

scala SDK is automatically installed for this module

+5
source share
2 answers

From the Gradle documentation for the Scala plugin, you should add the Scala library dependency to the compilation class path. For instance:

 compile "org.scala-lang:scala-library:2.12.4" compile "org.scala-lang:scala-reflect:2.12.4" 

To integrate with IntelliJ IDEA you can use the idea plugin:

 apply plugin: 'idea' 

Adding a Scala library to the compilation class path is required even if your source code is only in test code. After that, IntelliJ will automatically install the Scala SDK for you.

0
source

To have a project with a Scala module in Intellij using Gradle,

  1. Create a new IDEA based scala project Scala on an IDEA based scala project enter image description here
  2. Give the appropriate name for the project and continue.
  3. Then, check if you are gradle in your local environment. (Install gradle using $sudo apt install gradle and then use the $which gradle to find the gradle location)
  4. Open your terminal and go to your project directory. Run the command $gradle init --type scala-library This will make your project based on gradle and you will see the related gradle files in Intellij.
  5. Restart Intellij and go to View > Tool Windows > Gradle to see the Gradle tab.
0
source

Source: https://habr.com/ru/post/1263121/


All Articles