# @InputFile annotation - should path be relative or absolute

**URL:** <https://discuss.gradle.org/t/inputfile-annotation-should-path-be-relative-or-absolute/15630>\
**Category:** Help/Discuss\
**Created:** [March 31, 2016, 8:12pm UTC](https://discuss.gradle.org/t/inputfile-annotation-should-path-be-relative-or-absolute/15630 "2016-03-31T20:12:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sc1478](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/sc1478/32/4341_2.png) [@sc1478](https://discuss.gradle.org/u/sc1478)\
**Post date:** [March 31, 2016, 8:12pm UTC](https://discuss.gradle.org/t/inputfile-annotation-should-path-be-relative-or-absolute/15630/1 "2016-03-31T20:12:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mark\_vieira](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/mark_vieira/32/5396_2.png) [@mark\_vieira](https://discuss.gradle.org/u/mark_vieira)\
**Post date:** [March 31, 2016, 9:07pm UTC](https://discuss.gradle.org/t/inputfile-annotation-should-path-be-relative-or-absolute/15630/2 "2016-03-31T21:07:27Z")

</div>

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')
}
```
