Adding maven support to existing IntelliJ module is not available - maven

I just started an IntelliJ plugin project, and after going a few steps, I realized that I am not managing dependencies with maven. Naturally I head over to the module in the project explorer, and right click -> Add Framework Support. But Maven is not listed! In fact, the only thing listed is Groovy. What could cause this, and how do I get maven back?
The maven plugin is enabled.

Here is a brief answer how to get going with Gradle, but most questions remain unanswered.
How to manage development life cycle of IntelliJ plugins with Maven
For a comprehensive read this post : http://labs.bsb.com/2013/11/how-to-manage-development-life-cycle-of-intellij-plugins-with-maven-2/
The post also includes a link to the source code on github.
Making your plugin project use maven in IntelliJ
This is probably not what you are struggling with, but I include it just in case. Supposing you have already started a new plugin project you have two options:
Right-click on the project name in the project explorer and choose New > Module
Create a pom.xml in the project root, then right-click on it and choose Add as Maven Project
hth

First, make sure you have enabled maven plugin in
File -> Settings -> Plugins and add search the maven plugin and activate
Restart the IntelliJ.
Go and check the tool window to make it visible
go to View -> Tool Windows > Maven Projects to open it.

The above options might take some time to execute but there is a quick fix to this if you already have a pom.xml file present in the project.
Right click on the pom.xml file and you will see an option
Add as Maven Project

As far as I understood, you have to mark your folder with pom.xml as Maven module.
In order for the project to become Maven:
Go to - File -> Project Structure (or Ctrl + Shift + Alt + S)-> Modules.
In the middle, you must remove the existing module.
Then in the same place of window click on the plus -> Import module -> Select the
required folder with pom.xml -> Import module from external module -> Maven -> Next ->
Finish
You may need to restart your IntelijIdea. Better just in case to restart it.
After restarting it, it should be appear a pop-up window in the lower right corner - Import maven module -> Click on it.
After that, the folder for module and pom.xml should be displayed as Maven.
P. S. Also check before these steps, that you have Maven support for your IntelijIdea.

Solved it being root as intelliJ launcher... not the best solution but seems a workaround.
So the best solution I found yet instead of digging into filesystem to see where there is a permissions problem was to change the owner to my user
sudo chown -R myUsername:myUsergroup /opt/becauseIInstalledItHere/idea-IC-version

To get the option in the right hand of intellij you have to follow two step given below -
Right click on Pom.xml
Click on "add as Maven Project"

Related

how the best way to create project with maven on eclips?

i know there are 2 methode to create project with Maven.
Create Dynamic project on eclipse and convert it into maven project
Create Maven project with command line and then import the project into eclips.
i always do the 1. choise.
If You have latest eclipse IDE then its very simple.
Go to Create new Project wizard and search maven project. (if its old eclipse IDE then you probably need to install m2e plug in from market place).
select maven project and next. Check (Create a simple project) if you want customization other wise just click Next and You will be presented a number of ready made archtypes.
For simple console projects you can chose maven-archtype-quickstart. or what ever project you want to create.
Now Give groupId e.g. com.yourcompany or com.yourprojectgroup and artifactId e.g. projectname-alias . and Click Finish.
First Time eclipse will create local repo if its not already created and then put default dependencies defined by provided pom in your local repo. Further you just need maven knowledge to customize project. e.g. New Dependencies and build system etc.
I hope this will clear your mind. I prefer this way because its fast and easy.
If you create a new project in Eclipse (at least in Mars or Neon), you can choose "Maven Project" and get everything you need. Don't use eclipse goals of Maven. They are deprecated.

Spring STS not recognizing project structure with Gradle

