Home > Software design >  What is the proper syntax of excluding transient dependencies in gradle, name or module?
What is the proper syntax of excluding transient dependencies in gradle, name or module?

Time:04-20

I have come across two different variations of syntax to exclude a transient dependency in gradle

One uses name and another uses module. Which one is correct?

For eg:

name:

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation group: 'org.springframework', name: 'spring-context', version: '5.3.19'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    
    implementation('org.springframework.boot:sprin  g-boot-starter-web') {
        exclude group: 'org.springframework', name: 'spring-context'
    }
}

OR module:

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation group: 'org.springframework', name: 'spring-context', version: '5.3.19'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    
    implementation('org.springframework.boot:sprin  g-boot-starter-web') {
        exclude group: 'org.springframework', module: 'spring-context'
    }
}

CodePudding user response:

The current documentation (7.4.2) shows module:

https://docs.gradle.org/7.4.2/userguide/dependency_downgrade_and_exclude.html

implementation('commons-beanutils:commons-beanutils:1.9.4') {
    exclude group: 'commons-collections', module: 'commons-collections'
}

name is probably a legacy naming. Go with what the current documentation has, module.

  • Related