How to add sbt project cloud test artifacts to another test path?

There are two sbt projects: common and projectX .

The common project has some dependencies in the test , which I want to see in the path to test in projectX , which has common as a dependency.

This is an excerpt from build.sbt in projectX with the configuration configuration test->test , as described in Configurations :

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

After running test:compile in projectX , the following error appears:

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

How to add test -scoped dependencies in a common project to the class path of a test in a projectX project?

+6
source share
2 answers

I have never seen an error before and cannot reproduce it, but it looks like the test artifacts were not publishLocal ed, since they are not installed by default.

According to the selection of default artifacts :

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

To add all test artifacts:

 publishArtifact in Test := true 

And what you have to do to publish artifcts for the test configuration.

Add the build.sbt to the build.sbt of the common and build.sbt project: so that the tests are packaged and published to the local Ivy2 repository:

 publishArtifact in Test := true 

When changing, you should see the following in the publishLocal : - take into account artifacts related to testing:

 > 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 
+3
source

I had success in solving this problem without publishLocal, switching from Maven-style to Ivy-style publishing and resolution (Ivy files instead of pom files and Ivy-style storage). By the way, if you use a Nexus proxy, it is recommended that you keep backups of Maven and Ivy (as well as Maven groups and Ivy groups) completely separate in Nexus.

However, I don't know why you have this problem with publishLocal - this should work if you have the publishArtifact line in the project build source file correctly.

0
source

Source: https://habr.com/ru/post/972986/


All Articles