Skip to content
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

Open
ctwise opened this issue Aug 20, 2017 · 4 comments
Open

[gradle] Accessing files in build directory #279

ctwise opened this issue Aug 20, 2017 · 4 comments

Comments

@ctwise
Copy link

ctwise commented Aug 20, 2017

[provide a description of the issue]

Environment
  • Operating System: macOS Sierra
  • JDK version: JDK 8
  • Visual Studio Code version: 1.15
  • Java extension version: 0.8.0
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:

def buildNumber = new File("build.num").text.toInteger() + 1

It looks like gradle isn't being run in the same directory as the build.gradle file. So I changed the code to this:

def buildNumber = new File("${projectDir}/build.num").text.toInteger() + 1

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
@fbricon
Copy link
Collaborator

fbricon commented Aug 24, 2017

Please provide a standalone project reproducing this issue.
Can you try the same steps in Eclipse with Buildship installed?

@ctwise
Copy link
Author

ctwise commented Aug 24, 2017 via email

@fbricon fbricon added the Gradle label Aug 24, 2017
@fbricon fbricon changed the title Accessing files in build directory [gradle] Accessing files in build directory Aug 25, 2017
@fbricon
Copy link
Collaborator

fbricon commented Aug 25, 2017

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.

@badsyntax
Copy link

@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 cwd does not match the project dir.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants