88

I just installed Maven 3.3.1 on Mac OS X, and building a Maven Project with Eclipse is giving me this error:

-Dmaven.multiModuleProjectDirectory system property is not set.
Check $M2_HOME environment variable and mvn script match.

It did not happen before with Maven 3.2.5.

Is there any way to fix this (except downgrading to 3.2.5) ?

Where exactly can I set this "multiModuleProjectDirectory" property in Eclipse?

1
  • 3
    This was a filed m2e bug as of 2015-03-24 , and has since been resolved. Please see stackoverflow.com/a/29735560/751158 .
    – ziesemer
    Apr 19, 2015 at 20:42

10 Answers 10

197

In Eclipse you need to go like this.

Window-> Preference -> Java -> Installed JREs -> Edit

In the edit Default VM arguments you need to put

If you already set the maven home.

-Dmaven.multiModuleProjectDirectory=$M2_HOME
4
  • I don't know why, but when you run a maven option like clean in Eclipse it will show that is necessary. Apr 2, 2015 at 11:23
  • 5
    @atamanroman and all - this was a filed m2e bug as of 2015-03-24 , and has since been resolved. Please see stackoverflow.com/a/29735560/751158 .
    – ziesemer
    Apr 19, 2015 at 20:41
  • You can also add the VM args from Run Configuration -> Maven Build. Select your launch configuration and open the tab JRE. Add -Dmaven.multiModuleProjectDirectory=$M2_HOME in VM arguments textbox.
    – Bogie
    Jun 1, 2016 at 6:43
  • I followed the solution and still I was seeing the same error.That was because the maven project had reference to jre 1.7 But JAVA_HOME was set to jre1.8.Making Maven project to point to the jre 1.8 in configure Build path->java build path solved the issue.
    – Shubha S
    May 31, 2017 at 4:53
22

In IntelliJ you can set this option in VM Options field that you can find in the next configuration view:

Preferences/Build, execution, deployment/Build tools/Maven/Runner

enter image description here

1
  • Also it works for IntelliJ Idea 14.0 with Maven 3.3.9 Dec 26, 2015 at 12:48
17

This was filed as a bug with m2e in Eclipse at https://bugs.eclipse.org/bugs/show_bug.cgi?id=462944 , due to the changes in Maven 3.3.1.

This is fixed in m2e 1.5.2 as of 2015-04-13. This is an available release that can be installed from http://download.eclipse.org/technology/m2e/releases/ .

(No more changing JVM arguments for the entire workspace or for specific launch configurations required.)

2
  • 1
    I get : An error occurred while collecting items to be installed session context was:(profile=epp.package.jee, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=). No repository found containing: osgi.bundle,org.aspectj.runtime.source,1.7.0.20120703164200 No repository found containing: osgi.bundle,org.eclipse.contribution.weaving.jdt.source,2.2.0.e37x-RELEASE-20120704-0900 + others May 16, 2015 at 12:12
  • The latest 1.5.X release should be here: download.eclipse.org/technology/m2e/milestones/1.5
    – cyfur01
    Jul 17, 2015 at 0:29
7

Define like this in the JVM options:

-Dmaven.multiModuleProjectDirectory=HOME_PATH_OF_YOU_PROJECT
3
  • 1
    Where exactly can I set the JVM Options of a Project in Eclipse?
    – Bob
    Mar 29, 2015 at 22:53
  • 1
    PROJECT_DIR makes more sense than M2_HOME. Apr 2, 2015 at 11:46
  • 1
    that variable does not exist - what you actually were trying to refer to is $PROJECT_LOC
    – specializt
    Apr 2, 2015 at 14:59
4

In case you have this error message on your commandline, please verify if your PATH variable points to the same maven installation apache-maven-3.X.X/bin folder as your M2_HOME variable. In my case I was mixing up two versions which resulted in this error.

3

go to run configuration, create new maven build launch configuration where in the first tab you fill the base directory and the goal, then, go to jre tab and add to the vm args this config:

-Dmaven.multiModuleProjectDirectory=%M2_HOME%

where M2_HOME is an environment variable pointing to the base directory of your maven installation

2

If you want to try a second way, you can try to download a path from http://download.eclipse.org/technology/m2e/milestones/1.5/.

Open Help>install new software and download from url above. This way solved my problem.

2

I encountered the same issue with Maven 3.3 and 3.2 versions, so I decided to downgrade it to version 3.0.5 and it worked just fine.

1

To set the maven.multiModuleProjectDirectory property permanently in Maven, I've added a default activated profile which initializes the property with the MAVEN_HOME environment variable in the settings.xml file. Or you could also alternatively use the M2_HOME environment variable.

<profile>
    <id>my-profile</id>
    <properties>
            <maven.multiModuleProjectDirectory>${env.MAVEN_HOME}</maven.multiModuleProjectDirectory>
    </properties>
</profile>
<activeProfiles>
    <activeProfile>my-profile</activeProfile>
</activeProfiles>
0

i had the same problem with intelliJ 14, i tried out different solutions provided at forums but not worked out. What i did is i completely uninstall intellij and installed intellij 15.0.1 and import the same project then all works fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.