IntelliJ pulling in maven-enforcer-plugin without it being explicitly part of the pom.xml - maven

When doing a build from IntelliJ I get the error saying
org.apache.maven.plugins.enforcer.RequireMavenVersion failed with message:
Detected Maven Version: 3.3.9 is not in the allowed range 3.6.0.
My maven Version is 3.3.9 and this is the one I want to stick to. I do recall when opening IntelliJ for the first time, going through a UI which asked me to specify a minimum and a maximum version for Maven and I did indeed specify 3.6 as a minimum. However I struggle to find the same settings at this point. Can someone point me to where IntelliJ's settings for Maven version boundaries are?
I'm using IntelliJ 2017.3.5

You can try this path
-> Menu > Preferences > Type: Maven or Go to Building, Execution: Maven > select your version - 3.3.9 from Maven home directory: dropwdown
Make sure you downloaded and set maven environment as global variables on your PC

Related

Having Maven Plugins in IntelliJ IDEA without Maven Installation in Computer

I just started to use Maven and IntelliJ IDEA.
I imported a project into IntelliJ IDEA which requires Maven. I didn't install Maven to my computer but I have 2 plugins in IntelliJ IDEA named as "Maven" and "Maven Extension". And the code I have is running without any dependency problem.
In that case, do I still need to install Maven from the web or just the plugins in the IntellJ are enough for projects with Maven?
Can we say that for every project? If someone can explain the logic behind I would be very happy.
Thanks a lot!
Intellij comes with a bundled version of Maven (see File -> Settings -> Build, Execution, Deployment -> Build Tools -> Maven; the property 'Maven home directory' on that screen by defaults points to 'Bundled (Maven 3)').
You don't have to, but you can still install your own version of Maven, and point that property to it. It has the advantage of being able to run maven from the command-line, which is a better guarantee of build-stability (i.e. building the same project in different environments with the same result) than building directly inside of your IDE. And often is way more helpful in investigating build problems.

How to fix 'Missing requirement' error in Maven on Windows

I'm trying to build dbeaver and get the following error when running mvn package:
[ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: org.jkiss.dbeaver.slf4j 1.0.0.qualifier
[ERROR] Missing requirement: org.jkiss.dbeaver.slf4j 1.0.0.qualifier requires 'bundle org.slf4j.api 0.0.0' but it could not be found
I'm running on Windows 10 and using apache-maven-3.6.1. The strange thing is that when I try the same steps on Linux it builds without problem.
Update
Possible cause is maven 3.6.1 https://www.eclipse.org/lists/tycho-user/msg08177.html
Original post
The problem here, I presume, is that https://dbeaver.io/eclipse-repo/ p2 site is missing slf4j bundle and Tycho (?) cannot resolve the requirement. I still do not know how to make standalone maven build work, but here is an ugly workaround on how to build Windows binary with Eclipse (and embedded maven).
You can use p2-maven-plugin to build that missing bundle yourself. Instead of setting up a brand new project, you can temporarily modify product\localRepository\pom.xml to have a single artifact like
...
<artifacts>
<artifact><id>org.slf4j:slf4j-api:1.7.26</id></artifact>
</artifacts>
...
Now build that (product\localRepository\) project and start jetty
mvn p2:site
start mvn jetty:start
Now you can add this interim update site (http://localhost:8080/site/) to your Eclipse installation (Help -> Install New Software) and install slf4j. You should already be able to run DBeaver from within Eclipse.
To build a binary, add this interim repo into main pom.xml file, e.g. right after local-contrib one.
<repository>
<id>more</id>
<url>http://localhost:8080/site/</url>
<layout>p2</layout>
</repository>
Then go to Run Configurations -> Maven Build -> dbeaver, enter package goal and tick Skip Tests, click Run and go have some coffee.
As you can see Eclipse uses some sort of embedded maven runtime, so I guess it resolves things differently.
Note that if you are updating your local git repo, you might need to update your Eclipse project big time. I was unable to do it with right clicking on the project -> Configure -> Configure and Detect Nested Projects :( But deleting Eclipse project and nested projects (without deleting underlying files) and re-importing Maven project did the trick for me.
There is also an open issue for this https://github.com/dbeaver/dbeaver/issues/6115 .

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.

Has IntelliJ IDEA downloaded the Maven automatically?

My question is a little different from Setup Maven for IntelliJ 13.
My IntelliJ IDEA version is 14.0.3, and I didn't download any Maven in my computer before. I can create Maven project well, but the maven home directory is empty:
and the Maven menu doesn't contain clean, compile, package ...,
If the IntelliJ IDEA has built-in Maven, where is the Maven?
So, it seems that IntelliJ IDEA hasn't downloaded the Maven itself and I should download it and set the M2_HOME manually, right ?
Yes, you have to download and install a Maven distribution manually. As far as I know, IntelliJ doesn't do it automatically. As for the "Maven home directory" field, my preference is to explicitly choose the directory where Maven was installed, rather than setting a global "M2_HOME" environment variable.

Maven 2 is Still Alive : Even after setting Maven3

And i got a requirement, converting a Maven 2 project to Maven 3. So i downloaded Maven 3.2.1 and edited the Maven path to 3.And also changed Maven installation in eclipse to point Maven 3.
But when i run my project in eclipse, it is still taking maven 2 plugins. Could you please help me with this ?
Versions are just versions, there's no real relation between the Maven version and the plugin version. Actually, the Maven team tried to keep the maven-plugins as much as possible compatible with Maven3.
https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Plugin+Compatibility+Matrix shows the list of maven plugins and from which version they can be used with Maven3. Only the Maven-site-plugin required a major release, since it had to adopt the reporting part which has been removed with Maven3.

Resources