Coming Up for Air

A Quick-start for Scala and Gradle

Thursday, August 22, 2013 |

For those interested, here’s a quick and simple project to get you started using Gradle and Scala together:

build.gradle
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
apply plugin: 'scala'

repositories{
    mavenCentral()
    mavenLocal()
}

dependencies{
    compile 'org.slf4j:slf4j-api:1.7.5'
    compile "org.scala-lang:scala-library:2.10.1"
    testCompile "junit:junit:4.11"
}

task run(type: JavaExec, dependsOn: classes) {
    main = 'Main'
    classpath sourceSets.main.runtimeClasspath
    classpath configurations.runtime
}
src/main/scala/Main.scala
1
2
3
object Main extends App {
  println("Hello, world")
}

You can run the app using the custom task run:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
$ gradle run
:compileJava
:compileScala
:processResources
:classes
:run
Hello, world

BUILD SUCCESSFUL

Total time: 9.79 secs

Remember to add --daemon for faster startup times for your Gradle builds.

Have fun!

Search

    Quotes

    Sample quote

    Quote source

    About

    My name is Jason Lee. I am a software developer living in the middle of Oklahoma. I’ve been a professional developer since 1997, using a variety of languages, including Java, Javascript, PHP, Python, Delphi, and even a bit of C#. I currently work for Red Hat on the WildFly/EAP team, where, among other things, I maintain integrations for some MicroProfile specs, OpenTelemetry, Micrometer, Jakarta Faces, and Bean Validation. (Full resume here. LinkedIn profile)

    I am the president of the Oklahoma City JUG, and an occasional speaker at the JUG and a variety of technical conferences.

    On the personal side, I’m active in my church, and enjoy bass guitar, running, fishing, and a variety of martial arts. I’m also married to a beautiful woman, and have two boys, who, thankfully, look like their mother.

    My Links

    Publications