"play test" classpath is different from class "sbt test" classpath

Situation: I want to run JUnit test cases for my game! 2.0 on the Jenkins server. To create and test my application on the server, I want to use SBT (with a sequence of commands: clean compile test ).

Problem: Regardless of Jenkins, the play test command uses a different class path than the java -jar "sbt-launch.jar" test command (both commands are executed in the root directory of my playback project, both commands use the same version of sbt 0.12. 2). My test cases can be compiled using play test , but with java -jar "sbt-launch.jar" test compiler complains that some JUnit classes are missing (for example, org.junit.rules.TestWatcher ).

Analysis: The show test:full-classpath command shows that classpathes are really different:

play test classpath contains: Attributed(<playhome>\repository\local\junit\junit-dep\4.10\jars\junit-dep.jar)

java -jar "sbt-launch.jar test classpath contains: Attributed(<userhome>\.ivy2\cache\junit\junit-dep\jars\junit-dep-4.8.2.jar)

Question: Any ideas on how to ensure that java -jar "sbt-launch.jar test uses the same class path as play test ?

Build.scala:

 import sbt._ import Keys._ import play.Project._ object ApplicationBuild extends Build { val appName = "my app" val appVersion = "1.0-SNAPSHOT" val appDependencies = Seq( // Play framework dependencies javaCore, javaJdbc, javaEbean, // Add your project dependencies here "com.typesafe" %% "play-plugins-mailer" % "2.1.0", "com.feth" %% "play-authenticate" % "0.2.5-SNAPSHOT", "org.mongodb" % "mongo-java-driver" % "2.10.1", "com.embedly" % "embedly-api" % "0.1.5", "org.mockito" % "mockito-all" % "1.9.5", "org.mongojack" % "mongojack" % "2.0.0-RC5", "commons-io" % "commons-io" % "2.3" ) val main = play.Project(appName, appVersion, appDependencies).settings( resolvers += Resolver.url("play-easymail (release)", url("http://joscha.github.com/play-easymail/repo/releases/"))(Resolver.ivyStylePatterns), resolvers += Resolver.url("play-easymail (snapshot)", url("http://joscha.github.com/play-easymail/repo/snapshots/"))(Resolver.ivyStylePatterns), resolvers += Resolver.url("play-authenticate (release)", url("http://joscha.github.com/play-authenticate/repo/releases/"))(Resolver.ivyStylePatterns), resolvers += Resolver.url("play-authenticate (snapshot)", url("http://joscha.github.com/play-authenticate/repo/snapshots/"))(Resolver.ivyStylePatterns) ) } 
+4
source share
1 answer

play script redirects sbt to use the local JUnit file repository in addition to any remote computer you have deleted. That is why the load is so great. By default, Ivy does not copy local files to its local cache, as it assumes that they are stable.

SO, what you see is an sbt script that uploaded the file and a Play script that has its own local repo that takes precedence over the uploaded file.

Now the interesting part is around the version. Ivy has an interesting version conflict resolution.

If you paste, you look in your target/resolution-cache/reports directory, you can get an idea of ​​the difference between the two commands and why one junit is selected over the other. I assume that there is a dynamic version range that searches the local repository to play the script and does not find a newer version of junit-dep.

0
source

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


All Articles