Open octopus88888 opened 9 months ago
Does this only occur with the Spring Boot archetype or with all templates?
Since the task tries to execute the -DoutputDirectory=file:///c%3A/
argument, I assume there's something wrong with out URI decoding/encoding in this part of the API.
Does this only occur with the Spring Boot archetype or with all templates?
not only occur with the Spring Boot archetype, tried others also get the same error.
I can take a look!
Doesn't this sound like a problem in https://github.com/eclipse-jdtls/eclipse.jdt.ls ?
@tsmaeder I haven't confirmed this bug in vscode yet (I don't do Java coding these days), but I assume it works as expected there. In that case it's probably related to Theia in some way or another.
I just checked. The extension (and command) works in VSCode. So i would assume, that the API that the extension uses does not behave the same in Theia. Probably due to the file path decoding/encoding.
I found where this issue comes from, but i am unsure on how to deal with it:
The extension provides the args for the call like this:
"org.apache.maven.plugins:maven-archetype-plugin:3.1.2:generate",
`-DarchetypeArtifactId="${archetypeArtifactId}"`,
`-DarchetypeGroupId="${archetypeGroupId}"`,
`-DarchetypeVersion="${archetypeVersion}"`,
`-DgroupId="${groupId}"`,
`-DartifactId="${artifactId}"`
Note, that the values for the parameters are wrapped in "
.
This is how the commandLine
value looks for the task on the backend then:
cmd.exe /S /C ""mvn org.apache.maven.plugins:maven-archetype-plugin:3.1.2:generate -DarchetypeArtifactId="spring-boot-blank-archetype" -DarchetypeGroupId="am.ik.archetype" -DarchetypeVersion="1.0.6" -DgroupId="com.example" -DartifactId="demo"""
We use the commandLine
value for tasks on windows.
When i try to run that commandLine statement i get the following error message:
The syntax of the command is incorrect.
As far as i know the /S
argument should remove the first and last "
of a command. So i would expect the following command to work, but for some reason it doesn't (same command as above without duplicate "
):
cmd.exe /S /C "mvn org.apache.maven.plugins:maven-archetype-plugin:3.1.2:generate -DarchetypeArtifactId="spring-boot-blank-archetype" -DarchetypeGroupId="am.ik.archetype" -DarchetypeVersion="1.0.6" -DgroupId="com.example" -DartifactId="demo""
After some testing in the commandline i came to the conclusion that the command works when you either remove the wrapping set of "
:
cmd.exe /S /C mvn org.apache.maven.plugins:maven-archetype-plugin:3.1.2:generate -DarchetypeArtifactId="spring-boot-blank-archetype" -DarchetypeGroupId="am.ik.archetype" -DarchetypeVersion="1.0.6" -DgroupId="com.example" -DartifactId="demo"
(This also works without the /S
argument)
Or if you remove the "
around the arguments.
cmd.exe /S /C "mvn org.apache.maven.plugins:maven-archetype-plugin:3.1.2:generate -DarchetypeArtifactId=spring-boot-blank-archetype -DarchetypeGroupId=am.ik.archetype -DarchetypeVersion=1.0.6 -DgroupId=com.example -DartifactId=demo"
I am unsure on how we should tackle that issue, because other commands will likely need the wrapping "
for them to work correctly, right? Any ideas @tsmaeder or @msujew ?
Just as a note:
During debugging i also found that this.workspaceService.workspace?.resource.toString();
in the getContext()
function of task-service.ts
returns file:///c%3A/<path>
on Windows. It seems to not cause any problems with this extension, but it does not seem correct, does it?
@sgraband why would file:///c%3A/<path>
not be the correct url? Looks like the url-encoded form of c:/<path>
to me.
@sgraband can you give more context on "how the extension provides the args for the call"? Is this a json file, an API call?
@sgraband I'm not sure whether the file URI is correct or not. It might need to return uri.path.fsPath
instead. However, we should take a look at what vscode provides there.
@sgraband why would file:///c%3A/
not be the correct url? Looks like the url-encoded form of c:/ to me.
@tsmaeder might be, like i said it did not have any impact on executing the task, but i am unsure on what is expected there. I looked at this due to the comment and Issue description above that indicated it might have something to do with this. However like @msujew suggested i can take a look on what vscode provides there.
can you give more context on "how the extension provides the args for the call"? Is this a json file, an API call?
I took a look at this function.
I mainly debugged the commandLine
values from above at this line.
@sgraband the last url is broken.
Sorry about that: https://github.com/eclipse-theia/theia/blob/3e7f6eec297c4029ef01b2ef2c8f20361360c48c/packages/task/src/node/process/process-task-runner.ts#L88 (also fixed it above)
@tsmaeder did you already have time to take a look and/or have an idea on how we could tackle this issue? I would have time this month to provide a fix, but like indicated in my earlier comment i am missing an idea on how to solve this issue.
No, sorry, @sgraband I have no idea what the right thing to do is, here. In general, it's a good idea to keep things as objects instead of encoding them into a string for as long as possible, but not sure how that applies to this problem.
Scenario 1: 1) Create Maven Project 2) Select spring-boot-blank-archetype
3) Faced error to create maven project
Scenario 2: Similar error message with command line if provide -DoutputDirectory with invalid path: