eclipse-theia / theia

Eclipse Theia is a cloud & desktop IDE framework implemented in TypeScript.
http://theia-ide.org
Eclipse Public License 2.0
20.04k stars 2.5k forks source link

Unable create maven project with latest theia (windows) IDE #13284

Open octopus88888 opened 9 months ago

octopus88888 commented 9 months ago

Scenario 1: 1) Create Maven Project 2) Select spring-boot-blank-archetype image

3) Faced error to create maven project image

Scenario 2: Similar error message with command line if provide -DoutputDirectory with invalid path:

mvn archetype:generate -DarchetypeGroupId=com.nokia.dos -DarchetypeArtifactId=mechanism-driver-archetype -DarchetypeVersion=24.1.2 -DoutputDirectory=file:///c%3A/<path>
...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate (default-cli) on project standalone-pom: java.io.IOException: The file
name, directory name, or volume label syntax is incorrect -> [Help 1]
JonasHelming commented 9 months ago

Does this only occur with the Spring Boot archetype or with all templates?

msujew commented 9 months ago

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.

octopus88888 commented 9 months ago

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.

sgraband commented 9 months ago

I can take a look!

tsmaeder commented 9 months ago

Doesn't this sound like a problem in https://github.com/eclipse-jdtls/eclipse.jdt.ls ?

msujew commented 9 months ago

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

sgraband commented 9 months ago

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.

sgraband commented 8 months ago

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?

tsmaeder commented 8 months ago

@sgraband why would file:///c%3A/<path> not be the correct url? Looks like the url-encoded form of c:/<path> to me.

tsmaeder commented 8 months ago

@sgraband can you give more context on "how the extension provides the args for the call"? Is this a json file, an API call?

msujew commented 8 months ago

@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 commented 8 months ago

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

tsmaeder commented 8 months ago

@sgraband the last url is broken.

sgraband commented 8 months ago

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)

sgraband commented 7 months ago

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

tsmaeder commented 7 months ago

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.