# Gradle build path in Eclipse

**URL:** <https://discuss.gradle.org/t/gradle-build-path-in-eclipse/5188>\
**Category:** Old Forum Archive\
**Created:** [December 2, 2014, 10:41pm UTC](https://discuss.gradle.org/t/gradle-build-path-in-eclipse/5188 "2014-12-02T22:41:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![roma77](https://avatars.discourse-cdn.com/v4/letter/r/71e660/32.png) [@roma77](https://discuss.gradle.org/u/roma77)\
**Post date:** [December 2, 2014, 10:41pm UTC](https://discuss.gradle.org/t/gradle-build-path-in-eclipse/5188/1 "2014-12-02T22:41:00Z")

</div>

I have a Gradle build that I want to be able to run in command line and Eclipse. In the build I have a line like this:

String versionNum = new File(‘version’).text

which reads the version of the software that is used for build. This works for when I run it in command line, but when I run from under Eclipse it can’t find the file. I printed the default path from gradle script under eclipse and it is the path where my eclipse is installed, not where the gradle script is located.

How do I go about that - either changing the default path for build in Eclipse or using the location of the gradle script inside of gradle somehow.

---

<div class="post-metadata">

**Author:** ![ghhale](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/ghhale/32/26_2.png) [@ghhale](https://discuss.gradle.org/u/ghhale)\
**Post date:** [December 2, 2014, 11:11pm UTC](https://discuss.gradle.org/t/gradle-build-path-in-eclipse/5188/2 "2014-12-02T23:11:00Z")

</div>

You want to use the file() convenience method:

```gradle
String versionNum = file('version').text

```

This will always be resolved relative to the project directory rather than the working directory.

---

<div class="post-metadata">

**Author:** ![roma77](https://avatars.discourse-cdn.com/v4/letter/r/71e660/32.png) [@roma77](https://discuss.gradle.org/u/roma77)\
**Post date:** [December 2, 2014, 11:17pm UTC](https://discuss.gradle.org/t/gradle-build-path-in-eclipse/5188/3 "2014-12-02T23:17:00Z")

</div>

Thanks, that worked!
