简体   繁体   English

获取当前的sbt插件的交叉版本

[英]Getting the current sbt plugin cross version

I'm trying to cross-build an sbt plugin between 0.13 and 1.1 . 我正在尝试在0.131.1之间交叉构建sbt插件。 To accomplish this I need to use different libraryDependencies for the different builds, but I can't find a way to access the current build's target sbt version. 为此,我需要对不同的构建使用不同的libraryDependencies ,但是我找不到找到当前构建的目标sbt版本的方法。

Back when the cross compilation was in a plugin there was CrossBuilding.pluginSbtVersion but I can't find anything similar anymore. 当交叉编译在插件中时,有CrossBuilding.pluginSbtVersion但是我找不到类似的东西了。

  • sbtVersion.value always gives me 0.13.16 sbtVersion.value总是给我0.13.16
  • (sbtVersion in sbtPlugin) likewise (sbtVersion in sbtPlugin)同样
  • crossVersion always gives me Binary crossVersion总是给我Binary
  • scalaBinaryVersion always gives me 2.10 scalaBinaryVersion总是给我2.10

How can I do this? 我怎样才能做到这一点?

you can use the following code: 您可以使用以下代码:

libraryDependencies ++= {
  sbtBinaryVersion.value match {
    case "0.13" => Seq(...)
    case "1.0" => Seq(...)
  }
}

make sure to run your sbt commands with ^ , to run command on all sbt versions, ie: 确保使用^运行sbt命令,以在所有sbt版本上运行命令,即:

sbt "^compile"

It turns out the solution was present in sbt's output all along: 事实证明,解决方案始终存在于sbt的输出中:

[info] Setting `sbtVersion in pluginCrossBuild` to 1.1.2

I just had to use (sbtBinaryVersion in pluginCrossBuild).value 我只需要使用(sbtBinaryVersion in pluginCrossBuild).value

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM