简体   繁体   中英

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

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.

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