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

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

Open
Tracked by #13192
octopus88888 opened this issue Jan 18, 2024 · 16 comments
Open
Tracked by #13192

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

octopus88888 opened this issue Jan 18, 2024 · 16 comments
Assignees

Comments

@octopus88888
Copy link

octopus88888 commented Jan 18, 2024

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
Copy link
Contributor

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

@msujew
Copy link
Member

msujew commented Jan 18, 2024

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.

@JonasHelming JonasHelming mentioned this issue Jan 18, 2024
63 tasks
@octopus88888
Copy link
Author

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
Copy link
Contributor

I can take a look!

@tsmaeder
Copy link
Contributor

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

@msujew
Copy link
Member

msujew commented Jan 24, 2024

@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
Copy link
Contributor

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
Copy link
Contributor

sgraband commented Feb 6, 2024

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
Copy link
Contributor

tsmaeder commented Feb 6, 2024

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

@tsmaeder
Copy link
Contributor

tsmaeder commented Feb 6, 2024

@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
Copy link
Member

msujew commented Feb 6, 2024

@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
Copy link
Contributor

sgraband commented Feb 6, 2024

@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
Copy link
Contributor

tsmaeder commented Feb 6, 2024

@sgraband the last url is broken.

@sgraband
Copy link
Contributor

sgraband commented Feb 6, 2024

Sorry about that:

const terminal: Process = this.taskTerminalProcessFactory(terminalProcessOptions);
(also fixed it above)

@sgraband
Copy link
Contributor

sgraband commented Mar 7, 2024

@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
Copy link
Contributor

tsmaeder commented Mar 8, 2024

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.

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

No branches or pull requests

5 participants