microsoft / microsoft/vscode-cmake-tools
Using the same launch configuration for more than one Java target
- Dominant language
- TypeScript
- Stars
- 1.7k
- Forks
- 546
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 32
Description
### Brief Issue Summary
Background: We have a large number of Java examples. We would like one launch configuration to cover them all.
For one of the examples we have the following CMakeList.txt (some details are not shown):
```
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "")
project (java01Example VERSION 0.99 DESCRIPTION "A simple Java example" LANGUAGES Java)
find_package (RDM 16.1.0 REQUIRED)
find_package(Java 1.8)
include(UseJava)
add_jar(java01Example ENTRY_POINT java01Example_main
MANIFEST ${CMAKE_CURRENT_BINARY_DIR}/CLASS_PATH.txt
SOURCES java01Example_main.java
)
```
The jar target can be executed using the following command
(the class path and the main class has been embedded into the jar file's manifest):
`java -jar java01Example.jar`
We can launch this with the following launch configuration:
```
"launch": {
"configurations": [
{
"type": "java",
"name": "Debug RDM Java Example",
"request": "launch",
"args": "",
"vmArgs": "-jar ${command:cmake.buildDirectory}/java01Example.jar",
"cwd": "${command:cmake.buildDirectory}"
}
]
}
```
There are two issues with this launch configuration that CMake Tools is not able to accommodate:
1. The target is not automatically built when launching
2. The launch configuration is not generic as it is tied to one particular example
We would like `java01Example.jar` in the launch configuration to be replaced with a variable that expands to the selected build target and the target should also be built.
For our C/C++ examples this is not a problem as we can use `${command:cmake.launchTargetPath}`. However, for Java there is no way to accommodate this as far as I can tell. Since we have several examples, we would like to have one launch configuration to cover them all.
### CMake Tools Diagnostics
```shell
```
### Debug Log
```shell
```
### Additional Information
_No response_
Contributor guide
Research direction
Start with CMake Tools' launch configuration handling and compare the requested Java behavior with the existing `${command:cmake.launchTargetPath}` flow. Done means one launch configuration can select and build the chosen Java target, then launch its corresponding JAR without naming `java01Example.jar`.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, java
- Domain
- build-system, developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100