如何通知 SBT 使用插件的特定 scala 版本? [英] How to inform SBT to consume specific scala version for plugins?

查看:21
本文介绍了如何通知 SBT 使用插件的特定 scala 版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我不知何故弄乱了我的全局 sbt 插件 (~/.sbt/plugins/build.sbt).Scala 2.9.1 似乎是 sbt 0.11.3 想要的版本,并且所有插件(sbt-gpg-plugin、sbt-idea-plugin)都是针对 2.9.1 发布的.

Now I somehow messed up my global sbt plugins (~/.sbt/plugins/build.sbt). They were always fine retrieved against Scala 2.9.1 which seems to be the version that sbt 0.11.3 wants, and all the plugins (sbt-gpg-plugin, sbt-idea-plugin) are published against 2.9.1.

现在无论我做什么,它都会不断尝试找到它们是针对 2.9.2 构建的:

Now whatever I do, it persistently tries to find them built against 2.9.2:

[warn]  Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn]      com.github.mpeltonen:sbt-idea:1.0.0 (sbtVersion=0.11.3, scalaVersion=2.9.2)
[warn]      com.jsuereth:xsbt-gpg-plugin:0.6 (sbtVersion=0.11.3, scalaVersion=2.9.2)
...
[error] {file:...}default-50be6e/*:update: sbt.ResolveException: unresolved dependency: com.github.mpeltonen#sbt-idea;1.0.0: not found

我该如何解决这个问题,以便 sbt 像以前一样检索 Scala 2.9.1 的插件?

How can I fix this, so sbt retrieves the plugins for Scala 2.9.1 as before?

为了完整起见,我的文件是这样处理建议的:

For the sake of completeness, this is how my files look after the suggestions:

// project-home/build.sbt
scalaVersion := "2.9.2"
...

// project-home/project/plugins.sbt
resolvers += "less is" at "http://repo.lessis.me"

addSbtPlugin( "me.lessis" % "ls-sbt" % "0.1.1" )

scalaVersion := "2.9.1"  // "just in case it helps"

// ~/.sbt/plugins/build.sbt
scalaVersion := "2.9.1"  // "just in case it helps"

resolvers += "sbt-idea-repo" at "http://mpeltonen.github.com/maven/"

resolvers += Resolver.url( "sbt-plugin-releases", url( "http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases" ))( Resolver.ivyStylePatterns )

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.0.0")

addSbtPlugin( "com.jsuereth" % "xsbt-gpg-plugin" % "0.6" )

<小时>

更糟糕的是,即使在我 删除 ~/.sbt/plugins/build.sbt 之后,问题仍然存在.所以没有更多对 sbt-idea 或 xsbt-gpg-plugin 的引用(至少对我可见).我仍然无法编译任何项目,因为 sbt 仍然试图找到这两个插件.史诗般的失败.


What is even worse, the problem persists, even after I removed ~/.sbt/plugins/build.sbt. So there are no more references (at least visible to me) to either sbt-idea or xsbt-gpg-plugin. Still I cannot compile any project any more, because sbt still tries to find those two plugins. Epic fail.

推荐答案

您可以提供Scala版本的插件.我没有使用 ~/.sbt/,但我认为它也可以.

You could provide the Scala version of plugin. I didn't use ~/.sbt/, but I think it will works too.

以下是我的项目配置,使用 Scala 2.9.2 作为我的项目编译器,并使用了一些从 Scala 2.9.1 编译的插件.由于 Scala 2.9.1 和 Scala 2.9.2 是二进制兼容的,所以我还没有遇到任何问题.

The following is my project configuration using Scala 2.9.2 as my project compiler, and using some pluign that are compiled from Scala 2.9.1. Since Scala 2.9.1 and Scala 2.9.2 is binary compatible, I don't encounter any problem yet.

// MyProject/build.sbt

name := "MyProject"            

version := "0.1"            

scalaVersion := "2.9.2"     

以下是插件配置:

// File: MyProject/project/plugins.sbt

import sbt._

import Defaults._

resolvers += Resolver.url("sbt-plugin-releases",
  new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(
    Resolver.ivyStylePatterns)


// Resolved to: 
//
//  http://..../com.untyped/sbt-less/scala_2.9.1/sbt_0.11.3/0.4/jars/sbt-less.jar 
//
libraryDependencies += sbtPluginExtra(
    m = "com.untyped" % "sbt-less" % "0.4", // Plugin module name and version
    sbtV = "0.11.3",    // SBT version
    scalaV = "2.9.1"    // Scala version compiled the plugin
)

这篇关于如何通知 SBT 使用插件的特定 scala 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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