I have the following structure for my build:
build.gradle buildSrc src main groovy data script.tcl MyExtension.groovy
The buildSrc directory contains task extensions reused by several projects. MyExtension.groovy calls an executable which requires an absolute path to buildSrc/src/main/groovy/data/script.tcl.
Right now I simply assume the working dir is the project root (where build.gradle is located) and call:
def scriptPath = new File("buildSrc/src/main/groovy/data/script.tcl").getAbsolutePath ()
To get the absolute path of my script from MyExtension.groovy , but this feels a bit awkward.
Is there any other way to get the path of the script at execution time? Or is there a better way of dealing with situations like these?
The code in build.gradle should not be aware of the existence of the script file and/or data directory, it just executes the task extension in MyExtension.groovy.