gradle Dependencies Add a Dependency


Example

Dependencies in Gradle follow the same format as Maven. Dependencies are structured as follows:

group:name:version

Here's an example:

'org.springframework:spring-core:4.3.1.RELEASE'

To add as a compile-time dependency, simply add this line in your dependency block in the Gradle build file:

compile 'org.springframework:spring-core:4.3.1.RELEASE'

An alternative syntax for this names each component of the dependency explicitly, like so:

compile group: 'org.springframework', name: 'spring-core', version: '4.3.1.RELEASE'

This adds a dependency at compile time.

You can also add dependencies only for tests. Here's an example:

testCompile group: 'junit', name: 'junit', version: '4.+'