Scala Language Working With Gradle Basic Setup


Example

  1. Create a file named SCALA_PROJECT/build.gradle with these contents:

    group 'scala_gradle'
    version '1.0-SNAPSHOT'
    
    apply plugin: 'scala'
    
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url "https://repo.typesafe.com/typesafe/maven-releases"
        }
    }
    
    dependencies {
        compile group: 'org.scala-lang', name: 'scala-library', version: '2.10.6'
    }
    
    
    task  "create-dirs" << {
        sourceSets*.scala.srcDirs*.each { it.mkdirs() }
        sourceSets*.resources.srcDirs*.each { it.mkdirs() }
    }
    
    
  2. Run gradle tasks to see available tasks.

  3. Run gradle create-dirs to create a src/scala, src/resources directory.

  4. Run gradle build to build the project and download dependencies.