Home > Java > javaTutorial > body text

How to Exclude Specific Transitive Dependencies in Gradle Using the \'module\' Parameter?

DDD
Release: 2024-10-26 02:48:02
Original
514 people have browsed it

How to Exclude Specific Transitive Dependencies in Gradle Using the

How to Selectively Exclude Transitive Dependencies in Gradle

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.

The Solution: Using module Parameter

To specifically exclude an individual artifact without affecting other dependencies, use the following syntax:

configurations {
  runtime.exclude group: "org.slf4j", module: "slf4j-log4j12"
}
Copy after login

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.

Excluding from Individual Dependencies

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"
  }
}
Copy after login

Understanding Modules in Gradle

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!