Home >Java >javaTutorial >How to Exclude Specific Transitive Dependencies in Gradle Using the \'module\' Parameter?
When building a project with Gradle, it's possible for the application plugin to bring in unwanted transitive dependencies, such as org.slf4j:slf4j-log4j12. Using the traditional exclude rule with only group and name parameters may result in excluding too many artifacts or even entire configurations.
To specifically exclude an individual artifact without affecting other dependencies, use the following syntax:
configurations { runtime.exclude group: "org.slf4j", module: "slf4j-log4j12" }
The module parameter in ExcludeRule specifies the artifact that should be excluded. It's important to note that name cannot be used in an exclusion with module.
To exclude a specific transitive dependency from a particular dependency, use the following approach:
dependencies { compile ('org.springframework.data:spring-data-hadoop-core:2.0.0.M4-hadoop22') { exclude group: "org.slf4j", module: "slf4j-log4j12" } }
In Gradle, a module refers to a specific artifact within a dependency. It doesn't have a direct mapping to the Maven concept of modules. To determine the module of a Maven artifact, refer to the artifact's Maven coordinates in the Maven Central repository, which typically includes information like groupId, artifactId, and version.
The above is the detailed content of How to Exclude Specific Transitive Dependencies in Gradle Using the \'module\' Parameter?. For more information, please follow other related articles on the PHP Chinese website!