Declaring dependencies in gradle

We can declare dependencies in Gradle as shown below. Each dependency must be declared with 3 co-ordinates.
  • Group Id – Name of organisation that has developed this library
  • Artifact name – Name of the artifact (jar)
  • Artifact version
We can also declare the dependency in the form of jar files using files and fileTree syntax.
dependencies {
    compile group: 'joda-time', name: 'joda-time', version: '2.9.4'
    compile  'commons-io:commons-io:2.5'
    testCompile 'junit:junit:4.12'
    runtime files('libs/iolib.jar', 'libs/xmllib.jar')
    runtime fileTree(dir: 'libs', include: '*.jar')

Each dependency has a specific scope of dependency
  • compile
  • runtime
  • testCompile
  • testRuntime
For example – junit dependency has a testCompile scope. It means that this dependency is required at the time of compiling test source files.

Web development and Automation testing

solutions delivered!!