需要使用gradle构建文件从eclipse中排除依赖 [英] Need to exclude a dependency from eclipse using a gradle build file
问题描述
我试图从我的gradle构建中排除一个依赖项,主要是slf4j-simple。它运行良好,但是当我运行gradle eclipse时没有反映出来。
在我的gradle构建文件中有以下代码:
apply plugin:'war'
apply plugin:'eclipse'
apply plugin:'jetty'
...
依赖{
编译'mysql:mysql-connector-java:5.1.16'
编译'net.sourceforge.stripes:stripes:1.5'
编译'javax.servlet:jstl :1.2'
...(其余依赖)
}
配置{
全部* .exclude组:'org.slf4j',模块:'slf4j-simple'
$ / code>
现在,当我运行'gradle build'时,slf4j-simple被排除来自创建的war文件,这很好。
当我运行'gradle eclipse'时,slf4j-simple不会从eclipse classpath中排除。
在gradle cookbook中提到了解决这个问题的一个解决方案,但我不明白如何应用它:
http://docs.codehaus.org/display/GRADLE/Cookbook#Cookbook-Excludingdependencies fromEclipseProjects
尝试将其添加到您的build.gradle中:
eclipseClasspath {
plusConfigurations.each {
it.allDependencies.each {it.exclude group:'org.slf4j',module:'slf4j-simple'}
}
}
I'm trying to exclude a dependency, mainly "slf4j-simple" from my gradle build. It works well, but is not reflected when I run "gradle eclipse".
I have the following code in my gradle build file:
apply plugin:'war'
apply plugin:'eclipse'
apply plugin:'jetty'
...
dependencies {
compile 'mysql:mysql-connector-java:5.1.16'
compile 'net.sourceforge.stripes:stripes:1.5'
compile 'javax.servlet:jstl:1.2'
... (Rest of the dependencies)
}
configurations {
all*.exclude group:'org.slf4j',module:'slf4j-simple'
}
Now, when I run 'gradle build', the slf4j-simple is excluded from the war file created which is fine.
When I run 'gradle eclipse', the slf4j-simple is not excluded from the eclipse classpath.
A solution to the problem is mentioned in the gradle cookbook but I don't understand how to apply it:
http://docs.codehaus.org/display/GRADLE/Cookbook#Cookbook-ExcludingdependenciesfromEclipseProjects
Try adding this to your build.gradle:
eclipseClasspath{
plusConfigurations.each{
it.allDependencies.each{ it.exclude group: 'org.slf4j', module: 'slf4j-simple' }
}
}
这篇关于需要使用gradle构建文件从eclipse中排除依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!