简体   繁体   中英

com.google.appengine:appengine:+ vs com.google.cloud.tools:appengine-gradle-plugin:+

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?

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 eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM