I’m trying to use maven-embedder 3.1.1 with Gradle 1.9. Starting with version 3.1.0 Maven uses slf4j for logging. maven-embedder tries to configure the log level and then runs into the following error:
> Cannot cast object 'ch.qos.logback.classic.LoggerContext[default]' with class 'ch.qos.logback.classic.LoggerContext' to class 'ch.qos.logback.classic.LoggerContext'
Nice solution, but doesn’t this fork another instance of Maven? What I wanted to do is use maven-embedder to make things faster and to save some resources.
I finally came up with the following solution which works at least in my setup. I’m using maven-embedder in my ‘buildSrc/build.gradle’:
In order to override the Maven’s logging configuration I had to add a file named ‘buildSrc/src/main/resources/META-INF/maven/slf4j-configuration.properties’ with the following contents:
Of course I had to implement this new ‘DummyLogbackConfiguration’ in ‘buildSrc/src/main/groovy/DummyLogbackConfiguration.groovy’.
import org.apache.maven.cli.logging.BaseSlf4jConfiguration
import org.apache.maven.cli.logging.Slf4jConfiguration.Level
public class DummyLogbackConfiguration extends BaseSlf4jConfiguration {
@Override
public void setRootLoggerLevel(Level level) {
// do not change Gradle's log level
}
@Override
public void activate() {
// no op
}
}
I hope this helps. If you have questions, don’t hesitate to ask.