Determine projectName for VS Code launch from maven projects
Asked Answered
S

2

5

I am working in a complex project structure of bundles and plugins for karaf.

When attaching to the process, I cannot use WATCH as the project cannot be found:

Cannot evaluate because of java.lang.IllegalStateException: Project XY cannot be found..

Is it possible to determine the correct project name from the file the breakpoint is in and the maven file its contained in?

For some reason the content inside XY does not work.

This is the launch config:

"version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "Debug Karaf",
            "projectName" : "XY",
            "request": "attach",
            "hostName" : "localhost",
            "port": 5005
        }
    ]

Edit: Breakpoints and step by step debugging do work. Its strange that these two things are different.

Sutphin answered 30/6, 2020 at 8:3 Comment(0)
S
5

The project name XYZ that worked for me was in the pom building the jar file under artifactId: <artifactId>XYZ</artifactId>.

Sutphin answered 11/11, 2020 at 9:3 Comment(0)
M
2

Right-click on a Java file (one without a main() function) and choose "Run Java" and you'll get a prompt with a few options. This prompt will show the project name.

pop-up menu when Java file is not executable

As you can see in this screenshot of this Ant project, sometimes the project name is unpredictable.

Malliemallin answered 14/3, 2022 at 1:9 Comment(2)
the question is about maven projects, so I don't understand the point of the answerSutphin
@Sutphin It's a way to find projectName, regardless of whether it is a Maven project or not. As you know, StackOverflow encourages canonical answers which may be useful to future readers. This is one of those.Malliemallin

© 2022 - 2024 — McMap. All rights reserved.