I'm trying to build something with maven, but keep getting the following error in intellij
-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variable and mvn script match.
So after searching the internet I found some ideas with the environment variables. But I checked with mvn -version and this is the response I get:
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_65, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/jre
Default locale: nl_NL, platform encoding: UTF-8
OS name: "mac os x", version: "10.11", arch: "x86_64", family: "mac"
So I don't really know what I need to do extra to get this started?
If you are using IntelliJ, try to look at this post
You need to set the argument -Dmaven.multiModuleProjectDirectory=$M2_HOME to your JRE
Related
I have recently started working on MacOS, I installed Maven and when i checked out for it's Maven Home Path,I found out a strange path and I need to change this path.
When I run mvn -v command in terminal,i am get this output
Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
Java version: 15.0.1, vendor: N/A, runtime:
/usr/local/Cellar/openjdk/15.0.1/libexec/openjdk.jdk/Contents/Home
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.7", arch: "x86_64", family: "mac"
Kindly help me changing the Maven path to a different version that I desire.
binary home, using set o export and the path to maven root directory...
repository,
I upgraded maven version. What I've done:
Downloaded new maven version
Updated PATH environment variable
In idea selected new maven version:
Inside cmd I see correct maven version:
mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\Program Files (x86)\apache\apache-maven-3.6.3-bin\apache-maven-3.6.3\bin\..
Java version: 1.8.0_111, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_111\jre
Default locale: en_US, platform encoding: Cp1251
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Also I see correct version in Idea maven plugin:
But when I try to check maven version in the terminakl I see:
How could I acheve that Idea terminal sees new maven version ?
P.S.
shell config:
I download a new maven and execute using the full path, but still get the old version, and it doesn't help even I put it on PATH. It's very weird.
I run the maven as version of 3.3.9, but it still use the 3.2.5
-bash-4.1# /usr/hdp/2.3.2.0-2950/apache-maven-3.3.9/bin/mvn --version
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T17:29:23+00:00)
Maven home: /usr/share/apache-maven
Java version: 1.7.0_91, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.91.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-573.7.1.el6.x86_64", arch: "amd64", family: "unix"
M2_HOME is set as the old maven home directory. Seems maven will pick up the MAVEN from this environment variable.
SOLVED I solved the error by downgrading Maven to 3.0.5.
Original post:
I am quite new to Maven and want to use it with Android.
I try to go this tutorial, but I am stuck at step 4, I get this error.
Running mvn -version returns
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 18:22:22+0300)
Maven home: /opt/apache-maven-3.1.1
Java version: 1.7.0_21, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9", arch: "x86_64", family: "mac"
There are quite few posts about it, and JIRA ticket for it, but I don't know how to fix as fast as possible.
I am trying to use the maven-release-plugin with some environment variables, but I get an issue when I use an environment variable for the release version.
I am executing:
mvn release:clean --batch-mode -Dtag=${env.tag} -Dproject.rel.com.mycompany.project:project-root=${env.project.rel.com.mycompany.project:project-root} -Dproject.dev.com.mycompany.project:project-root=${env.project.dev.com.mycompany.project:project-root} release:prepare
I am getting:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-release-plugin:2.4:prepare
(default-cli) on project project-root: Error parsing version,
cannot determine next version: Unable to parse the version string:
"${env.project.rel.com.mycompany.project:project-root}" -> [Help 1]
If I change the ${env.project.rel.com.mycompany.project:project-root} to a specific version, the command will pass.
But as you can see I am using:
${env.tag}
${env.project.dev.com.mycompany.project:project-root}
with no issues. Is this a bug? Or am I doing something wrong?
Additional notes:
Environment variables:
tag=2.55
project.rel.com.mycompany.project:project-root=2.55
project.dev.com.mycompany.project:project-root=2.56-SNAPSHOT
My Maven version is:
C:\>mvn -version
C:\>set MAVEN_OPTS=-Xmx1024m -XX:MaxPermSize=512m
Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: C:\Users\John\Documents\apache-maven-3.0.4-bin
Java version: 1.6.0_25, vendor: Sun Microsystems Inc.
Java home: C:\JDK\jdk1.6.0_25\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
you will have to use the arguments attribute: http://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.html#arguments
So in your context your cmd line will look like this (Note the double quotes as well):
mvn release:clean --batch-mode release:prepare "-Darguments=-Dtag=${env.tag} -Dproject.rel.com.mycompany.project:project-root=${env.project.rel.com.mycompany.project:project-root} -Dproject.dev.com.mycompany.project:project-root=${env.project.dev.com.mycompany.project:project-root}"
Furthermore, if i remember right the uses of the tokens ${env.X} requires the usage of the property name in upper case (to be verified)
It's not working because the release plugin clears the environment[1]. I doubt it's documented[2], I found out by looking at the source. Farid's answer is a good workaround - it passes the environment value via java properties which are not cleared.
I would have simply commented on Farid's answer but SO doesn't think I'm shiny enough.
Why??
Classic maven.