Using project class in build.gradle

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Using project class in build.gradle

the_catfishman
This post has NOT been accepted by the mailing list yet.
Hello,

I'm wondering what the best way to handle this is.  What I'd like to do is be able to instantiate and use a java class from my project in the build script for that project.  The class imports other classes from the project as well as external dependencies.  What I'd like is something like:

import com.mypackage.MyClass

task myTask << {
    myObject = new MyClass()
    ....
}

Is this possible?  I've looked at some of the documentation in the Gradle user manual (Chapter 53: Organizing Build Logic), and it's making me think the buildSrc project may be the way to go here, but I can't quite figure out how this would work.

Does anyone have any suggestions?  I would really appreciate it.

Thanks,
John