简体   繁体   中英

what is the difference between compile, testCompile and provided in gradle dependency

I am using android studio and in project structure -> dependencies tab following options i can see:

  1. Compile
  2. Provided
  3. APK
  4. Test Compile
  5. Debug Compile
  6. Release Compile

my question: what is the difference between compile, testCompile and provided in gradle dependency

compile is the group of dependencies you need to build your application while testCompile is a group of dependencies that you need only for testing.

Look for instance at this build.gradle (taken from here )

apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final'
    testCompile group: 'junit', name: 'junit', version: '4.+'
}

This specifies that hibernate-core is needed to build your code but junit (a testing framework) is needed just for testing. Since it's not needed at runtime, it's not going to be included in the released package.

You should read the User Guide that comes with the distribution, or read it online at http://gradle.org/documentation/ .

In short, "compile" is for dependencies for your "main" code, "testCompile" for your test classes, and "provided" is used for dependencies that are used at compile time, but not stored in your WAR file (because they're expected to be available in your web container).

The following posting might have relevant information: Compile, Provided, APK - Android dependency scope .

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