1

I tried to use the sbt-osgi plugin, but I can't load its AutoPlugin, the compiler refuses to compile my code.

First, I added the newest version of the plugin to project/plugins.sbt:

resolvers += Classpaths.sbtPluginSnapshots
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.8.0-SNAPSHOT")

After that, I set the sbt version in project/build.properties:

sbt.version=0.13.7

Then, I created project/Build.scala with the following contents:

import sbt._
import com.typesafe.sbt.osgi.SbtOsgi

object Build extends sbt.Build {
  lazy val fooProject = Project("foo-project", file("."))
    .enablePlugins(SbtOsgi)
}

But this results in the following error message:

[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

This error message doesn't make any sense, because AutoPlugin extends sbt.Plugins. What could be the problem?

kiritsuku
  • 52,967
  • 18
  • 114
  • 136

2 Answers2

1

The reason for the problem is, that the 0.8.0-SNAPSHOT version of the sbt-osgi plugin is broken:

% 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();
}

As one can see, it extends sbt.Plugin, but not the expected sbt.Plugins. The solution is to wait for an upstream fix.

kiritsuku
  • 52,967
  • 18
  • 114
  • 136
0

My response to sbt/sbt#1844

If I believe the timestamp on 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/ The snapshot has not been updated since 05-Jan-2014 22:07, which matches the date on sbt/sbt-osgi@c6dd29a. At the time auto plugin was not released yet.

Eugene Yokota
  • 94,654
  • 45
  • 215
  • 319