Gradle custom plugin NoSuchMethodError: org.apache.log4j.ConsoleAppender

plugins

(Thulasirajan) #1

Hi,

So far I am just a Gradle user. However my current organisation uses a propitiatory build tools which in my opinion very less intuitive and reduces the productivity. To show the build team how easy using gradle, I decided to write a plugin that interacts with their proprietary repository. So I made a fat jar with all code that interacts with repository and I used this fat jar from Gradle Plugin. I unit tested fat jar independent of Gradle and works fine. But when I use this jar (which I added to local maven repo and created dep for the custom plugin) I get the following NoSuchMethodError

Caused by: java.lang.NoSuchMethodError: org.apache.log4j.ConsoleAppender.(Lorg/apache/log4j/Layout;Ljava/lang/String;)V

I verified it loaded some classes from fat jar but when it reaches a class that uses log I got the above error.

With google and this forum search I can find mail thread related to this topic but could not figure out how to solve this issue. What I understand so far is that Gradle plugin classpath has different version of log4j, but not sure how to confirm this and fix. Please let me know your suggestions. The Plugin is written in Java not groovy, this is just to let you know so that I can digest API signature in Java


(Albert Nicolas) #2

Hi,

I’m facing the same situation. I want to “gradlify” our own build tool (written in Java) to Gradle.
I like the idea to run in the same JVM as gradle but I read that classloader of plugin aren’t isolated and a futur version will improve that.

Maybe I’ll do a plugin wrapper to call a CLI version with arguments in its own JVM.

I still do experiments.

Do you find a solution ?