-
Notifications
You must be signed in to change notification settings - Fork 446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[gradle] Accessing files in build directory #279
Comments
Please provide a standalone project reproducing this issue. |
I don't use Eclipse and have no idea what 'Buildship' is.
The issue is that the Gradle build file is apparently being run from some
other directory then the one in which the file is located. So relative file
paths aren't being resolved. Just add this line to a working build.gradle:
def buildNumber = new File("build.num").text.toInteger() + 1
And make sure you have a file named 'build.num' in the same directory as
the build.gradle file, e.g., 'echo 1 > build.num'.
Yes, I realize this is an easy fix for the build.gradle writer. You can
replace that line with:
def buildNumber = new File("${projectDir}/build.num").text.toInteger() + 1
And what's more, it's better practice. I'm fixing my build.gradle files as
we speak. But the build.gradle file _should_ be run from the same directory
it's found in. The relative file approach works in other build tools
(IntelliJ IDEA, Bamboo, etc.).
…On Thu, Aug 24, 2017 at 10:29 AM, Fred Bricon ***@***.***> wrote:
Please provide a standalone project reproducing this issue.
Can you try the same steps in Eclipse with Buildship installed?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#279 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAVhnatRooykKQgTGlCKY2pfqF8vV_Vks5sbYjigaJpZM4O8rsJ>
.
|
So I managed to reproduce the issue with Eclipse, this is definitely an upstream issue in the Buildship project. My wild guess is this is caused by the gradle process running at the workspace level, not the project level. Unless @donat can provide guidance about how to fix it, if it's possible, we won't be able to change that behaviour. |
@fbricon can you describe your understanding of the differences between "workspace" level and "project" level? either way, i would agree with this theory, and reckon the cause of the issue is the java LS process i'd love to know if this is possible to fix in buildship, but I don't think you can configure a "custom cwd" via the gradle tooling api. i've written up some thoughts about supporting relative paths here microsoft/vscode-gradle#332 (comment) and would love some feedback. |
[provide a description of the issue]
Environment
Steps To Reproduce
I track a build number using a text file in the build project directory, e.g., 'build.num'
First, the file can't be found using this code:
It looks like gradle isn't being run in the same directory as the build.gradle file. So I changed the code to this:
Now the 'build.num' file is being found. The same problem exists when referencing any files from a relative location.
Current Result
File Not Found
Expected Result
Build should work the same as if running it from the build directory.
Additional Informations
The text was updated successfully, but these errors were encountered: