Roman Goyenko
Roman Goyenko

Reputation: 7070

Gradle build path in Eclipse

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.

Upvotes: 0

Views: 966

Answers (1)

roomsg
roomsg

Reputation: 1857

try:

String versionNum = file('version').text

with file() being a method on project, which creates a file object relative to the projectdir.

when using new File(), a file object will be created in the current working dir

Upvotes: 1

Related Questions