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

时间:2014-07-28 20:23:20

标签: sbt

有两个sbt项目:commonprojectX

项目commontest范围内有一些依赖项,我希望在test类{{}}}类路径中看到projectX作为依赖项common

这是build.sbtprojectX的{​​{1}}摘录,test->test配置为libraryDependencies ++= Seq( "org" %% "common" % "0.1" % "compile->compile;test->test" )

test:compile

projectX中执行test后,会出现以下错误:

  

[error](*:update)sbt.ResolveException:未解析的依赖项:   org#common_2.10; 0.1:org中的公共配置#common_2.10; 0.1:   '测试'。它来自org#projectX_2.10; 0.0.1-SNAPSHOT test

如何将项目common中的test范围的依赖项添加到项目projectX中的{{1}}类路径?

2 个答案:

答案 0 :(得分:3)

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

根据Selecting default artifacts

  

默认情况下,发布的工件是主要的二进制jar,一个jar   包含主要资源和资源,以及包含该资源的jar   API文档。您可以为测试类添加工件,   来源或API或您可以禁用一些主要工件。

     

添加所有测试工件:

publishArtifact in Test := true

这就是你发布test配置的艺术品所应该做的。

将以下内容添加到build.sbt项目的commonpublishLocal以将测试打包并发布到本地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

答案 1 :(得分:0)

通过从Maven风格切换到Ivy风格的发布和解析(Ivy文件而不是pom文件和常春藤风格的存储库),我已成功解决了没有 publishLocal这个问题。顺便说一句,如果您使用Nexus代理,建议在Nexus中将Maven repos和Ivy repos(以及Maven组和Ivy组)完全分开。

那就是说,我不知道你为什么遇到 publishLocal这个问题 - 如果你的源中有@Umbraco.Field("field_1", removeParagraphTags = true) 行,那肯定会有用 em>项目构建文件正确。