Ant ejbJar task could not load class org.apache.tools.ant.util.depend.bcel.FullAnalyzer

Hi,

I am trying to run ejbJar task to create an ejb jar which should include ejb classes plus all the classes on which ejbs are dependent upon.

ant.ejbjar(descriptordir:"$xdocletSrcPath/META-INF",
dependency:“full”,
srcdir:"$sourceSets.ejbJarSrc.output.classesDir",
destdir: “$libsDir”,
naming:“basejarname”,
basejarname:“my-ejb.jar”,
genericjarsuffix:"",
classpath:"$ejbClasspath") {
include(name:"/*ejb-jar.xml")
exclude(name:"
/weblogic.xml")
}

Due to property dependency:"full" it tries to load class org.apache.tools.ant.util.depend.bcel.FullAnalyzer which is not present in gradle-2.11 ( lib folder has only ant-1.9.3.jar and ant-launcher-1.9.3.jar which doesn’t have this file.) and sets property dependency:“full” to dependency:“none” and does not try to look for classes on which my ejbs are dependent upon.

I tried

  1. Copying ant-apache-bcel-1.9.3.jar in libs folder which has this class , but ant instance can still not load it and gives warning Unable to load dependency analyzer: org.apache.tools.ant.util.depend.bcel.FullAnalyzer

  2. Create a custom config and added a dependency for ant-apache-bcel-1.9.3.jar to it and provided this config.aspath in my ant taskdef but still ant cannot load the class while executing teh task

configurations{
ejbJarConfig
}

dependencies {
ejbJarConfig ‘org.apache.ant:ant-apache-bcel:1.9.3’
}

ant.taskdef( name: ‘ejbJar’,
classname: ‘org.apache.tools.ant.taskdefs.optional.ejb.EjbJar’,
classpath:configurations.ejbJarConfig.asPath)
)

ant.ejbJar(descriptordir:"$xdocletSrcPath/META-INF",
dependency:“full”,
srcdir:"$sourceSets.ejbJarSrc.output.classesDir",
destdir: “$libsDir”,
naming:“basejarname”,
basejarname:“my-ejb.jar”,
genericjarsuffix:"",
classpath:"$ejbClasspath") {
include(name:"/*ejb-jar.xml")
exclude(name:"
/weblogic.xml")
}

Can’t get my head around it :confused::worried:

The way we did it was to load all the any jar classes pogramatiacally as gradle ignores ant configurations like ant_home etc.

In build.gradle

configurations{
antEjbJarTaskDependenciesConfig libs.ant
}

def antClassLoader = org.apache.tools.ant.Project.class.classLoader
configurations.antEjbJarTaskDependenciesConfig.each { File f ->
antClassLoader.addURL(f.toURI().toURL())
}

In dependencies.gradle
ext.libs = [
ant :[ ‘org.apache.ant:ant:1.9.3’,
‘ant:ant-optional:1.5.2’,
‘org.apache.bcel:bcel:5.2’
]
]

This way it can load all teh ant jars we require and is able to execute ant tasks