Using .class inside jars in gradle scripts

Hi,

I am currently trying to use a .class inside a jar file in my gradle script. I have a directory like this:

[root]
    lib
        extJar.jar
            extClass.class
    build.gradle

I tried doing something like this in my task but it had an error:

dependencies {
    runtime fileTree("lib) {
        include "extJar.jar"
    }
}

task myTask {
    def extclass = new extClass()
    extClass.initStuff();

    def myClass = new myClass(extclass); 
    myClass.doStuff();

}

But have the error when executing it:

unable to resolve class extClass

Can anyone advice how can I include it properly (if possible)?

you would need to declare the dependency within the buildscript block to add it to the classpath of the build:

buildscript {
    dependencies {
         classpath fileTree("lib) {
             include "extJar.jar"
         }
    } 
}

further information on this can be found here: https://docs.gradle.org/current/userguide/userguide_single.html#applyPluginBuildscript

cheers,
René

thanks a lot, this solve my problems