Easy Way
-
Create a directory (e.g.,
demo_proj) for your project. -
Run
gradle init --type scala-libraryin terminal in the above directory. -
Import the directory as a Gradle project in IntelliJ IDEA. Alternatively, you can add
apply plugin: 'idea'intobuild.gradleand then run the command./gradlew openIdeato import the directory as a Gradle project in Intellij IDEA.
Hard Way
-
Create a Gradle project in IntelliJ IDEA.
-
Create a directory named
scalaundersrc/main. -
Mark the directory
src/main/scalaas source root directory. -
Open
build.gradleand 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' }