2012-03-31 15 views
5

gradleタスクからスカラREPLを呼び出す標準的な方法はありますか?これのためのプラグインはありますか?私は1つを発見していない。私は、この例に従うことができるが、それは少し時代遅れようだと私はより良い方法があるかどうかを知りたいと思った: gradleからスカラREPLを実行していますか?

http://gradle.1045684.n5.nabble.com/Reading-keyboard-input-td3073108.html

はありがとうございます。

答えて

6

現在、GradleにバンドルされているScalaプラグインには、REPLサポートがありません。しかし、Scalaサポートの改善に現在投資しているので、これはすぐに変わる可能性があります。 http://forums.gradle.orgにあなたの希望についてお知らせください。

+0

完了:http://forums.gradle.org/gradle/topics/running_the_scala_repl_from_gradle。迅速な対応に感謝します。 –

2

GradleプロジェクトでScala REPLを起動する方法の1つは、Gradleにクラスパスをコンパイルして出力させ、REPLをシェルスクリプトとは別に起動させることです。

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私blog post

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

詳細。

関連する問題