I am using Gradle for a project. My build.gradle has got JUnit as a dependency, but every time I import the project again it does not recognize the JUnit library and asks me to add it to classpath. This problem does not only apply to JUnit, but also to other dependencies. Did I add JUnit to the wrong place?
PS: The project builds just fine, it's just the IDE (IntelliJ) that's marking everything red.
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
}
Gradle dependencies are grouped into sets called configurations. Different configurations are used for building classpath for the major two tasks — compile classpath is used for compilation and runtime classpath is used for running the application.
The dependency declaration is correct. Probably you're opening the project in IntelliJ IDEA the wrong way.
I suggest you to open a Gradle project this way:
File | Open
menubuild.gradle
fileHere is further information about importing Gradle projects (see also the side note in that page).
download the external jar file from mvn repository and add it to libs folder.
Gradle-project(your project)->libs(inside libs folder paste jar file). if you don't have libs folder just create it.
go to build.gradle dependencies { compile files('libs/your_jar.jar') }
reload the gradle project.
it's worked for me. i hope it's work for you guys also...
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