Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER and how do I make it work in IntelliJ?

I have a Java codebase that was written with Eclipse that I am trying to work with in IntelliJ. The codebase consists of about 20 Java packages built alongside each other as separate projects. (There are about twenty directories, each containing a .classpath and .project file.) They have dependencies on each other. Presumably everything builds just fine in Eclipse.

I had IntelliJ import these from the Eclipse build format. It mostly seemed to work except that Project Settings -> Modules -> Dependencies shows that many projects have an unresolved dependency on org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER. This appears to come from the following entries in the .classpath files:

<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
    <attributes>
        <attribute name="maven.pomderived" value="true"/>
        <attribute name="org.eclipse.jst.component.nondependency" value=""/>
    </attributes>
</classpathentry>

The packages with this dependency do not build in IntelliJ because they can't resolve the dependencies on the other packages.

I suspect that org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER is some Eclipse-specific trickery that doesn't translate to a different IDE, but I can't figure out exactly what is going on here.

What is org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER? Do I have to do anything special to a build environment that uses it to make it work outside Eclipse?

IntelliJ Ultimate 2016.1.2, Java 1.8.0_91, OS X 10.11.5


I worked around this problem by going into Project Settings->Modules and manually adding module dependencies between my various projects until everything built. Tedious but effective.

I'm leaving this question up here, though, because a short definition of org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER would still have been helpful to me.

like image 774
W.P. McNeill Avatar asked Jun 03 '16 23:06

W.P. McNeill


People also ask

How do I search dependencies in IntelliJ?

If you want to check whether a dependency still exists in your project, and find its exact usages, you can run dependency analysis: From the main menu, select File | Project Structure Ctrl+Alt+Shift+S and click Modules | Dependencies. Right-click the necessary dependency and select Analyze This Dependency.


2 Answers

Intro

The IntelliJ IDEA Maven-2 plugin integrates Maven-2 into IntelliJ IDEA.

First,

enter image description here

Second,

enter image description here

Third,

enter image description here

Similar to the Ant plugin, the Maven-2 plugin allows execution of goals (or phases) and redirects output (with error highlighting) to the message window.

Installation

Available for IDEA 6.0 (until version 1.1 also for IDEA 5.0) through IDEAs built-in plugin manager or directly from {{http://plugins.intellij.net/plugin/?id=1166}}.

In case you downloaded the plugin, simply extract the content of the binary archive into your IDEA plugin directory. The extracted folder (idea-maven-plugin) contains another folder lib, where all the JARs reside.

Usage

Assuming you have specified the environment variables JAVA_HOME and M2_HOME the plugin should be ready to run without any further configuration. In case JAVA_HOME is not defined, the plugin uses the internal IDEA JDK.

If M2_HOME is not defined, you must specify the home directory of Maven-2 in the configuration dialogs. This is a change starting from version 1.1 of the plugin.

Before version 1.1, Maven was called via the start script provided with the normal Maven installation. In order to get better access to the running Maven process Maven now is called directly by starting a Java process. This for example allows terminating the running Maven process by the user.

The configuration can be done in two ways:

Either via the IDE Settings or the Project Settings. The project settings always override the application settings!

The plugin will not work with IDEA versions prior to 6.0! The plugin was tested under Windows and Linux. It was not tested under Mac OS X.

Resource Link:

  1. Maven 2 Integration
  2. Import Maven dependencies in IntelliJ IDEA
like image 137
SkyWalker Avatar answered Oct 05 '22 14:10

SkyWalker


I've come up with a solution that works for me, but the bounty is still open (because I can't close it :P ) and will go to someone who can provide a more detailed explanation.

The solution: Run mvn eclipse:clean and mvn eclipse:eclipse. This causes maven to clear the .classpath file and rebuild it from the pom.xml. Somewhat mysteriously, it no longer contained the dreaded reference to org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER.

Perhaps this is a deprecated tag/variable in Eclipse.

like image 3
Daniel Patrick Avatar answered Oct 05 '22 14:10

Daniel Patrick