I have a code without main method. The project was executed using the following command:
$mvn clean install -Dparam1="folder" -Dparam2="path"
In Eclipse or IntelliJ, I just need to create a maven executor, define the goas as clean install and pass the maven parameters using the -Dparam format.
In VSCode, I have saw 3 different approaches and experimented the following:
- Create a
lunch.jsonfile calling the commandmvnormvnDebugin thepreLaunchTask.
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"request": "launch",
...
"preLaunchTask": "mvnDebug",
"vmArgs": [ "clean", "install", "-Dparam1=\"blabla\"", "-Dparam2=\"blablabla\"" ]
}
]
}
I also have tested passing all the commands in the preLaunchTask without the vmArgs. And did not work.
- Creating a
task.jsonfile passing the script and alaunch.jsonfile which will call inpreLaunchTaskthe task created with the name defined in the parametertaskNameoftask.json.
{
"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 3rd approache I've tried was using
settings.json:
{
"maven.terminal.favorites": [
{
"alias": "CLEAN COMPILE",
"command": "clean install -Dparam1=\"value\" -Dparam2=\"blabla\"",
"debug": true
},
]
}
For all of them I got the message in the terminal:
Listening for transport dt_socket at address: 56787
What I need from you, guys, is:
- What does this message means?
- Why is it waiting for a port?
- How does VSCode use a socket to do it?
- What is the best approach and why?
- THE MOST IMPORTANT ONE: How to run my JAVA MAVEN parameterized without a main function code using VSCode?
OBSERVATION: My JAVA version is JDK11, but I've tried with JDK 8 too.
Thank you a lot.
