有没有从gradle任务调用scala REPL的标准方法?有没有插件?我没有找到一个。我可以仿效这一做法,但似乎有点过时了,我想知道是否有更好的办法:从gradle运行scala REPL?
http://gradle.1045684.n5.nabble.com/Reading-keyboard-input-td3073108.html
谢谢。
有没有从gradle任务调用scala REPL的标准方法?有没有插件?我没有找到一个。我可以仿效这一做法,但似乎有点过时了,我想知道是否有更好的办法:从gradle运行scala REPL?
http://gradle.1045684.n5.nabble.com/Reading-keyboard-input-td3073108.html
谢谢。
与Gradle捆绑在一起的Scala插件目前没有REPL支持。然而,这可能会很快改变,因为我们目前正在投资改善我们的Scala支持。让我们在http://forums.gradle.org处了解您的愿望。
以下是启动Gradle项目的Scala REPL的一种方法:让Gradle编译并输出类路径,并从shell脚本单独启动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
更多细节。
完成:http://forums.gradle.org/gradle/topics/running_the_scala_repl_from_gradle。感谢您的及时回应。 – 2012-04-01 00:50:57