Using the 2.10-only SBT plugin in a project built against 2.9

Suppose I have a SBT 0.13 project built against Scala 2.9.3 and 2.10.4. I want to use the SBT plugin ( sbt-coveralls ) only for build 2.10, because the plugin is not available for 2.9.

I know that I could use CrossVersion to conditionally add plugin settings to assembly 2.10, but this does not help that addSbtPlugin will not find anything for assembly 2.9, etc.

I suppose this is not possible (with the exception of some really confusing command line scripts), but I'm not an SBT master, and it would be nice to be surprised at the SBT mysteries in a good way.

+2
source share
2 answers

Found this terrible hack workaround, but it seems to work:

 resolvers <++= scalaVersion { case v if v startsWith( "2.12" ) => Seq.empty case _ => addSbtPlugin( "org.scoverage" % "sbt-scoverage" % "1.0.4" ) addSbtPlugin( "org.scoverage" % "sbt-coveralls" % "1.0.0" ) Seq( Classpaths.sbtPluginReleases ) } 
+3
source

I might misunderstand the question, but I think you might be confused with sbt and Scala project versions.

You cannot use a plugin that is incompatible with sbt runtime. If the plugin does not support the version of Scala sbt uses under cover art, the plugin is considered incompatible and, therefore, sbt will refuse to run. sbt 0.13.5 uses 2.10.4, so plugins can only use Scala API 2.10.4. Therefore addSbtPlugin does not offer %% .

For projects, this is different. Here you can use any version you want, regardless of the version of sbt used and, therefore, of the plugins. Once you have created the addSbtPlugin 'plugin, the plugin available in the project and including it, add the settings to the projects.

+2
source

All Articles