Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to exclude a dependency from eclipse using a gradle build file

Tags:

eclipse

gradle

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

like image 580
Basil Musa Avatar asked Sep 27 '11 14:09

Basil Musa


1 Answers

Try adding this to your build.gradle:

eclipseClasspath{
  plusConfigurations.each{
    it.allDependencies.each{ it.exclude group: 'org.slf4j', module: 'slf4j-simple' }
  }
}
like image 64
rodion Avatar answered Oct 03 '22 05:10

rodion