M2E in VsCode (or terminal) as Apache Maven Eclipse Plugin has retired - maven

I have to update .classpath, .project and .settings for a Maven project in VS Code. I read that mvn eclipse:eclipse has been retired and I tried that but it doesn't gives me correct files.
How can I use M2E in VScode to regenerate these files? Or, how can I use M2E from the terminal (independent of IDE)?
Reference:
Apache Maven Eclipse Plugin (RETIRED) - Introduction
maven - how to run the command mvn eclipse:eclipse - Stack Overflow

Related

Maven Archetype and no extension files

When creating a maven archetype with "mvn archetype:create-from-project -Darchetype.properties=", all files without extensions are ignored (Like Dockerfile for ex). How to keep these files ?
Maven version: 3.5.2

How to update the version of Maven used by IntellijIdea

I try to open the Maven project in IntellijIdea. This project uses spark and scala. When I run:
mvn clean install -DskipTests
then it gives the error:
[ERROR] Failed to execute goal
org.scalastyle:scalastyle-maven-plugin:0.7.0:check (default) on
project spark-mllib_2.10: Failed during scalastyle execution: You have
50 Scalastyle violation(s)
I think that the problem is in the version of Maven. Indeed in IntellijIdea Settings I have the version Bundled (Maven 3) 3.0.5, while pom.xml defines <maven.version>3.3.3</maven.version>
If I run mvn -version in terminal, it points Maven 3.3.3
So, how can I update the version of Maven used by IntellijIdea?
Install the new version of maven (If not already installed)
Go to File -> Settings and use the search bar to find maven settings
Edit the Maven home directory setting so it points to the installation folder of the desired version
It may sometimes happen that after configuring maven in Intellij and changing as following it does not work by command build, so build it by Intellij maven tool.
Setting > Maven > Importer - select the JDK
Setting > Maven > Runner - select the JRE
After that, try to build by Intellij maven tool instead of Intellij console.

Do we have to include jar files in eclipse project if we are using maven?

I am new to maven.
The POM file in maven contains all the dependencies that we need in our project.
So we don't have to externally add any JAR's to the buildpath in eclipse.Right?
That's right. Maven will download dependencies and M2Eclipse (Eclipse plugin for integrating Eclipse with Maven) will setup a build path for you.
Two Solutions - 1 Using Eclipse IDE
Install the Maven (M2E Eclipse Plugin) if you use older version of eclipse, If you download the latest eclipse.
Point your settings.xml and create a maven project from your eclipse, it is better keep Group Id as com.yourcompany.app Artifact Id as yourProjectName and Version 0.0.1-SNAPSHOT depends on your Architecture Standards set by your company. Also Packaging can be as WAR file for WebApplication, EAR file for Enterprise Application. You can find the numerous list of examples from Maven Site.
2 From Command Line
Install Maven from Apache Maven site, Would recommend to go for the latest version -apache-maven-3.3.9-bin.zip.
Set the Maven Home in the Environment Variables as shown in the below figure.
Edit Your Path variable as %MAVEN_HOME%\bin, verify your installation by using this command from your command prompt. It should display the Maven Home and Java Version, which confirms your maven successful installation.
Paste your settings.xml (C:\apache-maven-3.3.9\conf) given by your build team or Architecture team for accessing your internal repository. And keep a backup of the original settings.xml (which is default download from Maven site)
Run these commands from your command prompt.
mvn eclipse:clean -e
mvn eclipse:eclipse -e (which will automatically set your project build path as shown in the below figure)
It will resolve your compilation issues and your project is ready as an deploy-able artifact

Installing maven and the maven eclipse plugin?

I installed maven from here: http://maven.apache.org/download.cgi
and also installed plugin for eclipse from the eclipse marketplace.
This is a really dumb question, but what's the difference between the two?
both are same thing ? or for differnet purposes ?
do we need both on system ?
Maven itself is the software you can use on your machine. It has nothing to do with Eclipse. You can use it from the command line with the mvn command to execute Maven goals on your projects in the file system.
The Maven Eclipse plugin (m2e) integrates Maven with Eclipse so you can comfortably use Maven functionality from inside Eclipse rather than using Maven as an external tool. The plugin just integrates Maven with Eclipse and needs a Maven installation to work. You can configure the plugin to use the Maven installation on your system but there is no need for one. It can use it's own internal "installation" of the actual Maven software. This would be basically the same as you can download and install yourself but it is integrated with the plugin. It therefor can't be used outside Eclipse.

Using maven jetty plugin in multi-module project under Eclipse

I am working on a simple multi module maven project under Eclipse using m2eclipse with maven 3 and jetty plugin version 7. One of my module is a jar and the other module is a war which has a dependency on the jar.
Even though the workspace dependency resolution is enabled, the call to mvn jetty:run fails if I don't run mvn install before.
Having read about workspace dependency, I am not sure why a call to mvn install is required. I would like to be able to run the jetty plugin without installing the artifacts to my local repository. Is it possible?
Thanks in advance.
There is an integration module between m2eclipse and the WTP (Web Tool Platform).
WTP allow starting Jetty/Tomcat/... from Eclipse, debugging inside Eclipse, redeploy on change,...
Here is it: m2eclipse Extras

Resources