I’m trying to develop a simple task that uses a library which has dependency to log4j. However, when executing my task the build fails with “java.lang.NoSuchMethodError: org.apache.log4j.Logger.getAppender(Ljava/lang/String;)Lorg/apache/log4j/Appender;”. From what I found this is because the Gradle Runtime classpath is taken with higher priority than the one for my custom task. This means that log4j-over-slf4j(part of the gradle runtime) has high prio in the classpath and as it does not contain a method getAppender(String) for the Logger class the build fails.
Is there a way to prevent this behavior and make my task use the log4j implementation for the Logger class?