Reputation: 5028
I am trying to use a library called REST Assured with the Play Framework. The documentation - https://code.google.com/p/rest-assured/wiki/GettingStarted - gives the following artifact for Maven -
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>1.8.0</version>
<scope>test</scope>
</dependency>
So I altered my Build.scala file as follows to include this dependency -
val appDependencies = Seq(
// Add your project dependencies here,
javaCore,
javaJdbc,
javaEbean,
"com.jayway.restassured" % "rest-assured" % "1.8.0" % "test"
)
Then I try and use this library in a Java by statically importing some packages, which is what the documentation instructs me to do -
import static com.jayway.restassured.RestAssured.*;
import static com.jayway.restassured.matcher.RestAssuredMatchers.*;
import static org.hamcrest.Matchers.*;
But this results in an Compilation error when I try and run the Play application -
error: package com.jayway.restassured does not exist
I know that Play/sbt is retrieving the dependency because I can see a "com.jayway.restassured" directory in the play-2.1.0/repository/cache directory. However it is not showing in the play-2.1.0/repository/local directory, I don't know if that has any significance.
So what's going wrong, why can't I access this library in my Play application?
Upvotes: 2
Views: 1174
Reputation: 2708
If you need to access REST Assured from non-test code, the dependency should be defined as:
"com.jayway.restassured" % "rest-assured" % "1.8.0"
In other words, drop the "test"
declaration. When that's present you're specifying that the library is a test-scope dependency. At the moment you're saying that REST Assured is not a dependency of your production code, and only needs to be scoped to code in your test tree (i.e added to the test classpath).
I guess the follow-up question is why you wish to reference a testing library from your app
code?
Upvotes: 3