I'm trying to do this getting started guide from Spring. So I cloned the project using git from the command line. As I'm working with Gradle, I removed the Maven files from the repository to clean the project.
After that I open my STS and go to File -> Open Projects from File System and navigate to the /initial folder of the repository. The project is imported correctly but when I try to add some "java stuff" (packages, classes, etc.) I get several errors and I can only add folders and files, which is quite annoying for working.
To be more descriptive, I'll add some images so you can see what's happening. This is the project initially imported into STS as I described above:
Then I try to add some java stuff, let's say for example a source folder. So Right Click on library -> New -> Source folder and this is the result:
And in the properties of library I have the following:
So the question is: how can I tell to STS to recognize the library folder as a Java Project (or Gradle module, I don't know how to call it) instead of a plain folder so I can add my packages and classes?
Thanks in advance for your answers.
In case you would like to work with Gradle, you should use the Gradle integration for Eclipse (project Buildship) and install that into your STS environment. After that, you should be able to import the projects either from disc as existing Gradle project (not as file system) or via the wizard that integrates the spring guides into STS (Import Getting Started Content). The wizard for the guides also let you choose between the Maven and the Gradle variant, so you don't need to close and delete stuff yourself.
Hope this helps!!!

Netbeans can't find sources in non-standard maven project layout

I'm trying to use Netbeans 8.1 to work on a Maven project with a non-standard project structure. In my project, my sources are under src/foo instead of src/main/java. To open my project, I click File > Open Project... in the menu. Then I navigate to my project in the file browser that opens. Then I select my project and click Open. When my project opens in the Netbeans Projects tab, it does not contain any source packages. It only shows a folder labeled Dependencies and a folder labeled Project Files.
I've tried changing the location of the source folder in the project properties to fix this. I right-click on the project, click Properties, and then click Sources in the menu on the left. Then I try to edit the Source Folder value, but the value isn't editable. It's worth noting that for ant projects, I can add sources in the project properties, but for Maven this doesn't seem possible.
Does your maven project actually build correctly? The IDE will pull the source location from your POM model. Eg.
<project>
<build>
<sourceDirectory>${project.basedir}/src/foo</sourceDirectory>
</build>
One solution is to change your project so that it uses Maven's standard directory layout. One very easy way to do that (if you have your sources under one directory), is to create symbolic link from src/main/java to src/foo:
mkdir src/main && ln -s /path/to/project/src/foo src/main/java
If you do that, Netbeans will be able to see your sources, and you can keep your non-standard directory structure.
Possible Alternative: When searching for alternative solutions to this issue, I found that I could import the project into Netbeans as either a Java Project with Existing Sources or a Java Free-Form Project (I'm not sure which one I used). However, Netbeans won't let me do that anymore, so I'm not sure if it will always work and I'm not sure of the steps I took. If you want to try that solution, click File > New Project, choose the Java category, and choose either Java Project with Existing Sources or Java Free-Form Project. In the next window, point Netbeans to your existing sources as the location of the project. As I said above, I'm sure that this worked for me once, but I cannot use this method anymore as Netbeans shows the following error:
Project folder is managed by a project foo-project-name. Instead of creating a new project just open it. If by a chance you just deleted the project foo-project-name than [sic] restart the IDE to reuse the folder.

Minor Annoyance: edu.emory.mathcs.backport.java.util

I know this is trivial, but I bet I am not the only developer being annoyed by this issue:
I have a maven project building a Spring Hibernate frameowrk for a webapp.
I am building using Eclipse.
I use Eclipse shortcuts to import dependencies and often do so almost subconsciously.
Somewhere in my project dependencies I have a jar that includes the following package.
edu.emory.mathcs.backport.java.util
I often accidentally import this package instead of java.util and get compile or runtime errors.
QUESTION: How can I find out which dependency includes this package so I can (hopefully) exclude it using the Maven enforcer plugin.
This does not directly answer your question but may help you prevent the accidental import in the first place:
In Eclipse you can add a type filter in Preferences → Java → Appearance → Type Filters.
From the description there:
All types whose fully qualified name matches the selected filter strings will not be shown in the 'Open Type' dialog. They will also be ignored in content assist or quick fix proposals and when organizing imports. For example 'java.awt.*' will hide all types from the awt packages.
You can run mvn dependency:tree from the command line. It will show a tree of your dependencies and their transitive dependencies.
Within Eclipse you can open your pom.xml using the Maven POM Editor (default editor for POM files) and click on Dependency Hierarchy.
Within this view you can use a filter or select the dependency on the right side and the dependency tree for this dependency will be shown on the left side.
I recently encountered this issue with a Maven project in IntelliJ IDEA.
You can view transitive dependencies using the Maven command mvn dependency:tree to figure out where this package is creeping in.
However, it's worthwhile to mention that this problem can occur for Gradle or Maven projects. If you are using IntelliJ, then another workaround that will work for all of your projects - regardless of build tool - is to exclude the package altogether from the IDE's editor settings.
The steps to exclude the edu.emory.mathcs.backport.java.util package when using auto-import for all of your projects opened in IntelliJ are as follows (this is valid for IntelliJ IDEA 2022.2):
Ctrl + Alt + S (or click on File, then Settings)
Editor > General > Auto Import
Under the exclusion section, add the following exclusion with an IDE scope: edu.emory.mathcs.backport.java.util.*
Reference Screenshot

Add a remote Archetype Catalog in IntelliJ

I am new to IntelliJ but coming from Eclipse I expected Maven support to be far better. It really is but I could not find how to define a remote archetype catalog in IntelliJ (14.1).
All I could find was a way to add a Archetype manually but that is not what I need. I would like to point to a XML file on a remote server that contains the list of all archetypes available.
In Eclipse, it looks like this :
Maybe you would like to try an Intellij Plugin that I wrote yesterday. It enables you to add remote archetype catalogs to Idea: Maven Archetype Catalog plugin
To make my answer more clear: I had the same issue that it struggles me that you can add Maven Archetype Catalog files in Eclipse, but not in IntelliJ IDEA. So I tried to write a plugin for IntelliJ IDEA, so that you can actually define URLs to archetype-catalog.xml.
The plugin just parses those URLs and provides the Maven Archetypes to the list of available Archetypes in IntelliJ IDEA.
After installing the Plugin you can find a new entry in the Settings menu at File - Settings - Build, Execution and Deployment - Build tools.
I know this is kinda old thread, but in the future if some one will look for it.
This Maven Archetype Catalogs is a plugin for intellij that allows import external archetypes from a URL.
It solved my problem on Linux, haven't tried it on Windows.
To add this plugin go to File->Settings->Plugins->Browse repositories
in the search bar type "Maven Archetype Catalogs". Install and restart.
To use it go to File -> Settings -> Build, Execution, Deployment -> Build Tools -> Maven Archetype Catalogs. click the '+' and add the archetype-catalog
It seems that there is a plugin to do this - Maven Archetypes. The reviews are not favourable, and I have never used it though so cannot comment to its effectiveness.
You could also (assuming Windows/IntelliJ 14), edit C:\Users\<username>\.IntelliJIdea14\system\Maven\Indices\UserArchetypes.xml and add the archetypes manually. Not ideal, but still workable.
Screenshots are made in IDEA 14, I've also checked IDEA 13, it's also true for it.
If this is what you need
Then it's in the Preferences:

Resources