Enable Maven support IntelliJ IDEA 2022 - maven

I just updated IntelliJ IDEA from 2021.3 to 2022.1, and it appears I lost maven support.
I have a scala plugin, which was automatically installed, but I've never had to do anything to have the option to build a project as a maven project, but now that option is gone. The new menu format offers me native IntelliJ, or Gradle.
If I look for plugins, there are a ton of them, but they all appear to be "extra features", and none of them (that I can see, it's hard to be sure with so many) are actually core JetBrains tools (which I would expect this to be).
Here is the new project window, offering IntelliJ and Gradle build systems, but not maven. The IntelliJ page shows a screenshot of this page that includes maven.
Since I suspect this will be the next question from kind folks trying to help, here's the window I get if I try to "add framework support" to the project:
Again, Maven's not on the list.
Also, FWIW, this is my command line:
$ mvn --version
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /home/simon/apache-maven-3.8.1
Java version: 17.0.1, vendor: Eclipse Adoptium, runtime: /usr/local/jdk-17.0.1+12
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-117-generic", arch: "amd64", family: "unix"
What can I try next?

You can add Maven framework to your module by right clicking the module -> Add Framework Support and selecting Maven.

(Posted solution on behalf of the question author, to move it to the correct place).
The solution, courtesy of the IntelliJ forum, is that for reasons I didn't ask about, the installation had a file "disabled_plugins.txt" which explicitly named Maven. This file was in the config directory, and for me, on Linux, was: ~/.config/JetBrains/IdeaIC2022.1/disabled_plugins.txt.
Deleting that file and restarting allows everything to work as expected.

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 do you compile Maven projects with IntelliJ?

I'm using windows, and I am having trouble understanding how to compile this source. https://github.com/Maxcloud/Mushy
Please if you can help that would be great :)
I think the Readme expects you to be using ubuntu or a linux.
You can use File | New | Project from Existing Sources to import a maven project in IntelliJ. See also the documentation.
If you are using intelliJ you can use the maven tab located to the right of your IDE and within that you will have access to all the maven commands, specifically install for building your dependencies.
**NOTE*
You will need a valid POM and you will have to tell IntelliJ about it if it doesn't know.

pom error - org.apache.maven.archiver.MavenArchiver.getManifes

I am getting error in pom file - org.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.MavenProject, org.apache.maven.archiver.MavenArchiveConfiguration)
in my pom i am using maven-war-plugin 3.0.0 , IDE- STS , java 7
encountered the same issue after updating the maven-jar-plugin to its latest version (at the time of writing), 3.0.2.
Eclipse 4.5.2 started flagging the pom.xml file with the org.apache.maven.archiver.MavenArchiver.getManifest error and a Maven > Update Project.. would not fix it.
Easy solution: downgrade to 2.6 version
Indeed a possible solution is to get back to version 2.6, a further update of the project would then remove any error. However, that's not the ideal scenario and a better solution is possible: update the m2e extensions (Eclipse Maven integration).
Better solution: update Eclipse m2e extensions
From Help > Install New Software.., add a new repository (via the Add.. option), pointing to any of the following URLs:
https://otto.takari.io/content/sites/m2e.extras/m2eclipse-mavenarchiver/0.17.2/N/LATEST/ or
http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-mavenarchiver/0.17.2/N/LATEST/
Then follow the update wizard as usual. Eclipse would then require a restart. Afterwards, a further Update Project.. on the concerned Maven project would remove any error and your Maven build could then enjoy the benefit of the latest maven-jar-plugin version.
Additonal notes
The reason for this issue is that from version 3.0.0 on, the concerned component, the maven-archiver and the related plexus-archiver has been upgraded to newer versions, breaking internal usages (via reflections) of the m2e integration in Eclipse. The only solution is then to properly update Eclipse, as described above.
Also note: while Eclipse would initially report errors, the Maven build (e.g. from command line) would keep on working perfectly, this issue is only related to the Eclipse-Maven integration, that is, to the IDE.
Upgrade your m2e extensions instead downgrade.
(In Eclipse IDE) From Help > Install New Software.., add a new repository (via the Add.. option)
Specify name for your plugin and add path http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-mavenarchiver/0.17.2/N/LATEST/
once you are done with installation, please restart eclipse and update your project.

Broadleaf commerce Adding maven home in build.properties file

