I have a Gradle plugin with a task:
@TaskAction
def nyTask() {
def myFlags = project.pluginConfig.myFlags
if myFlags == null {
myFlags = "-arg1 absolutePathToFile/file1.txt -arg2 absolutePathToFile/file2.txt"
// *** this is the part I don't know ***
}
project.exec {
executable aCommand
args myFlags.split()
}
}
myFlags
is defined in the plugin's extension. When using the plugin I can configure it like:
myPlugin {
myFlags = "-arg1 absolutePathToFile/file1.txt -arg2 absolutePathToFile/file2.txt"
}
I have some default files in the plugins src/main/resources/
folder, i.e.,
src/main/resources/file1.txt
src/main/resources/file2.txt
If myFlags == null
then I want to use the files from the resource folder.
The problem is that I do not know how to get the correct path to these files.
How do I get the absolute path to the file1.txt and file2.txt in the plugin's resource folder?