scala – 使用sbt构建命令行应用程序

任何人都成功跟随

http://www.scala-sbt.org/0.13/docs/Command-Line-Applications.html

使用最新的sbt 0.13.7?

对于0.12.0,我得到未解析的依赖“org.scala-sbt#command; 0.12.0:not found”.
尝试命令版本0.13.7会在initialGlobalLogging周围的Main.scala文件中收到编译错误:

[error] Unspecified value parameter console.                                       
[error]      GlobalLogging.initial(MainLogging.globalDefault _, File.crea          
teTempFile("hello", "log") )                                                       
[error]      GlobalLogging.initial(MainLogging.globalDefault _, File.crea          
teTempFile("hello", "log") )                                                       

谢谢

最佳答案 0.13.7似乎更新了GlobalLogging.initial()的参数类型和数量.

(
http://www.scala-sbt.org/0.13.7/api/#sbt.GlobalLogging $)

尝试更改Main.scala中的最后两行:

/** Configures logging to log to a temporary backing file as well as to the console. 
* An application would need to do more here to customize the logging level and
* provide access to the backing file (like sbt's last command and logLevel setting).*/
def initialGlobalLogging: GlobalLogging =
      GlobalLogging.initial(MainLogging.globalDefault _, File.createTempFile("hello", "log"))

val consoleOut = ConsoleOut.systemOut
def initialGlobalLogging: GlobalLogging =
   GlobalLogging.initial(MainLogging.globalDefault(consoleOut).apply, java.io.File.createTempFile("hello", "log"), consoleOut )
点赞