scala - sbt different libraryDependencies in test than in normal mode -
because of conflicting / transitive (elasticsearch / lucene / jackrabbit) dependencies want have different librarydependencies in test have when running app. solved setup below, requires running activator -dtest , prevent app running when i'm done testing. other way around, i.e. running activator, will run app not run test. so, not convenient , think can done better (btw i'm new sbt/scala)
name := """example""" version := "0.1" lazy val root = (project in file(".")).enableplugins(playjava) scalaversion := "2.11.1" // fork in test := true javaoptions in test += "-dconfig.file=conf/application.test.conf" javaoptions in test += "-dlogger.file=conf/test-logger.xml" // run activator -dtest if (sys.props.contains("test")) { seq[project.setting[_]]( librarydependencies ++= { seq( javajdbc, javaebean, cache, javaws, "org.webjars" %% "webjars-play" % "2.3.0-2", "org.webjars" % "bootstrap" % "3.3.6", "org.webjars" % "font-awesome" % "4.5.0", "be.objectify" %% "deadbolt-java" % "2.3.3", "org.apache.lucene" % "lucene-core" % "3.6.0", "org.elasticsearch" % "elasticsearch" % "1.7.4" exclude("org.apache.lucene", "lucene-core"), "javax.jcr" % "jcr" % "2.0", "org.apache.jackrabbit" % "jackrabbit-core" % "2.11.2", "org.apache.jackrabbit" % "jackrabbit-jcr2dav" % "2.11.2", "org.apache.tika" % "tika-parsers" % "1.11", "org.apache.tika" % "tika-core" % "1.11", "commons-io" % "commons-io" % "2.4", "com.typesafe.akka" % "akka-testkit_2.11" % "2.3.14" % "test" ) } ) } else { seq[project.setting[_]]( librarydependencies ++= { seq( javajdbc, javaebean, cache, javaws, "org.webjars" %% "webjars-play" % "2.3.0-2", "org.webjars" % "bootstrap" % "3.3.6", "org.webjars" % "font-awesome" % "4.5.0", "be.objectify" %% "deadbolt-java" % "2.3.3", "org.elasticsearch" % "elasticsearch" % "1.7.4", "javax.jcr" % "jcr" % "2.0", "org.apache.jackrabbit" % "jackrabbit-core" % "2.11.2", "org.apache.jackrabbit" % "jackrabbit-jcr2dav" % "2.11.2", "org.apache.tika" % "tika-parsers" % "1.11", "org.apache.tika" % "tika-core" % "1.11", "commons-io" % "commons-io" % "2.4", "com.typesafe.akka" % "akka-testkit_2.11" % "2.3.14" % "test" ) } ) } //.. our private nexus repo left out here resolvers += "jboss repository" @ "https://repository.jboss.org/nexus/content/repositories" resolvers += "jboss third-party repository" @ "https://repository.jboss.org/nexus/content/repositories/thirdparty-releases" resolvers += "typesafe repository" @ "http://repo.typesafe.com/typesafe/releases/" resolvers += resolver.url("objectify play repository", url("http://deadbolt.ws/releases/"))(resolver.ivystylepatterns)
i don't have setup can test whether works, how understand sbt dependencies should:
dependencies can have kind of scope called configuration. typically, used define test dependencies:
"com.typesafe.akka" % "akka-testkit_2.11" % "2.3.14" % "test"
but should able define compile time , run time dependencies using "compile" , "runtime" instead.
sbt prints me warning if use dependencies different versions. problem is, use different version of dependency compile , run tests. run against different version compiled with. there of course libraries, work, especially, if run newer version use compile.
if need compile application twice different dependencies , use 1 build running , 1 testing, fear, there won't solution without extending sbt or that.
you try make 2 modules, 1 main code , 1 testing , try cross-build 2 different versions of first module. sbt can cross-build on multiple scala versions, don't think can out of box multiple versions of library.
Comments
Post a Comment