This works fine but when I execute any ant task via gradle e.g. gradle build an exception is thrown which states that logging class is already loaded
log4j:ERROR A "org.apache.log4j.PatternLayout" object is not assignable to a "org.apache.log4j.Layout" variable.
log4j:ERROR The class "org.apache.log4j.Layout" was loaded by
log4j:ERROR [AntClassLoader[
...
C:\project\lib\jaxen-1.1.3.jar;C:\project\lib\jgroups-3.2.5.Final.jar;
C:\project\lib\joda-time-2.0.jar;
C:\project\lib\junit-4.9.jar;
C:\project\lib\log4j-1.2.16.jar;
C:\project\lib\mime-util-2.1.3.jar;
....
]]
whereas object of type
log4j:ERROR "org.apache.log4j.PatternLayout" was loaded by [org.gradle.internal.classloader.MutableURLClassLoader@71f250e8].
in this case the log4j-1.2.16 conflicts with gradles log4j-over-slf4j-1.7.2. It is not possible to change the log4j implementation because it is a third party app.
Is it possible to run the ant task in a sandbox where the classloader of gradle does not influence the build?
I’ve the same problem. (sorry if the question is stupid, I’m quite new to Gradle) The framework I’m using (Hybris) forces Ant vers.1.9.1
I’ve created my own gradle distribution changing ant to version 1.9.1 instead of 1.9.2 in order to be able to call ant tasks inside my build.gradle. The problem I’m having now is exactly the one mentioned here.
log4j:ERROR A "org.apache.log4j.PatternLayout" object is not assignable to a "org.apache.log4j.Layout" variable.
log4j:ERROR The class "org.apache.log4j.Layout" was loaded by
log4j:ERROR [AntClassLoader[
...
/data/proj/lib/junit-4.9.jar:
/data/proj/lib/log4j-1.2.16.jar:
/data/proj/lib/mail-1.4.4.jar:
...
]] whereas object of type
log4j:ERROR "org.apache.log4j.PatternLayout" was loaded by [org.gradle.internal.classloader.MutableURLClassLoader@7a5f39b0].
in the current settings.gradle of the gradle project I’ve just changed
$ ./gradlew task
log4j:ERROR A "org.apache.log4j.PatternLayout" object is not assignable to a "org.apache.log4j.Layout" variable.
log4j:ERROR The class "org.apache.log4j.Layout" was loaded by
log4j:ERROR [AntClassLoader[/data/proj/platform/bootstrap/bin/ybootstrap.jar:/data/proj/platform/bootstrap/bin/yant.jar:
.....
r]] whereas object of type
log4j:ERROR "org.apache.log4j.PatternLayout" was loaded by [org.gradle.internal.classloader.MutableURLClassLoader@1c49094].
[ant:echo] ---------------------------------------------------------------
[ant:echo] hybris Platform Environment
[ant:echo] ---------------------------------------------------------------
.....
log4j:ERROR [AntClassLoader[/data/proj/platform/bootstrap/bin/ybootstrap.jar:/data/proj/platform/bootstrap/bin/yant.jar:
.....
r]] whereas object of type
log4j:ERROR "org.apache.log4j.PatternLayout" was loaded by [org.gradle.internal.classloader.MutableURLClassLoader@1c49094].
:tasks
.....
(tasks are correctly shown)
....
It looks like only by importing the build.xml gradle calls ant default task and then fails in the mid.
Question is why is it calling it? my build.gradle has only the ant.importBuild nothing more.
The other thing is that even upgrading log4j to 1.2.17 in the Hybris ant distribution doesn’t solve the problem.
@Luke: The framework [y] which I am using is providing ant build which is wrapped by gradle and this 3rd Party build file includes the lib. Because the framework it self is not in the VCS and regularly updated I don’t want to change all build files which are including the lib.
Did anyone ever resolve this? I’m having the same issue. If I leave log4j out of the ant classpath, I get a class not found exception. If I put it in, I get the same conflict described here with the no classdef found error.