我尝试使用sbt-osgi插件,但我无法加载其AutoPlugin
,编译器拒绝编译我的代码。
首先,我将最新版本的插件添加到project/plugins.sbt
:
resolvers += Classpaths.sbtPluginSnapshots
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.8.0-SNAPSHOT")
之后,我在project/build.properties
中设置了sbt版本:
sbt.version=0.13.7
然后,我使用以下内容创建了project/Build.scala
:
import sbt._
import com.typesafe.sbt.osgi.SbtOsgi
object Build extends sbt.Build {
lazy val fooProject = Project("foo-project", file("."))
.enablePlugins(SbtOsgi)
}
但是这会导致以下错误消息:
[info] Loading project definition from .../sbt-osgi-test/project
[info] Compiling 1 Scala source to .../sbt-osgi-test/project/target/scala-2.10/sbt-0.13/classes...
[error] .../sbt-osgi-test/project/Build.scala:10: type mismatch;
[error] found : com.typesafe.sbt.osgi.SbtOsgi.type
[error] required: sbt.Plugins
[error] .enablePlugins(SbtOsgi)
[error] ^
[error] one error found
[error] (compile:compile) Compilation failed
此错误消息没有任何意义,因为AutoPlugin
扩展了sbt.Plugins
。可能是什么问题?
答案 0 :(得分:1)
问题的原因是,sbt-osgi插件的0.8.0-SNAPSHOT版本被破坏了:
% javap -cp ~/.ivy2/cache/scala_2.10/sbt_0.13/com.typesafe.sbt/sbt-osgi/jars/sbt-osgi-0.8.0-SNAPSHOT.jar com.typesafe.sbt.osgi.SbtOsgi$
Compiled from "SbtOsgi.scala"
public final class com.typesafe.sbt.osgi.SbtOsgi$ implements sbt.Plugin {
public static final com.typesafe.sbt.osgi.SbtOsgi$ MODULE$;
public static {};
public scala.collection.Seq<sbt.Init<sbt.Scope>.Setting<?>> settings();
public scala.collection.Seq<sbt.Init<sbt.Scope>.Setting<?>> projectSettings();
public scala.collection.Seq<sbt.Init<sbt.Scope>.Setting<?>> buildSettings();
public scala.collection.Seq<sbt.Init<sbt.Scope>.Setting<?>> globalSettings();
public com.typesafe.sbt.osgi.OsgiKeys$ OsgiKeys();
public scala.collection.Seq<sbt.Init<sbt.Scope>.Setting<?>> osgiSettings();
public scala.collection.Seq<sbt.Init<sbt.Scope>.Setting<?>> defaultOsgiSettings();
}
可以看出,它扩展了sbt.Plugin
,但不是预期的sbt.Plugins
。解决方案是等待上游修复。
答案 1 :(得分:0)
我对sbt/sbt#1844的回复
如果我认为https://repo.scala-sbt.org/scalasbt/sbt-plugin-snapshots/com.typesafe.sbt/sbt-osgi/scala_2.10/sbt_0.13/0.8.0-SNAPSHOT/jars/上的时间戳自2014年1月5日22:07以来未更新快照,则与sbt / sbt-osgi @ c6dd29a上的日期相匹配。当时自动插件尚未发布。