2
I have a code with no main method. The project is executed using the following command:
$mvn clean install -Dparam1="folder" -Dparam2="path"
In Eclipse or Intellij, I just need to create a Maven executor, set the goals as clean installation
and pass the parameters of the Maven at the right place.
In Vscode, I saw three different approaches and tried them:
- Creating a file
launch.json
calling the commandmvn
inpreLaunchTask
.
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"request": "launch",
...
"preLaunchTask": "mvnDebug",
"vmArgs": [ "clean", "install", "-Dparam1=\"blabla\"", "-Dparam2=\"blablabla\"" ]
}
]
}
I also tried to pass all commands on prelaunchTask
without the parameter vmArgs
. And it didn’t work.
- Creation of a
task.json
passing the script, and alaunch.json
who will call onprelaunchTask
the task created with the name defined in the parameter"taskName"
of the task.
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"request": "launch",
"preLaunchTask": "Debug",
"name": "Launch Program",
"sourceMaps": true
}
]
And the tasks.json
:
{
"version": "2.0.0",
"tasks": [
{
"label": "Debug",
"type": "java",
"script": "mvnDebug clean install -Dparam1=\"folderName\" -Dparam2=\"blablabla\"",
"problemMatcher": []
}
]
}
The third approach I used is through settings.json
:
{
"maven.terminal.favorites": [
{
"alias": "CLEAN COMPILE",
"command": "clean install -Dparam1=\"value\" -Dparam2=\"blabla\"",
"debug": true
},
]
}
For all of them I got the result in terminal:
Listening for transport dt_socket at address: 56787
What I need is:
- What does this mean? Why are you waiting for a port? How does Vscode use a socket to do this?
- What is the best approach and why?
- How to run my code in Vscode? This is the most important one! I need to run my code.