Skip to content

Commit 4f177e6

Browse files
authored
Set up VS Code for debugging Java and Frontend (#825)
1 parent 1353b50 commit 4f177e6

File tree

7 files changed

+139
-9
lines changed

7 files changed

+139
-9
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,4 @@ src/main/webapp/js/bundles
2121
.project
2222
.factorypath
2323

24-
# VS Code project files
25-
.vscode
26-
2724
*.dylib

.vscode/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Based on https://github.com/github/gitignore/blob/f752d0799fb7e690bfb888d5cd4d453d2858a865/Global/VisualStudioCode.gitignore
2+
3+
*
4+
!.gitignore
5+
!settings.json
6+
!tasks.json
7+
!launch.json
8+
!extensions.json
9+
!*.code-snippets

.vscode/extensions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["vscjava.vscode-java-pack", "vitest.explorer"]
3+
}

.vscode/launch.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"version": "2.0.0",
3+
"configurations": [
4+
{
5+
"name": "Debug Frontend",
6+
"type": "chrome",
7+
"request": "launch",
8+
"preLaunchTask": "Run Jenkins",
9+
"url": "http://localhost:8080/jenkins",
10+
"pathMapping": {
11+
"/jenkins/plugin/pipeline-graph-view": "${workspaceFolder}/src/main/webapp"
12+
}
13+
},
14+
{
15+
"name": "Debug Java",
16+
"type": "java",
17+
"request": "attach",
18+
"preLaunchTask": "Run Jenkins",
19+
"hostName": "localhost",
20+
"port": 8000
21+
}
22+
],
23+
"compounds": [
24+
{
25+
"name": "Debug All",
26+
"configurations": ["Debug Java", "Debug Frontend"]
27+
}
28+
]
29+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"java.compile.nullAnalysis.mode": "automatic"
3+
}

.vscode/tasks.json

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "Run Jenkins",
6+
"type": "shell",
7+
"command": "mvn hpi:run -Dskip.npm -P quick-build",
8+
"options": {
9+
"env": {
10+
// Do not wait for debugger to connect (suspend=n), unlike mvnDebug
11+
"MAVEN_OPTS": "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000"
12+
}
13+
},
14+
"dependsOn": ["Build Frontend"],
15+
"presentation": {
16+
"focus": true,
17+
"panel": "dedicated",
18+
"clear": true
19+
},
20+
"isBackground": true,
21+
"problemMatcher": [
22+
{
23+
"pattern": [
24+
{
25+
"regexp": "\\b\\B",
26+
"file": 1,
27+
"location": 2,
28+
"message": 3
29+
}
30+
],
31+
"background": {
32+
"activeOnStart": true,
33+
"beginsPattern": ".*INFO.*Started initialization.*",
34+
"endsPattern": ".*INFO.*Jenkins is fully up and running.*"
35+
}
36+
}
37+
]
38+
},
39+
{
40+
"label": "Build Frontend",
41+
"type": "shell",
42+
"command": "npm run build:dev",
43+
"group": "build",
44+
"presentation": {
45+
"focus": true,
46+
"panel": "dedicated",
47+
"clear": true
48+
},
49+
"isBackground": true,
50+
// https://github.com/vitejs/vite/discussions/20164
51+
"problemMatcher": [
52+
{
53+
"pattern": [
54+
{
55+
"regexp": ".",
56+
"file": 1,
57+
"location": 2,
58+
"message": 3
59+
}
60+
],
61+
"background": {
62+
"activeOnStart": true,
63+
"beginsPattern": ".*build started*",
64+
"endsPattern": ".*built in.*"
65+
}
66+
}
67+
]
68+
}
69+
]
70+
}

CONTRIBUTING.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,39 @@ Prerequisites: _Java_ and _Maven_.
3636

3737
```console
3838
$ java -version
39-
openjdk 17.0.13 2024-10-15
40-
OpenJDK Runtime Environment (build 17.0.13+11-Ubuntu-2ubuntu124.04)
41-
OpenJDK 64-Bit Server VM (build 17.0.13+11-Ubuntu-2ubuntu124.04, mixed mode, sharing)
39+
openjdk version "21.0.7" 2025-04-15 LTS
4240
```
4341

44-
- Ensure Maven >= 3.9.9 is installed and included in the PATH environment variable.
42+
- Ensure Maven >= 3.9.9 is installed and included in the `PATH` environment variable.
4543

4644
```console
47-
mvn --version
45+
$ mvn -version
46+
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
4847
```
4948

5049
### IDE configuration
5150

52-
See [IDE configuration](https://jenkins.io/doc/developer/development-environment/ide-configuration/)
51+
See [IDE configuration](https://jenkins.io/doc/developer/development-environment/ide-configuration/).
52+
53+
### Debugging in Visual Studio Code
54+
55+
This repository comes preconfigured for debugging in [Visual Studio Code](https://code.visualstudio.com/). Beyond Java and Maven, you will need:
56+
57+
- The [recommended extensions](./.vscode/extensions.json) for Visual Studio Code
58+
- Node.js and NPM installed and in `PATH` (check recommended versions in [`pom.xml`](./pom.xml) > `properties`)
59+
- Frontend dependencies installed with `npm install`
60+
61+
Then, in the [_Debug_ view](https://code.visualstudio.com/docs/debugtest/debugging), you can select between:
62+
63+
- _Debug Frontend_ to debug the frontend code in a browser
64+
- _Debug Java_ to debug the Java code
65+
- _Debug All_ to debug both at the same time
66+
67+
When launching one of these, Visual Studio Code will automatically start the required tasks, such as `npm run build:dev` and `mvn hpi:run -Dskip.npm -P quick-build`.
68+
69+
https://github.com/user-attachments/assets/709e29b4-ac1c-47da-bcc4-30eda7dcc266
70+
71+
Both frontend and Java tests can also be ran and debugged through the [Test view](https://code.visualstudio.com/docs/debugtest/testing).
5372

5473
### CLI
5574

0 commit comments

Comments
 (0)