2012-03-31 40 views

Trả lời

6

Plugin Scala đi kèm với Gradle không có hỗ trợ REPL tại thời điểm này. Tuy nhiên, điều này có thể thay đổi ngay khi chúng tôi hiện đang đầu tư vào việc cải thiện hỗ trợ Scala của chúng tôi. Hãy cho chúng tôi biết về mong muốn của bạn tại http://forums.gradle.org.

+0

Xong: http://forums.gradle.org/gradle/topics/running_the_scala_repl_from_gradle. Cảm ơn đã phản ứng kịp thời. –

2

Dưới đây là một cách để khởi chạy Scala REPL cho một dự án Gradle: Cho Gradle biên dịch và xuất ra đường dẫn lớp và khởi chạy REPL tách biệt với một kịch bản lệnh shell.

build.gradle

project(':repl') { 

    def scalaVersion = '2.11.7' 

    // Require the scala-compiler jar 
    buildscript { 
     dependencies { 
      classpath "org.scala-lang:scala-compiler:${scalaVersion}" 
     } 
     repositories { 
      mavenCentral() 
     } 
    } 

    // The path of the scala-compiler jar 
    def scalaPath = buildscript.configurations.classpath.find { 
     it.name == "scala-compiler-${scalaVersion}.jar" 
    } 

    // The classpath of this project and its dependencies 
    def classpath = sourceSets.main.runtimeClasspath.asPath 

    // Prints the classpath needed to launch the REPL 
    task printClasspath << { 
     println "${scalaPath}:${classpath}" 
    } 

} 

repl.sh

#!/bin/bash 
gradle :repl:compileScala && \ 
java -Dscala.usejavacp=true \ 
    -classpath "$(gradle :repl:printClasspath --quiet)" \ 
    scala.tools.nsc.MainGenericRunner 

tin chi tiết về blog post tôi.

Các vấn đề liên quan