Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

gradle

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

like image 552
Abdul Rahman Avatar asked Jun 14 '16 23:06

Abdul Rahman


People also ask

What is the difference between compile and implementation in Gradle?

Fortunately, the implementation dependency configuration provides the same functionality as compile. You should always use implementation rather than compile for dependencies, as compile is now deprecated or removed in the case of Gradle 7+.

What is difference between compile and compileOnly Gradle?

The compileOnly configuration is used to itemize a dependency that you need to compile your code, same as compile above. The difference is that packages your java code use from a compileOnly dependency will not be listed as Import-Package manifest entries.

What is provided compile Gradle?

Here, compile refers to the dependencies that are required to compile the project and non-compile refers to the dependencies that are not required for project compilation. The compileOnly configuration is the closest option to mavens "provided" scope, but it is not a true "only at compile time" configuration.

What is testImplementation in build Gradle?

For example the testImplementation configuration extends the implementation configuration. The configuration hierarchy has a practical purpose: compiling tests requires the dependencies of the source code under test on top of the dependencies needed write the test class.


1 Answers

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.

like image 79
mariosangiorgio Avatar answered Sep 24 '22 22:09

mariosangiorgio