maven-eclipse-plugin with maven 3.8 - eclipse

After migration to jdk11 and maven 3.8.6 , is the plugin maven-eclipse-plugin still useful, knowing that it is noted that it is retired https://maven.apache.org/plugins/maven-eclipse-plugin/
Should i delete this plugin from my pom.xml?
org.apache.maven.plugins
maven-eclipse-plugin
how can i replace it?

Related

Circular Dependencies in Eclipse Platform

I'm trying to add the Eclipse Platform to my Maven project and stumbled over something very weird.
There is the plug-in org.eclipse.swt, which has a dependency org.eclipse.swt.${osgi.platform}, where ${osgi.platform} can be any of the following:
cocoa.macosc.cocoa
gtk.linux.aarch64
win32.win32.x86_64
However if you check the pom.xml of org.eclipse.swt.win32.win32.x86_64 you learn that this project has a dependency to org.eclipse.swt. Which forms a nice dependency circle, which is not allowed in Maven nor in OSGi.
Consequently I'm getting a StackOverflowError, but only if I try to use the maven-dependency-plugin with -Dosgi.platform=win32.win32.x86_64.
If I don't use that parameter I get the following exception:
No versions available for org.eclipse.platform:org.eclipse.swt.gtk.linux.aarch64:jar:[3.105.2,3.105.2]
(Which is probably okay, because I guess that Linux is the default value, but it doesn't apply to me, since I've got a Windows PC.)
I can't exclude the dependency either, e.g. with:
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.swt</artifactId>
<exclusions>
<exclusion>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.swt.gtk.linux.aarch64</artifactId>
</exclusion>
</exclusions>
</dependency>
I get the same error messages as above with that approach.
I'm wondering how the Eclipse guys even managed to release that mess, but more importantly: How do I build against a Maven project with circular dependencies like this?
You're looking at the wrong place. Eclipse artifacts are published in Eclipse p2 repositories. In addition, some Eclipse artifacts will be published in Maven repositories for use in plain (non-Eclipse based) Java applications which cannot be used to build Eclipse-based applications. Something seems to have gone wrong publishing Eclipse SWT to Maven Central causing the circular dependencies. Please report this to Eclipse.
The Eclipse IDE packages are built with the Maven plug-in Tycho. See for example the pom.xml file for the Eclipse platform or here the parent pom.xml for all IDE packages. Tycho uses one or more Eclipse p2 repositories to resolve dependencies. A Maven repository would not work to resolve Import-Package dependencies or product configurations, for example. In a Maven repository, an artifact has a version, while in a p2 repository also Java packages of the same JAR can have different versions. In a Maven Tycho pom.xml only the p2 repositories have to be specified, the dependencies are already declared in the META-INF/MANIFEST.MF, feature.xml and *.product files.

How to use lombok in Eclipse/STS or Intellij Idea?

After lombok dependency add into pom.xml and update repository, it can't work well, IDE could not identify lombok's annotaiton. How could I do?
First step, you need to add lombok dependency in your pom.xml, and update maven dependencies to download lombok.
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
And then, if you use Eclipse/STS as your IDE, you need to install lombok. Close your IDE first, and execute below command:
C:\Users\a243903\.m2\repository\org\projectlombok\lombok\1.16.20>java -jar lombo
k-1.16.20.jar
If you use Intellij Idea as your IDE, you need to install lombok plugin:
Go to File > Settings > Plugins.
Click on Browse repositories...
Search for Lombok Plugin.
Click on Install plugin. Settings -> Compiler -> Annotation
Processors, make sure check box Enable annotation processing
Restart IntelliJ IDEA.
Lombok plugin for IntelliJ is available here:
https://plugins.jetbrains.com/plugin/6317-lombok-plugin
Install it and restart IntelliJ.

How do I make my eclipse project a M2e Maven project

