如何通知 SBT 为插件使用特定的 Scala 版本?

编程入门 行业动态 更新时间:2024-10-27 04:33:37
本文介绍了如何通知 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 "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 "mpeltonen.github/maven/" resolvers += Resolver.url( "sbt-plugin-releases", url( "scalasbt.artifactoryonline/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("scalasbt.artifactoryonline/scalasbt/sbt-plugin-releases/"))( Resolver.ivyStylePatterns) // Resolved to: // // ..../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 版本?

本文发布于:2023-07-24 13:15:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1203668.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:插件   版本   通知   SBT   Scala

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!