Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the meaning of @aar with transitive = true

i use crashlytics only as an example.

what's is the difference from

    compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { transitive = true; }

and

    compile 'com.crashlytics.sdk.android:crashlytics:2.6.8'
like image 763
Xan Avatar asked Jul 04 '17 09:07

Xan


People also ask

Is transitive true?

Several Gradle docs (here and here) imply that "transitive" defaults to true. Yet removing transitive = true results in transitive dependencies not being brought in (in particular KitGroup ).

What is transitive dependencies Gradle?

Transitive dependencyA variant of a component can have dependencies on other modules to work properly, so-called transitive dependencies. Releases of a module hosted on a repository can provide metadata to declare those transitive dependencies. By default, Gradle resolves transitive dependencies automatically.

Is transitive false Gradle?

Since gradle 3.4, compileClasspath was added which the Java Plugin uses. Although compileClasspath depends on compile, settings transitive = false on compile is not inherited (by design) and therefore code is compiled with a classpath that includes all the transitive dependencies.

How do you avoid transitive dependencies in Gradle?

When you specify a dependency in your build script, you can provide an exclude rule at the same time telling Gradle not to pull in the specified transitive dependency. For example, say we have a Gradle project that depends on Google's Guava library, or more specifically com.


1 Answers

If you use the ...@artifacttype notation in a Gradle dependency it means "only get me this artifact and no transitive dependencies". By additionally setting transitive = true, you are fetching the transitive dependencies despite that fact.

The first version gets the aar with dependencies and as far as I remember the second always gets the jar if one is present and else nothing but the dependencies. Add configurations.compile.each { println it } to output the actual files in the configuration and you should see the difference.

In the case of crashlytics there is no difference:

compile 'com.crashlytics.sdk.android:crashlytics:2.6.8'
/home/xan/.gradle/caches/modules-2/files-2.1/com.crashlytics.sdk.android/crashlytics/2.6.8/2f667ae0609d82045cbe602d38df3fbf2c9528dd/crashlytics-2.6.8.aar
/home/xan/.gradle/caches/modules-2/files-2.1/com.crashlytics.sdk.android/beta/1.2.5/f73d30657bb44ecb79d434a4ae3fb7d887371d84/beta-1.2.5.aar
/home/xan/.gradle/caches/modules-2/files-2.1/io.fabric.sdk.android/fabric/1.3.17/85fc9aae9009f6fb2beaf23fa0ce1ae13f124413/fabric-1.3.17.aar
/home/xan/.gradle/caches/modules-2/files-2.1/com.crashlytics.sdk.android/crashlytics-core/2.3.17/f3bed4c297be8d30dc5aa7f18b06dff75435bde4/crashlytics-core-2.3.17.aar
/home/xan/.gradle/caches/modules-2/files-2.1/com.crashlytics.sdk.android/answers/1.3.13/83dc1dd439c7da04ce9705f18037fe7551ae06bc/answers-1.3.13.aar

compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { transitive = true; }
/home/xan/.gradle/caches/modules-2/files-2.1/com.crashlytics.sdk.android/crashlytics/2.6.8/2f667ae0609d82045cbe602d38df3fbf2c9528dd/crashlytics-2.6.8.aar
/home/xan/.gradle/caches/modules-2/files-2.1/com.crashlytics.sdk.android/beta/1.2.5/f73d30657bb44ecb79d434a4ae3fb7d887371d84/beta-1.2.5.aar
/home/xan/.gradle/caches/modules-2/files-2.1/io.fabric.sdk.android/fabric/1.3.17/85fc9aae9009f6fb2beaf23fa0ce1ae13f124413/fabric-1.3.17.aar
/home/xan/.gradle/caches/modules-2/files-2.1/com.crashlytics.sdk.android/crashlytics-core/2.3.17/f3bed4c297be8d30dc5aa7f18b06dff75435bde4/crashlytics-core-2.3.17.aar
/home/xan/.gradle/caches/modules-2/files-2.1/com.crashlytics.sdk.android/answers/1.3.13/83dc1dd439c7da04ce9705f18037fe7551ae06bc/answers-1.3.13.aar
like image 72
Vampire Avatar answered Nov 14 '22 22:11

Vampire