gpt4 book ai didi

未找到 scalacheck/scalatest : how to add it in sbt/scala?

转载 作者:行者123 更新时间:2023-12-04 16:54:45 24 4
gpt4 key购买 nike

我已经从 http://typesafe.com/stack/download 安装了 typesafe-stack在我的 ubuntu12 上,我创建了一个播放项目(g8 typesafehub/play-scala),现在我想将 scalatest 或 scalacheck 添加到我的项目中。

所以 my_app/project/plugins.sbt 有以下几行:

// The Typesafe repository 
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.0.1")

然后我使用 addSbtPlugin 添加了 scalatest:
addSbtPlugin("org.scalatest" %% "scalatest" % "2.0.M1" % "test")

现在当我运行“sbt test”时它失败并显示以下消息
[info] Resolving org.scalatest#scalatest;2.0.M1 ...
[warn] module not found: org.scalatest#scalatest;2.0.M1
[warn] ==== typesafe-ivy-releases: tried
[warn] http://repo.typesafe.com/typesafe/ivy-releases/org.scalatest/scalatest/scala_2.9.1/sbt_0.11.3/2.0.M1/ivys/ivy.xml
[warn] ==== local: tried
[warn] ~/.ivy2/local/org.scalatest/scalatest/scala_2.9.1/sbt_0.11.3/2.0.M1/ivys/ivy.xml
[warn] ==== Typesafe repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/org/scalatest/scalatest_2.9.1_0.11.3/2.0.M1/scalatest-2.0.M1.pom
[warn] ==== typesafe-ivy-releases: tried
[warn] http://repo.typesafe.com/typesafe/ivy- releases/org.scalatest/scalatest/scala_2.9.1/sbt_0.11.3/2.0.M1/ivys/ivy.xml
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/org/scalatest/scalatest_2.9.1_0.11.3/2.0.M1/scalatest-2.0.M1.pom

我不明白的是:为什么它使用这个 http://repo.typesafe.com/typesafe/releases/org/scalatest/scalatest_2.9.1_0.11.3/2.0.M1/scalatest-2.0.M1.pom URL 而不是真实的 http://repo.typesafe.com/typesafe/releases/org/scalatest/scalatest_2.9.1/2.0.M1/scalatest_2.9.1-2.0.M1.pom ?

我在使用 scalacheck 时遇到了完全相同的问题:它还尝试使用特定于 sbt 版本的 artifactId 进行下载,而存储库只有特定于 scala 版本的。

我究竟做错了什么?我知道在 sbt 某处必须有一个开关,而不是使用 sbt-version 作为工件 URL 的一部分?

我也尝试在我的 plugins.sbt 中使用它
libraryDependencies += "org.scalatest" %% "scalatest" % "2.0.M1" % "test"

但看起来它被 sbt 完全忽略了,并且 scalatest.jar 没有出现在类路径中:
my_app/test/AppTest.scala:1: object scalatest is not a member of package org
[error] import org.scalatest.FunSuite

因为 sbt clean && sbt test 的输出有很多
解决 org.easytesting#fest-util;1.1.6 或只是另一个库,但与 Scalatest 无关。

我使用scala 2.9.1和sbt 0.11.3,尝试使用scalatest 2.0.M1和1.8;标量检查:
resolvers ++= Seq(
"snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
"releases" at "http://oss.sonatype.org/content/repositories/releases"
)

libraryDependencies ++= Seq(
"org.scalacheck" %% "scalacheck" % "1.9" % "test"
)

具有相同的结果,即它使用不存在的 sbtVersion 特定 POM URL。

我究竟做错了什么?谢谢。

最佳答案

Scalatest 不是构建插件,而是测试库。你应该像这样添加它:

libraryDependencies += "org.scalatest" %% "scalatest" % "2.0.M1" % "test"

你应该把它添加到 build.sbt在项目的基本目录(您称为“my_app”),而不是 project/plugins.sbt .

它的原因 0.11.3在它尝试查找的 URL 中是因为构建插件与您使用的 SBT 版本相关联。

关于未找到 scalacheck/scalatest : how to add it in sbt/scala?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10842966/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com