简体   繁体   中英

How do I run a scala application using gradle?

I added the scala plugin to gradle, but i don't how to run it. There's no run task when i create a scala project.

How do I run the scala project?

My gradle build script:

    apply plugin: 'idea'
    apply plugin: 'scala'
    repositories {
        mavenLocal()
        maven {
            url "http://maven.aliyun.com/nexus/content/groups/public/"
        }
        mavenCentral()
    }
    dependencies {
        compile group: 'org.scala-lang', name: 'scala-library', version: '2.13.1'
    }

You need to provide the classpath as well. Change run task declaration to:

task run(type: JavaExec, dependsOn: classes) {
   main = 'Demo'
   classpath = sourceSets.main.runtimeClasspath
}

And it will work fine. Demo .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM