nieschumi
nieschumi

Reputation: 561

Gradle dependencies: What's the difference between compile project and compile name?

Sample code

dependencies {    
    compile project (':aProject')
    compile name: 'somefile'
    compile files('libs/something_local.jar')
    compile 'com.google.code.gson:gson:2.3.1'
}

My questions are

  1. What's the difference between compile project and compile name here?

  2. Is compile name the same as compile files?

  3. When do you use compile directly as shown in the 5th line of code

  4. What does compile do here? Is it compiling the files inside bracket/single quotes? Can I use something like 'build' etc.?

Upvotes: 6

Views: 2169

Answers (1)

NaviRamyle
NaviRamyle

Reputation: 4007

Compile means, it is compiling the library in other to be used on your project

compile project (':aProject')

  • It compiles the module from your project

compile files('libs/something_local.jar')

  • It compiles a file from your project (usually it is on lib directory)

compile name: 'something_local'

compile(name:'something_local', ext:'jar')

  • It is the same as compile files, but your are indicating the directory of the file the repositories (like compiling from a remote repository but it is from local)

compile 'com.google.code.gson:gson:2.3.1'

  • It compiles the library from a maven repository, you use this instead of cloning the library project and putting it to your project.

Upvotes: 6

Related Questions