在与 2.9 交叉构建的项目中使用仅限 2.10 的 SBT 插件 [英] Using a 2.10-only SBT plugin in a project that's cross-built against 2.9

查看:11
本文介绍了在与 2.9 交叉构建的项目中使用仅限 2.10 的 SBT 插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个针对 Scala 2.9.3 和 2.10.4 交叉构建的 SBT 0.13 项目.我只想为 2.10 构建使用 SBT 插件 (sbt-coveralls),因为该插件不适用于 2.9.

Suppose I've got a SBT 0.13 project that's cross-built against Scala 2.9.3 and 2.10.4. I want to use an SBT plugin (sbt-coveralls) for the 2.10 build only, because the plugin isn't available for 2.9.

我知道我可以使用 CrossVersion 有条件地将插件设置添加到 2.10 构建中,但这无助于 addSbtPlugin 不可用的事实查找 2.9 版本等的任何内容.

I know that I could use CrossVersion to conditionally add the plugin settings to the 2.10 build, but that doesn't help with the fact that addSbtPlugin isn't going to find anything for the 2.9 build, etc.

我假设这是不可能的(缺少一些非常混乱的临时 shell 脚本),但我不是 SBT 向导,如果能一次以一种好的方式对 SBT 的奥秘感到惊讶,那就太好了.

I'm assuming this is impossible (short of some really messy ad-hoc shell scripting) but I'm not an SBT wizard, and it would be nice to be surprised by the mysteries of SBT in a good way for once.

推荐答案

找到了这个可怕的解决方法,但它似乎确实有效:

Found this horrible hack of a workaround, but it does seem 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 )
}

这篇关于在与 2.9 交叉构建的项目中使用仅限 2.10 的 SBT 插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