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

Working directory is wrong when executing an ant taskdef task. #834

Open
rogerlittin opened this issue Jan 29, 2021 · 2 comments
Open

Working directory is wrong when executing an ant taskdef task. #834

rogerlittin opened this issue Jan 29, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@rogerlittin
Copy link

Extension Name: vscode-gradle
Extension Version: 3.5.2
OS Version: MacOS 10.15.7
VSCode version: 1.5.2

Description
I have an ant taskdef that retrieves some git information and I am executing it from a gradle task. When I run the task from a bash console, I get the correct output, but when I run it from the vscode-gradle tasks extension, I get an error from git.
Error: fatal: not a git repository (or any of the parent directories): .git

I have added logging to the ant taskdef class, before the git command is executed, and I can see that the vscode-gradle extension is executing the ant task from the .gradle/daemon/6.7/ in my home folder instead of the project folder.

vscode-gradle: Current Working Dir: /Users/roger/.gradle/daemon/6.7/

Command line: Current Working Dir: /Users/roger/path/to/project/

To Reproduce
Create an class that extends org.apache.tools.ant.Task and have that class log the current working directory.
Create a gradle task that uses the ant task.
Execute the task from the vscode-gradle tasks list.
it should print out the Gradle User Home path instead of the project path
Executing the same task from the command line prints out the project path.

Expected behavior
The ant task should execute from the project directory

Does the bug still exist if you disable all other extensions?
not tested

@rogerlittin rogerlittin added the bug Something isn't working label Jan 29, 2021
@badsyntax
Copy link
Collaborator

This is related to #245 and #332

The problem is that I can't change the gradle working directory, so gradle will inherit the working directory from the java process that calls the gradle api.

So one potential fix, as shown in the PR above, is to set the working directory to the project directory when starting the gradle server. This will fix all relative path issues, but presents some problems for multi-root workspaces (eg, which project root do i start the server in? should i start one server for each multi-root project?)

I just need to think about the best approach for multi-root workspaces and then i'll add a fix for this.

@badsyntax
Copy link
Collaborator

Although your case seems a little different, i'm surprised the working directory is /Users/roger/.gradle/daemon/6.7/. Either way, I will fix the gradle server cwd issue and we'll see if that resolves it for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants