首页  

sbt自定义任务     所属分类 sbt 浏览量 192
val scalaVersion = settingKey[String]("The version of Scala used for building.")
val clean = taskKey[Unit]("Deletes files produced by the build, such as generated sources, compiled classes, and task caches.")

sbt scalaVersion
sbt about


以下代码 放到 build.sbt 最后

val helloStringTask = taskKey[String]("hello string task demo")
helloStringTask := {
  Thread.sleep(2000)
  val str = helloStringTask+",helloStringTask,"+new java.util.Date()
  println(str)
  str
}

注释 使用 // 

sbt helloStringTask


[info] welcome to sbt 1.5.2 (Oracle Corporation Java 1.8.0_321)
[info] loading global plugins from /Users/dugang/.sbt/1.0/plugins
[info] loading settings for project playdemo-build from plugins.sbt ...
[info] loading project definition from /Users/dugang/tmp/playdemo/project
[info] loading settings for project root from build.sbt ...
...
[info] Version 2.8.13 running Java 1.8.0_321

[info] 
TaskKey(This / This / This / helloStringTask),helloStringTask,Sun Feb 20 09:05:50 CST 2022
[success] Total time: 2 s, completed 2022-2-20 9:05:50


构建工具sbt 简介 maven 与 sbt 配置对比 maven 和 sbt 命令对比 sbt JVM 参数设置

上一篇     下一篇
scala Option Try Either

scala try future 例子

scala Play框架 依赖注入 guice 使用说明

scala shell 使用第三方jar包

sbt hello 例子

gradle入门