1
In my application I am trying to use Maven, but I have some problems that can be related to configuration, when I will generate a project JAR or use some Run As option from the pom.xml file in the terminal the return is always:
-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.
I am using jdk1.8.0_45, apache-Maven-3.3.3 and the following environment variables have already been added: JAVA_HOME and M2_HOME.
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>appgeodev</groupId>
<artifactId>simple-map</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>simple-map</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
How are you
M2_HOME
andPATH
?– Bruno César
M2_HOME looks like this: C: starcode apache-Maven-3.3.3 and PATH : ;%JAVA_HOME% bin;%M2_HOME% bin;
– Emanoel
You’re running something with this is:
-Dmaven.multiModuleProjectDirectory=$M2_HOME
? As is windows, tried without the$
?– Bruno César
@Brunocésar, I tried to execute this command in cmd with and without $ , as follows: mvn -Dmaven.multiModuleProjectDirectory=$M2_HOME, but unsuccessfully, the terminal returns me the following message: Please set the M2_HOME variable in your Environment to match the Location of the Maven installation
– Emanoel
This way you put it will surely give error, because you are without any
goal
. Try, for examplemvn clean -Dmaven.multiModuleProjectDirectory=$M2_HOME
and update with the bug, tested in a windows here and is OK. If possible, include yourpom.xml
– Bruno César
@Brunocésar seems to be a problem in my configuration, because when I give the command
mvn -version
it shows me the following message on the terminal: ERROR: M2_HOME is set to an invalid directory. M2_HOME = "C program Files apache-Maven-3.0.4" Please set the M2_HOME variable in your Environment to match the Location of the Maven installation– Emanoel
I also could not run your suggested command, my pom.xml this very basic, nothing that should generate any problem
– Emanoel
That value for
M2_HOME
It’s different from what I said before. See if the directory is correct, if it is configured right, without being in the user variables, etc.– Bruno César
That statement of "C program Files apache-Maven-3.0.4" is what the terminal, my M2_HOME path looks like: C: starcode apache-Maven-3.3.3, I’ll add my pom.xml
– Emanoel