Skip to content

[gradle] Accessing files in build directory #279

Closed

Description

@ctwise

[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

Activity

  1. fbricon commented on Aug 24, 2017

    @fbricon
    Collaborator

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

  2. ctwise commented on Aug 24, 2017

    @ctwise
    Author
  3. changed the title [-]Accessing files in build directory[/-] [+][gradle] Accessing files in build directory[/+] on Aug 25, 2017
  4. fbricon commented on Aug 25, 2017

    @fbricon
    Collaborator

    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.

  5. badsyntax commented on May 5, 2020

    @badsyntax

    @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.

  6. robstryker commented on Oct 28, 2026

    @robstryker
    Contributor

    This issue seems to be an upstream issue. See microsoft/vscode-gradle#245

    Closing this issue now.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions