I have a basic java project and I want to run tests using Mockito (since I use it at work and it's easy). So I referred to this link and added the following to my build.gradle
dependencies {
testCompile 'junit:junit:4.11'
testCompile "org.mockito:mockito-core:1.+"
}
Even though I think mavenCentral() should be enough, I went ahead and added these to my repositories list
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
The ./gradlew clean build runs perfectly fine, but when I try to add the import for Mockito it doesn't get it. And my External Libraries folder in the project doesn't have the Mockito jar. I even tried using mavenLocal() in the hope that it'll pick it up from my local .m2 directory, but it doesn't. I've been looking around and trying out all combinations for 2 hours now with absolutely no result. I don't want to add the jar to the project. I want to let gradle pull it from the central repo and compile it.
Thanks for any help in advance.
I found the answer here Apparently clicking on that refresh button refreshes the dependencies. Else right click on module -> Open Module settings -> Go to Dependencies tab and add your dependency either from your local m2 folder or provide the maven central URL for the dependency. I was too used to Eclipse doing stuff for me I guess. :)
Is this in Eclipse? If so, right-click on the project and go gradle > Update All
(I think it is - I don't have open at moment and don't think about it any more). This will update the dependencies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With