Custom Gradle Plugin- Calling a script file from the Consumer's side

I’ve built a custom plugin, which I’ve deployed to a few users. I have a task that needs to send an email, and does so through the CLI, by calling cmd and then locating a vbscript which in turn executes the send email logic. I do not want to have to copy and paste this vbscript throughout the several different projects.
However, I’m completely stuck on how to find the path to this vbscript, when in the user’s project. Is there a way to access the vbscript when it is packaged into the plugin?

If you put the file in src/main/resources of the plugin then it will be packed into the plugin jar and available on the plugin classpath.

You could then copy it to a local file under $buildDir to run it. You’d likely access the resource via the plugin classloader. Eg

InputStream in = MyPlugin.classloader.getResourceAsStream('path/myscript.vb') 
1 Like

Thanks, I will try this path also. But my workaround was just writing a task that created and wrote the script to the file on the user’s directory.