2

Since there are no stupid questions, I dare to ask this stupid question. As a beginner at 0, I do not see how to make the step 0, that is, how to stand at the starting point at all.

I stumbled upon a bug in an older Java project that now needs to be tested and debugged in development environment.

It must be built and compiled with Maven by running in the main folder:

  • build: mvn package -Dmaven.test.skip=true
  • compile: mvn compile -Dmaven.test.skip=true

For this, I installed Maven with sudo apt install maven. Up to now, not bad, I can run the jar package (java -jar my_project) that I get from that just from the terminal.

Still, since I know that it is a Maven project, else the build/compile with Maven would not work, I want to set up the project as a Maven project in VSCodium and see whether that can help debugging the project. Up to now, the only debugging I can use is printouts in the console output. I installed the Maven for Java extension:

enter image description here

(and the Language Support for Java(TM) by Red Hat extension) and found a new right-click menu item "Create Maven Project".

enter image description here

That sounds as If to make a new project, but that is not my aim. I need to know how to create such a Maven project from a project that already is a Maven project. How can I just load it?

Shall I make a new empty folder and link to the repository's main folder? I tried this, half-guessing, half-following How to create maven projects on VS code?. I put in some guessed entries in the menu boxes (I later found out that just pressing Enter every time is enough for a quick test start), and I tested it with both of the two first choices for the archetype menu since they seemed the most likely to be able to "take over" the old Maven project into the new Maven project:

  • maven-archetype-quickstart and
  • archetype-quickstart-jdk8

enter image description here

After the end of the menu boxes, the build of the project fails, both of the new project folders stay empty, and I do not know how to get them filled with the old Maven project. From Maven project and Eclipse workspace I guess that I have to somehow point the new project to the old one, and just opening the old Maven project "into" the new one does not seem to be that pointer: a new folder with the dummy name that I gave the new Maven project will just be put in the old project's main folder, the new folder stays empty.

Here is the failing build after choosing maven-archetype-quickstart in the menu screenshot, as an example, which also stands for the other try:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.1.2:generate (default-cli) on project my_project: Unable to add module to the current project as it is not of packaging type 'pom' -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

 *  The terminal process "/usr/bin/bash '-c', 'mvn org.apache.maven.plugins:maven-archetype-plugin:3.1.2:generate -DarchetypeArtifactId="maven-archetype-quickstart" -DarchetypeGroupId="org.apache.maven.archetypes" -DarchetypeVersion="1.4" -DgroupId="com.my_company.my_project" -DartifactId="dev"'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

How to load a chosen Maven project into VSCode/VSCodium using the Maven extension?

questionto42
  • 1,861
  • 3
  • 21
  • 52

1 Answers1

1

This long question has an easy answer.

The project gets loaded without doing anything. Maven finds the pom.xml in the main folder of the old project and adds it to the Maven pane at the bottom left - which I had just overseen, and that new right-click menu was just not needed.

enter image description here

Instead, in a running project, check the pom.xml in the main folder and read Working with POM.xml, and it has anything in it to get things done.

enter image description here

questionto42
  • 1,861
  • 3
  • 21
  • 52