【发布时间】:2014-09-14 21:23:27
【问题描述】:
我正在尝试使用新的AutoPlugin 功能创建一个 sbt 插件,但失败了。
所有代码都在这里:
build.sbt
sbtPlugin := true
name := "my-sbt-plugin"
version := "0.1.0"
organization := "test20140913"
project/MySbtPlugin.scala
import sbt._
object MySbtPlugin extends AutoPlugin {
object autoImport {
lazy val hello = taskKey[Unit]("hello task from my plugin")
}
import autoImport._
val helloSetting = hello := println("Hello from my plugin")
override def projectSettings = Seq(
helloSetting
)
}
project/build.scala
import sbt._
object MySbtPluginBuild extends Build {
lazy val root = project.in(file("."))
root.enablePlugins(MySbtPlugin)
}
当我在上面运行sbt时,它会报错:
[info] Done updating.
[info] Compiling 2 Scala sources to /myplugin/project/target/scala-2.10/sbt-0.13/classes...
/sbttest/myplugin/build.sbt:0: error: '.' expected but eof found.
import _root_.sbt.plugins.IvyPlugin, _root_.sbt.plugins.JvmPlugin, _root_.sbt.plugins.CorePlugin, _root_.sbt.plugins.JUnitXmlReportPlugin, MySbtPlugin
回购
你可以克隆它:https://github.com/freewind/my-sbt-plugin,然后运行./sbt来复制它
【问题讨论】:
-
请尝试 sbt0.13.6
-
它也有助于删除 build.sbt - 似乎是解析器/code_generator 的问题
-
用sbt0.13.6,错误消失了,但是我在其他项目还是不能使用这个插件