2

I am new to gradle concept. I'm doing gradle for app engine (I don't know maven or ant) and I gone through in [https://cloud.google.com/appengine/docs/standard/java/tools/gradle] but I can't able to understand the difference between the:

buildscript {
     repositories {
     jcenter()
     mavenCentral()
   }
dependencies {
     classpath 'com.google.cloud.tools:appengine-gradle-plugin:+'
   }
}

and:

repositories {
     jcenter()
     mavenCentral()
}

dependencies {
     providedCompile 'javax.servlet:servlet-api:2.5'
     compile 'com.google.appengine:appengine:+'
}

I searched in the internet I can't able to understand? Can anyone explain this?

Opal
  • 81,889
  • 28
  • 189
  • 210
Prakash
  • 630
  • 3
  • 10
  • 20

1 Answers1

1

It may be confusing at the very beginning but is quite easy. With gradle you do manage the project but both gradle and the project that is managed can have their own dependencies. So, if you'd like e.g. use guava to compile your project files it will be:

repositories {
   mavenCentral()
}

dependencies {
   compile 'com.google.guava:guava:22.0'
}

but if you'd like to use guava in build.gradle file then the following piece of code is necessary:

buildscript {
   repositories {
      mavenCentral()
   }
   dependencies {
      classpath 'com.google.guava:guava:22.0'
   }
}

So buildscript is used to configure build.gradle itself.

In the example provided buildscript block is used to configure dependency for plugin that is applied later on in build.gradle and the second block configures the dependencies for the project itself.

Opal
  • 81,889
  • 28
  • 189
  • 210