ExternalDependency with explicit extension not transitive

Hi,

I have observed, that external dependencies are silently set to transitive=false, if the extension was explicitely specified (as ‘jar’), e.g.:

compile "org.apache.httpcomponents:httpclient:4.0.3"
compile "org.apache.httpcomponents:httpclient:4.0.3@jar"

This behaviour is different from how Maven works and thus unexpected.

At least, this should be mentioned in the documentation, e.g. at https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.dsl.DependencyHandler.html#N15F9A

You can verify my observations with the builds scripts copied-in below (can’t attached files yet). Just invoke ‘gradle dependencies’ or ‘mvn dependency:tree’.

Thanks and regards,

Thipor


apply plugin: ‘java’

dependencies {
compile "org.apache.httpcomponents:httpclient:4.0.3"
compile “org.springframework:spring-context:3.1.4.RELEASE@jar”
}

<dependencies>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.0.3</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>3.1.4.RELEASE</version>
        <type>jar</type>
    </dependency>
</dependencies>

By changing a dependency from “org.apache.httpcomponents:httpclient:4.0.3” to “org.apache.httpcomponents:httpclient:4.0.3@jar” you make this dependency an artifact only dependency and any meta-data will be ignored. This is expected behaviour and explained in detail in the Gradle userguide at https://docs.gradle.org/current/userguide/dependency_management.html.