相关疑难解决方法(0)

使用Gradle时如何排除传递依赖项的所有实例?

我的gradle项目使用该application插件来构建一个jar文件.作为运行时传递依赖的一部分,我最终会进入org.slf4j:slf4j-log4j12.(它被引用为至少5或6个其他传递依赖的子传递依赖 - 这个项目使用spring和hadoop,所以除了厨房水槽之外的所有东西都被拉进来......没等了......那也是:) ).

我想slf4j-log4j12从我的内置jar中全局排除jar.所以我试过这个:

configurations {
  runtime.exclude group: "org.slf4j", name: "slf4j-log4j12"
}
Run Code Online (Sandbox Code Playgroud)

但是,这似乎排除了所有 org.slf4j工件,包括slf4j-api.在调试模式下运行时,我看到以下行:

org.slf4j#slf4j-api is excluded from com.pivotal.gfxd:gfxd-demo-mapreduce:1.0(runtime).
org.slf4j#slf4j-simple is excluded from com.pivotal.gfxd:gfxd-demo-mapreduce:1.0(runtime).
org.slf4j#slf4j-log4j12 is excluded from org.apache.hadoop:hadoop-common:2.2.0(runtime).
Run Code Online (Sandbox Code Playgroud)

我不想查找每个slf4j-log4j12传递依赖的源,然后compile foo { exclude slf4j... }在我的dependencies块中有单独的语句.

更新:

我也试过这个:

configurations {
  runtime.exclude name: "slf4j-log4j12"
}
Run Code Online (Sandbox Code Playgroud)

最终排除了构建中的所有内容!好像我指定的那样group: "*".

更新2:

我正在使用Gradle版本1.10.

java gradle

87
推荐指数
7
解决办法
10万
查看次数

标签 统计

gradle ×1

java ×1