Easy Way
-
Create a directory (e.g.,
demo_proj
) for your project. -
Run
gradle init --type scala-library
in terminal in the above directory. -
Import the directory as a Gradle project in IntelliJ IDEA. Alternatively, you can add
apply plugin: 'idea'
intobuild.gradle
and then run the command./gradlew openIdea
to import the directory as a Gradle project in Intellij IDEA.
Hard Way
-
Create a Gradle project in IntelliJ IDEA.
-
Create a directory named
scala
undersrc/main
. -
Mark the directory
src/main/scala
as source root directory. -
Open
build.gradle
and change its content to the following.plugins { id 'scala' } apply plugin: 'idea' group 'net.legendu' version '1.0-SNAPSHOT' sourceCompatibility = 1.8 dependencies { // Use Scala 2.12 in our library project implementation 'org.scala-lang:scala-library:2.12.7' // Use Scalatest for testing our library testImplementation 'junit:junit:4.12' testImplementation 'org.scalatest:scalatest_2.12:3.0.5' // Need scala-xml at test runtime testRuntimeOnly 'org.scala-lang.modules:scala-xml_2.12:1.1.1' }