有没有一种标准的方法可以从gradle任务中调用scala REPL?是否有相应的插件可用?我还没有找到这样的插件。我可以按照这个例子来操作,但是它似乎有点过时了,我想知道是否有更好的方法:
http://gradle.1045684.n5.nabble.com/Reading-keyboard-input-td3073108.html
谢谢。
有没有一种标准的方法可以从gradle任务中调用scala REPL?是否有相应的插件可用?我还没有找到这样的插件。我可以按照这个例子来操作,但是它似乎有点过时了,我想知道是否有更好的方法:
http://gradle.1045684.n5.nabble.com/Reading-keyboard-input-td3073108.html
谢谢。
目前Gradle捆绑的Scala插件不支持REPL。但是,我们正在投资改进Scala支持,这可能很快会有所改变。请在http://forums.gradle.org告诉我们您的愿望。
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
更多详细信息请查看我的博客文章。