@InputFile annotation - should path be relative or absolute

I’ve tried using a relative file path assuming a base of the root directory of the project and it fails with not being able to find the file.

How would I use the @InputFile annotation specifying a path relative to the project’s base directory?

The @InputFile annotation has to be placed on an instance of File. Relative vs absolute is only an issue when you are creating the file instance, in which case you should be using the Project.file() method.

class MyTask extends DefaultTask {
    @InputFile
    File myInput
}

task foo(type: MyTask) {
    myInput = file('dir/relativeTo/projectDir/input.txt')
}