Integrating IntelliJ with Maven - java

I have set M2_HOME variable to the required directory in .bash_profile, still I am getting the following error:
Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.[ERROR] Maven execution terminated abnormally (exit code 1)

One solution (but it's only a workaround) may be to set console argument
"-Dmaven.multiModuleProjectDirectory="
Then the project should work.
I have the same problem while building maven projects from eclipse with system maven installation.

Have you configured maven in IntelliJ?

You can change your maven's version to 3.1.1.
I met the problem too: My version of maven was 3.3.3, and then I changed it to 3.1.1 and it worked.

Related

Spotbugs build issue

Built failed while creating aws-sdk-v2 jars due to spotbugs plugin.
Steps to reproduce the error:
clone latest version of aws-sdk-java-v2
In terminal, go to directory and run mvn clean install
Error:
Failed to execute goal com.github.spotbugs:spotbugs-maven-plugin:3.1.11:spotbugs (spotbugs) on project aws-sdk-java-pom: Execution spotbugs of goal com.github.spotbugs:spotbugs-maven-plugin:3.1.11:spotbugs failed: Unable to load the mojo 'spotbugs' in the plugin 'com.github.spotbugs:spotbugs-maven-plugin:3.1.11'. A required class is missing: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
I tried to rebuild the project by deleting spotbugs-maven-plugin but I that didn't solve the problem.
I had no .mavenrc file yet, but recently had added Java 17 to test something via Home Brew. As a result, I started seeing this issue. I created a ~/.mavenrc and added the following to it:
JAVA_HOME=`/usr/libexec/java_home -v 1.8.0`
This allowed me to get back to using Java 8 with Maven just like my default Java version would be.
I had a similar problem and it turned out my installation of Java 15 was the culprit. Once I got maven to use my standard java version (1.8 Corretto) I could build the project again. Use mvn -version to check which java it's currently using.
Personally I had to set JAVA_HOME in my .mavenrc file, setting it in my bash profile didn't help.

Maven throwing no class found but is working on other developers environment

I am getting the following error when running mvn clean test:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/maven/plugin/MojoExecutionException
It's not happening on my development team they say they are running the command just fine.
I've checked the JAVA_HOME and JRE_HOME environments, both fine.
I'm using maven version 3.6.3 and Java version 1.8.0_144
Not sure what to do at this point. This project was installed using IntelliJ git clone
IntelliJ could use a bundled maven version, which could be different from the system/user one. Have you already checked settings of the IDE?
The problem could be related to different option, maybe a log could help more. Be sure that all the dependencies and plugins are downloaded without any problems. In the past I had same issue and it was related to the proxy settings for the download.
Something was wrong with the maven donwload. I remapped the environment settings to use the intellij maven and everything worked great.

Unable to configure Maven in Jenkins

Maven version 3.3.3 (Maven is configured in my system. I'm able to get version number by mvn -version.)
Following is my Maven project in Jenkins:
Which basically asks me to configure Maven.
Below are the only fields available when I select Configure System. Though I gave the path of Maven, the error is not removed and unable to build.
Can someone help on this.
Please check "Jenkins => Configuration => Global Tool Configuration". There you can define your maven-installation not only the the environment-variable MAVEN_HOME.
Afterwards you should be able to select your maven-installation in your project-build.
ln -s /opt/apache-maven-3.5.4/bin/mvn /usr/bin/mvn
run echo $PATH in pipeline script and see paths available to Jenkins user. Once linking with maven bin path, maven started working. To check, run mvn -v in the pipeline.
First you should configure a JDK and NOT an JRE. Furthermore the rootPOM location is relative to the Jenkins Job Workspace which means usually only pom.xml nothing more...

Maven 3.3.1 ECLIPSE: -Dmaven.multiModuleProjectDirectory system propery is not set

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?
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
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
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.)
Define like this in the JVM options:
-Dmaven.multiModuleProjectDirectory=HOME_PATH_OF_YOU_PROJECT
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.
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
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.
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.
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>
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.

M2E Maven Plugin: Importing Maven project is throwing error in Eclipse JUNO

I have an existing project in maven which is working fine in other remote env which i
dont have any access, I dont know what is the issue in my env, the same project is working
in other remote env.
My Env Details are:-
Java1.7
Tomcat7.x
Eclipse Juno,Build id: 20120614-1722
Plugin Details: M2E - Maven Integration for Eclipse
The below error is coming while importing the project and after selecting pom.xml.
No marketplace entries found to handle maven-compiler-plugin:2.0.2:compile in Eclipse
Go to Window > Preferences > Maven Installations and then deactivate the Embedded and add your own installation.
I would check:
That Eclipse Maven build settings are using a JDK and not a JRE
Check the actual compiler settings in the POM. Maybe the source and target should be explicitly set to 1.7.
It's also worth checking if this runs properly with mvn from the command line to rule out whether it is truly a Maven or IDE issue.

Categories

Resources