I am trying to run the Broadleaf Demosite project in eclipse. I have setup the Demosite by following the instructions from the
Getting started guide from broadleaf site. The default code in the build.properties file inside the Demosite maven parent project shows this,
#required
maven.home=/usr/share/maven
#optional
jrebel.path=/usr/lib/jrebel/jrebel.jar
As maven.home is required to start up the server and so now that I have downloaded and extracted the maven 3.0.4 in C:\Users\admin\Downloads\apache-maven-3.0.4\lib.
What is the path I have to specify in the maven.home line in the properties file,
Should it be something like this?
maven.home=C:\User\admin\apache-maven-3.0.4\lib
Maven is shipped into a .zip archive. So unzip maven where do you want. Let's say somewhere like :
C:\User\admin\apache-maven-3.0.4\
then set into your build.properties
maven.home=C:/User/admin/apache-maven-3.0.4
and this should work.
I just changed the maven.home to point to the path like this,
maven.home==/Users/admin/Downloads/apache-maven-3.0.4
Download maven and extract it wherever you want in you computer. Set the path to that directory using command prompt,
C:\Users\admin>set PATH="c:\Users\admin\downloads\apache-maven-3.0.4\bin";%PATH%
Now I'm able to start the jetty server in eclipse with BUILD SUCCESS.
UPDATE:
As the above solution only works for once and you need to run that command every-time you restart the system. For it to work always you have to set the PATH environment variable for maven. Look at How to install maven in Windows? for a permanent solution. Once installed run the following to check if you have installed maven correctly and to check other variables are properly set.
CMD PROMPT
C:\Users\admin>mvn -version
Apache Maven 3.0.4 (r1232337; 2012-01-17 14:14:56+0530)
Maven home: c:\Users\admin\Downloads\apache-maven-3.0.4\bin\..
Java version: 1.6.0_32, vendor: Sun Microsystems Inc.
Java home: C:\Program Files\Java\jdk1.6.0_32\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
C:\Users\admin>
If all the above works fine then in the properties file, you have to specify the maven home directory which in my case was,
C:/Users/admin/Downloads/apache-maven-3.0.4
Sometimes the single forward slash(/) doesn't work in Windows, so replace it with double-forward slash(//) and that should work.
Default value in build.properties file:
#required
maven.home=/usr/share/maven
You have to follow the below format:-
#required
maven.home=C://Program Files//apache-maven-3.0.5-bin//apache-maven-3.0.5

IntelliJ steps through the wrong lines when debugging remote Java application

I tried to remote debug a maven plugin for a liquibase project with Intellij. IDEA is highlighting the wrong source code line.
I manually built and installed the plugin in my local maven repository from sources in my Intellij project. Intellij version is 11.1.3 and maven version is 3.0.4 running on Ubuntu 12.04.
For debugging the maven plugin I used mvnDebug comand.
If someone has any ideas please give me some advice. I'm not too used to remote debugging (in fact this is the second time I've done this).
For me, whenever IntelliJ is highlighting the wrong line, it was always because the version of the JAR/classes being used to run the application differs from my source files - i.e. different version of the sources were used to build the JAR and/or classes.
You are going to have to be sure that you are working from the exact source that was used to build the classes you are debugging.
You can verify this by looking at the classpath being used to launch the application, locating the JAR file or classes directory that contains the classes you are debugging, and verifying that they were built from the sources you are inspecting.
Note that when you are debugging third-party libraries, you often can download the "sources" jar (see IntelliJ2-IDEA get Maven-2 to download source and documentation).
If you stumbled across this post, and sure that the source and JAR are the same code, then this could be your problem.
http://youtrack.jetbrains.com/issue/IDEA-8021
Instead of doing remote debugging you can run the plugin directly from IntelliJ.
Have the liquibase plugin project loaded in IntelliJ by just pointing at the pom.xml.
Choose Edit Configurations...
Press the + button to Add New Configuration.
Select Maven.
Enter the Working directory to the project you want to run the plugin on.
Enter the Command line. Could be process-sources, compile or liquibase:status depending on what you want to do.
Press OK
Set a breakpoint in the Liquibase Mojo.
Now you can start this configuration by pressing Shift+F9.
Maven will start and finally you will see that your plugin is waiting at the breakpoint!
Make sure that you have defined the plugin in the target pom.xml with correct version and also that you build the plugin before launching it. You can ensure that by enabling Make in the Before Launch pane.

Resources