34

I got the maven .tar file from http://maven.apache.org/download.cgi, and installed it to the path /usr/local/. I run the mvn -version command in the new window, the output is correct. Below is my .bash_profile in my home directory:

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk7/Contents/Home  
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar  
PATH=$JAVA_HOME/bin:$PATH:  
export JAVA_HOME  
export CLASSPATH  
export PATH  
M2_HOME=/usr/local/maven  
M2=$M2_HOME/bin  
PATH=$M2:$PATH  
export M2_HOME    
export M2  
export PATH

and the mvn -version is below :

BianFranks-MacBook-Pro:~ Frank$ mvn -version  
Apache Maven 3.3.1 (cab6659f9874fa96462afef40fcf6bc033d58c1c; 2015-03-    14T04:10:27+08:00)  
Maven home: /usr/local/maven  
Java version: 1.7.0_72, vendor: Oracle Corporation  
Java home: /Library/Java/JavaVirtualMachines/jdk7/Contents/Home/jre  
Default locale: en_US, platform encoding: UTF-8  
OS name: "mac os x", version: "10.10.2", arch: "x86_64", family: "mac"

But the tips occurred when cleaning the module via Maven in Intellij IDEA 14:

/Library/Java/JavaVirtualMachines/jdk7/Contents/Home/bin/java -Dmaven.home=/usr/local/maven -Dclassworlds.conf=/usr/local/maven/bin/m2.conf -Didea.launcher.port=7532 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA 14.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/usr/local/maven/boot/plexus-classworlds-2.5.2.jar:/Applications/IntelliJ IDEA 14.app/Contents/lib/idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=14.0.2 clean  
-Dmaven.multiModuleProjectDirectory system propery is not set. Check   $M2_HOME environment variable and mvn script match.   
Process finished with exit code 1

the system property is not set, but I don't know how to set it...

8 Answers 8

73

Open up the IntelliJ settings dialog.

In Maven-->Runner options set a following VM option: -Dmaven.multiModuleProjectDirectory=project root

10
  • Great, it's ok. Thx very much , But I wanna the reason why it occurred.
    – Frank
    Mar 19, 2015 at 7:24
  • this case occurred because I changed my mac from air to pro, and the version of maven changed from 3.2.3 to 3.3.1.
    – Frank
    Mar 19, 2015 at 7:26
  • 2
    It could be a bug in Maven 3.3.1 maybe?
    – dreamer
    Mar 19, 2015 at 11:42
  • 4
    yes, it's a known issue and fixed in nearest update :<youtrack.jetbrains.com/issue/IDEA-137783>
    – Frank
    Mar 19, 2015 at 12:18
  • 3
    I'm sorry. "some_valid_path" is of course the Project Home directory Mar 20, 2015 at 10:07
20

This is a known bug in IntelliJ (as indicated by @Frank) in IntelliJ 14.0.3 and 14.1.

It will be fixed in IntelliJ 14.0.5 and 14.1.1.

If you need the fix right now, you can download and install the specific fix as described in the issue.

Alternatively, if you do not need the newest maven 3.3.1, you can fallback to an earlier version of maven.

1
  • 1
    I would like to say they bundled Maven 3.0.5 with the new Intellij 14.1 release which also could be a temporary fix for others.
    – t0tec
    Mar 24, 2015 at 15:40
16

I've got the same error with these tools version:

  1. apache-maven-3.3.1
  2. Eclipse: Luna Service Release 2 (4.4.2) with M2Eclipse 1.5.0
  3. java: 1.8.0_31

Solved it by adding the VM argument (-Dmaven.multiModuleProjectDirectory= MAVEN_HOME_PATH)

2
  • 7
    Had the same problem with a similar setup. My only difference was using Mars Milestone 6. Apparently though, the argument doesn't even need a value, it just has to be there. Putting "-Dmaven.multiModuleProjectDirectory= " into my VM args for the project solved the problem.
    – sheltem
    Mar 31, 2015 at 9:35
  • Works well also with Eclipse Luna
    – atao
    Apr 4, 2015 at 8:18
6

If the variant from previous comments will not work:

-Dmaven.multiModuleProjectDirectory=project root

you can try this with quotes:

-Dmaven.multiModuleProjectDirectory="project root"

This is exactly what helped me.

1
  • Thanks, this worked for me as well. The one with the quotes.
    – SoltanG
    Apr 5, 2016 at 21:40
0

Got the same with Luna Service Release 2 (4.4.2), following are the steps that i followed:

  1. Goto - Run Configuration - under JRE tab - type -Dmaven.multiModuleProjectDirectory=

This solution was provided by sheltem Mar...Thanks

0
  1. Goto Run Configuration under JRE tab
  2. type(in VM argument text field) "-Dmaven.multiModuleProjectDirectory="
0

This thread is important thread and very useful so I added this solution to it. I added this line to maven runner and it works with me

    -Dmaven.multiModuleProjectDirectory=$M2_HOME

Noting that, M2_HOME is defined in the environment variables for maven home in case of windows OS.

0

If you don't rely on an external IDE, remember to put this in MAVEN_OPTS, like so (Linux)

export MAVEN_OPTS=-Dmaven.multiModuleProjectDirectory=<your path> 

From Apache Maven's documentation, it's good to learn about this variable:

This variable contains parameters used to start up the JVM running Maven and can be used to supply additional options to globally to Maven. E.g. JVM memory settings could be defined with the value -Xms256m -Xmx512m.

You can refer to this link https://maven.apache.org/configure.html

Your Answer

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

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