I get the following error message while adding m2e Maven with eclipse:
Cannot complete the install because one or more required items could
not be found. Software being installed: m2e - Maven Integration for
Eclipse (includes Incubating components) 1.6.1.20150625-2338
(org.eclipse.m2e.feature.feature.group 1.6.1.20150625-2338) Missing
requirement: Maven POM XML Editor 1.6.1.20150625-2338
(org.eclipse.m2e.editor.xml 1.6.1.20150625-2338) requires 'bundle
com.google.guava [14.0.1,16.0.0)' but it could not be found Cannot
satisfy dependency:
From: m2e - Maven Integration for Eclipse (includes Incubating components) 1.6.1.20150625-2338 (org.eclipse.m2e.feature.feature.group
1.6.1.20150625-2338)
To: org.eclipse.m2e.editor.xml [1.6.1.20150625-2338]
First check whether you have maven eclipse plugin installed in your eclipse.
For newer version of eclipse use below update site,
http://download.eclipse.org/technology/m2e/releases
For older version of eclipse, for example Indigo use below update site,
http://download.eclipse.org/technology/m2e/releases/1.3
In this case, you have to check the combitability of the plugin and eclipse, as Mars was released a few weeks ago.

Can maven treat WEB-INF\lib the way eclipse (and m2e) does?

I have a servlet/jsp web project which runs fine on eclipse and is exported as war fine (once I clean it that is). I mavenized the project deleting all of the dependencies from the WEB-INF\lib folder except a homebrew jar (the output of another project in the workspace). When I run the package maven goal I get messages for missing classes from this jar:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
#..... NOTICE THIS COMES FROM A CUSTOM JAR
[ERROR] /C:/path/DataServlet.java:[3,30] package xxx.java.helpers does not exist
Now this has been asked before and the most rigorous solution appears to be to create a local repo: Can I add jars to maven 2 build classpath without installing them? (NB: I am at maven 3).
I would like to avoid this - so is there any way maven will just stuff this jar to WEB-INF\lib in the war ?
Solutions that use some maven plugin to cp the contents of the WEB-INF\lib in the war are welcome - although I just have this feeling that there should be a solution that takes into account the "special" nature of this folder.
Observations:
Alt+F5 removes this line:
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
which corresponds to the "Web App libraries" in the Java Build Path. So not only maven refuses to take into account the WEB-INF\lib - it also breaks the build path of eclipse completely.
Related:
Maven: How to include jars in Eclipse, which are not available in repository?
Uses the maven eclipse plugin : update my classpath with an Eclipse User Library via the maven eclipse plugin - not compatible with m2e
How does the m2e eclipse plugin interact with eclipse? - apparently m2e checks the pom then calls the eclipse builders (hence the .classpath is read)
Eclipse maven-enabled web app references workspace projects, but those are not deployed when running Tomcat server
Deploying a Maven project with dependencies to Tomcat or Jboss running within Eclipse
Did you add this jar from WEB-INF\lib as a dependency like this:
<dependency>
<groupId>someGroupId</groupId>
<artifactId>someArtifactId</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/homebrew jar</systemPath>
</dependency>

Setup Tomcat libraries dependencies in maven POM

I am currently migrating our build process from Eclipse/Ant to Maven/M2Eclipse/Artifactory.
I have a Webapp as a WTP project in Eclipse.
I have migrated it to Maven with m2eclipse.
The compilation runs fine from the Eclipse IDE.
However, when I try to compile from Maven CLI (mvn clean & mvn compile), Maven complains about not finding the libraries provided by the Tomcat Environment (like annotations-api, servlet-api, etc, ...).
Fair enough : Indeed, these dependencies are provided by WTP, as Java resources / Libraries / ApacheTomcat6. Maven is not aware of them.
I could deactivate this in the build path, and add each corresponding dependency in my POM, but I'm afraid this would lead Maven to deploy them again in my webapp (WEB-INF/libs).
So, what is the good way to say to maven "this application will run in a well known environment, providing the following libraries ". Is there some common Tomcat POM that I could add as a dependency ?
Thanks in advance for your advice.
regards,
Raphael
One way to handle this is to declare these dependencies with scope provided. These dependencies will be available for compile and test, but will not be packaged by maven into the webapp. For example,
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>