Reputation: 12413
I am extremely confused, I am not a gradle expert, not really familiar with the Groovy syntax. The thing is, I have a transitive dependency in my logging libraries that I want to exclude but when I try to boot my app using gradle bootRun, looks like I cant because have some kind of syntax error and I can't figure out what it is. This is the error I get:
>gradle bootRun
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\workspace\tictactoe\build.gradle' line: 55
* What went wrong:
A problem occurred evaluating root project 'tictactoe'.
> No signature of method: java.util.LinkedHashMap.call() is applicable for argument types: (build_bkiihj275q6h9zzyz2rjvcelk$_run_closure3$_closure7) values: [build_bkiihj275q6h9zzyz2
rjvcelk$_run_closure3$_closure7@7d42404e]
Possible solutions: wait(), any(), wait(long), any(groovy.lang.Closure), take(int), max(groovy.lang.Closure)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.678 secs
And this is the part of my gradle.build where I add all my dependencies:
compile (
[group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.6.2'],
[group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'],
[group: 'org.springframework.boot', name: 'spring-boot-starter-jetty'],
[group: 'org.springframework.boot', name: 'spring-boot-starter-logging'],
[group: 'org.springframework', name: 'spring-context-support'],
[group: 'org.apache.commons', name: 'commons-lang3', version: commonsLangVersion],
[group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion],
[group: 'org.slf4j', name: 'slf4j-log4j12', version:'1.7.10']
{
exclude group: 'ch.qos.logback', module: 'logback-classic'
},
[group: 'log4j', name: 'log4j', version:'1.2.17'],
[group: 'com.mashape.unirest', name: 'unirest-java', version: unirestVersion],
[group: 'com.cedarsoftware', name: 'json-io', version: jsonioVersion]
)
Upvotes: 2
Views: 1817
Reputation: 3779
You probably want to globally exclude logback from your project.
The simplest way to do this is to add the following to your project's build.gradle
:
configurations.all {
exclude group: "ch.qos.logback", module: "logback-classic"
}
If you want to exclude everything in that group and not just a specific artifact (logback-classic
), you can omit module
. Like so:
configurations.all {
exclude group: "ch.qos.logback"
}
Upvotes: 3
Reputation: 50245
This should do.
[
[group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.6.2'],
[group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'],
[group: 'org.springframework.boot', name: 'spring-boot-starter-jetty'],
[group: 'org.springframework.boot', name: 'spring-boot-starter-logging'],
[group: 'org.springframework', name: 'spring-context-support'],
[group: 'org.apache.commons', name: 'commons-lang3', version: commonsLangVersion],
[group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion],
[group: 'log4j', name: 'log4j', version:'1.2.17'],
[group: 'com.mashape.unirest', name: 'unirest-java', version: unirestVersion],
[group: 'com.cedarsoftware', name: 'json-io', version: jsonioVersion]
].each {
compile it
}
compile 'org.slf4j:slf4j-log4j12:1.7.10', {
exclude module: 'logback-classic'
}
You can go one step further to make it simpler as
[
'org.slf4j:jcl-over-slf4j:1.6.2',
'log4j:log4j:1.2.17',
'foo:bar:0.1'
].each { compile it }
Upvotes: 1