Reputation: 645
My build.gradle file
idea {
project {
vcs {
vcs = 'Git'
}
jdkName = '1.8'
languageLevel = '1.8'
}
}
I would also like to set the scala SDK in the module using gradle. Right now, I end up having to manually set it from Project Structure in the Idea UI. Ideally, I would prefer to set it in my build.gradle file such that when I run
gradle idea
the scala SDK is automatically set for this module
Upvotes: 7
Views: 3481
Reputation: 556
To have a project with scala module in Intellij using gradle,
IDEA based scala project
$sudo apt install gradle
and then use command $which gradle
to find location of gradle)$gradle init --type scala-library
This will make your project gradle based and you'll see associated gradle files in Intellij. View > Tool Windows > Gradle
to see Gradle
tab.Upvotes: 3
Reputation: 4236
From the Gradle documentation for the Scala plugin, you must add the Scala library dependency to the compile class path. For example:
compile "org.scala-lang:scala-library:2.12.4"
compile "org.scala-lang:scala-reflect:2.12.4"
For integration with IntelliJ IDEA, you can apply the idea plugin:
apply plugin: 'idea'
Adding the Scala library to the compile class path is required even if your source is in test code only. After this, IntelliJ will automatically set up the Scala SDK for you.
Upvotes: 1