gpt4 book ai didi

sbt - 如何将 sbt 项目的测试范围工件添加到另一个测试类路径?

转载 作者:行者123 更新时间:2023-12-04 08:43:59 24 4
gpt4 key购买 nike

有两个 sbt 项目:commonprojectX .

项目commontest 中有一些依赖项我想在 test 上看到的范围projectX 中的类路径其中有 common作为依赖。

这是摘自 build.sbtprojectXtest->test配置映射如 Configurations 中所述:

libraryDependencies ++= Seq(
"org" %% "common" % "0.1" % "compile->compile;test->test"
)

执行后 test:compileprojectX出现以下错误:

[error] (*:update) sbt.ResolveException: unresolved dependency: org#common_2.10;0.1: configuration not public in org#common_2.10;0.1: 'test'. It was required from org#projectX_2.10;0.0.1-SNAPSHOT test



如何添加 test项目中的范围依赖项 commontest项目中的类路径 projectX ?

最佳答案

我以前从未见过错误,无法重现,但看起来测试工件没有publishLocal ed,因为它们不是默认的。

根据 Selecting default artifacts :

By default, the published artifacts are the main binary jar, a jar containing the main sources and resources, and a jar containing the API documentation. You can add artifacts for the test classes, sources, or API or you can disable some of the main artifacts.

To add all test artifacts:

publishArtifact in Test := true


这就是您发布 test 的人工制品时应该做的事情。配置。

将以下内容添加到 build.sbtcommon项目和 publishLocal它将测试打包并发布到本地 Ivy2 存储库:
publishArtifact in Test := true

进行更改后,您应该会在 publishLocal 的日志中看到以下内容- 注意与测试相关的工件:
> common/publishLocal
[info] Packaging /Users/jacek/sandbox/multi-module-test-scope-25003683/common/target/scala-2.10/common_2.10-0.1-sources.jar ...
[info] Packaging /Users/jacek/sandbox/multi-module-test-scope-25003683/common/target/scala-2.10/common_2.10-0.1-tests-sources.jar ...
[info] Done packaging.
[info] Done packaging.
[info] Updating {file:/Users/jacek/sandbox/multi-module-test-scope-25003683/}common...
[info] Wrote /Users/jacek/sandbox/multi-module-test-scope-25003683/common/target/scala-2.10/common_2.10-0.1.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] :: delivering :: org#common_2.10;0.1 :: 0.1 :: release :: Mon Jul 28 23:00:41 CEST 2014
[info] delivering ivy file to /Users/jacek/sandbox/multi-module-test-scope-25003683/common/target/scala-2.10/ivy-0.1.xml
[info] Packaging /Users/jacek/sandbox/multi-module-test-scope-25003683/common/target/scala-2.10/common_2.10-0.1-javadoc.jar ...
[info] Done packaging.
[info] Packaging /Users/jacek/sandbox/multi-module-test-scope-25003683/common/target/scala-2.10/common_2.10-0.1.jar ...
[info] Done packaging.
[info] Test Scala API documentation to /Users/jacek/sandbox/multi-module-test-scope-25003683/common/target/scala-2.10/test-api...
[info] Compiling 1 Scala source to /Users/jacek/sandbox/multi-module-test-scope-25003683/common/target/scala-2.10/test-classes...
model contains 2 documentable templates
[info] Test Scala API documentation successful.
[info] Packaging /Users/jacek/sandbox/multi-module-test-scope-25003683/common/target/scala-2.10/common_2.10-0.1-tests-javadoc.jar ...
[info] Done packaging.
[info] Packaging /Users/jacek/sandbox/multi-module-test-scope-25003683/common/target/scala-2.10/common_2.10-0.1-tests.jar ...
[info] Done packaging.
[info] published common_2.10 to /Users/jacek/.ivy2/local/org/common_2.10/0.1/docs/common_2.10-javadoc.jar
[info] published common_2.10 to /Users/jacek/.ivy2/local/org/common_2.10/0.1/srcs/common_2.10-tests-sources.jar
[info] published common_2.10 to /Users/jacek/.ivy2/local/org/common_2.10/0.1/jars/common_2.10-tests.jar
[info] published common_2.10 to /Users/jacek/.ivy2/local/org/common_2.10/0.1/jars/common_2.10.jar
[info] published common_2.10 to /Users/jacek/.ivy2/local/org/common_2.10/0.1/srcs/common_2.10-sources.jar
[info] published common_2.10 to /Users/jacek/.ivy2/local/org/common_2.10/0.1/poms/common_2.10.pom
[info] published common_2.10 to /Users/jacek/.ivy2/local/org/common_2.10/0.1/docs/common_2.10-tests-javadoc.jar
[info] published ivy to /Users/jacek/.ivy2/local/org/common_2.10/0.1/ivys/ivy.xml
[success] Total time: 2 s, completed Jul 28, 2014 11:00:43 PM

关于sbt - 如何将 sbt 项目的测试范围工件添加到另一个测试类路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25003683/

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