【问题标题】:How to deal with library eviction when writing sbt plugin?编写 sbt 插件时如何处理库驱逐?
【发布时间】:2016-09-06 21:08:31
【问题描述】:

我尝试编写一个使用jsch 的简单sbt 插件。由于安全原因 (ecdsa),我的要求是在 0.1.53 中使用 jsch。我已经在 build.sbt 文件中声明了依赖项:

libraryDependencies += "com.jcraft" % "jsch" % "0.1.53"

不幸的是,org.scala-sbt:ivy 2.3.0 引入了对 0.1.46 的依赖。 SBT 说旧版本被驱逐,但在运行时使用我的插件时,我可以看到它仍在针对 0.1.46 jsch 运行。

[info]  com.jcraft:jsch
[info]      - 0.1.46
[info]          status: release
[info]          publicationDate: Thu Feb 02 13:39:27 CET 2012
[info]          resolver: sbt-chain
[info]          artifactResolver: sbt-chain
[info]          evicted: true
[info]          evictedData: latest-revision
[info]          homepage: http://www.jcraft.com/jsch/
[info]          isDefault: false
[info]          configurations: default, compile, runtime, default(compile), master
[info]          licenses: (Revised BSD,Some(http://www.jcraft.com/jsch/LICENSE.txt))
[info]          callers: org.scala-sbt:ivy:0.13.11
[info]      - 0.1.53
[info]          status: release
[info]          publicationDate: Fri Jun 05 17:32:00 CEST 2015
[info]          resolver: sbt-chain
[info]          artifactResolver: sbt-chain
[info]          evicted: false
[info]          homepage: http://www.jcraft.com/jsch/
[info]          isDefault: false
[info]          configurations: default, compile, runtime, default(compile), master
[info]          licenses: (Revised BSD,Some(http://www.jcraft.com/jsch/LICENSE.txt))
[info]          callers: com.evojam:sbt-ssh:0.1.1-SNAPSHOT (scalaVersion=2.10, sbtVersion=0.13), org.scala-sbt:ivy:0.13.11

我在 0.13.11 版本中使用 sbt。

我已将我的插件添加到测试项目中。运行我的 sbt 任务时,我收到明确的日志消息: [信息] 本地版本字符串:SSH-2.0-JSCH-0.1.46 以及一个关于不受支持的算法的错误,这使我得出结论,我的 jsch 版本已被某种方式覆盖。

问题是写sbt插件时如何处理库驱逐?

【问题讨论】:

    标签: scala sbt sbt-plugin


    【解决方案1】:

    也许你可以试试:

    dependencyOverrides += "com.jcraft" % "jsch" % "0.1.53"
    

    但我怀疑 jsch 的 sbt 版本是在你的插件之前加载到 jvm 类路径中的。

    更新到 ivy 2.4 存在 sbt 问题;这也将更新使用的 jsch 版本:https://github.com/sbt/sbt/issues/1920

    【讨论】:

    • 不幸的是,这不起作用。我很高兴看到 Ivy 2.4 更新了 jsch,尽管这可能需要一些时间。
    猜你喜欢
    • 2015-06-15
    • 2014-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-26
    • 2014-05-26
    • 2018-06-01
    • 2010-09-06
    相关资源
    最近更新 更多