作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我没有找到在Linux中编译scala的好方法,所以我尝试了以下命令,
mkdir runnablescala
cd runnablescala
mkdir -p src/main/scala
mkdir -p src/main/resources
mkdir -p src/test/scala
mkdir -p src/test/resources
cd src/main/scala
mkdir -p com/johnathanmarksmith/gradle
vi com/johnathanmarksmith/gradle/HelloWorld.scala
package com.johnathanmarksmith.gradle;
object HelloWorld {
def main(args: Array[String]) {
println("Hello, world!")
}
}
cd ../../..
vi build.gradle
apply plugin: 'scala'
jar {
baseName = 'smith'
version = '1.0'
manifest {
attributes 'Main-Class': 'com.johnathanmarksmith.gradle.HelloWorld' }
}
gradle build
:compileJava UP-TO-DATE
:compileScala FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileScala'.
> 'compileScala.scalaClasspath' must not be empty
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
最佳答案
https://docs.gradle.org/current/userguide/scala_plugin.html:
Unless a task's scalaClasspath is configured explicitly, the Scala (base) plugin will try to infer it from the task's classpath. This is done as follows:
If a scala-library Jar is found on classpath, and the project has at least one repository declared, a corresponding scala-compiler repository dependency will be added to scalaClasspath.
Otherwise, execution of the task will fail with a message saying that scalaClasspath could not be inferred.
dependencies {
compile 'org.scala-lang:scala-library:2.11.7'
}
build.gradle
。如果要构建独立的jar,请参见
Building a uberjar with Gradle。
关于scala - 如何将Scala编译为可运行的jar文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33291506/
我是一名优秀的程序员,十分优秀!