What is "${env.M2_HOME}" and how do I set it? - maven

I'm getting this error when trying to do a maven build:
[INFO] An Ant BuildException has occured: The following error occurred while executing this line:
C:\[[project]]\build.xml:17:
settingsFile does not exist: C:\[[project]]\${env.M2_HOME}\conf\settings.xml
Is this the same as M2.HOME? How do I set it when I don't have access to environment variables due to silly IT security policies in my company? Is it possible to set it within the project using IntelliJ IDEA?

It's the M2_HOME environment variable.
export M2_HOME=/path/to/maven
Or since you're on Windows (sorry):
set M2_HOME=c:/path/to/maven

Related

How to set up apache ranger on apple macbook pro m1

I'm trying to set up apache ranger for work using this https://github.com/apache/ranger/tree/master/dev-support/ranger-docker
however by running
mvn clean package -DskipTests
I'm getting the following error: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.6:exploded (prepare) on project security-admin-web: Execution prepare of goal org.apache.maven.plugins:maven-war-plugin:2.6:exploded failed: Unable to load the mojo 'exploded' in the plugin 'org.apache.maven.plugins:maven-war-plugin:2.6' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: null The entire error can be seen in this picture:
[1]
and as an alternative provided in the github, when I run:
docker-compose -f docker-compose.ranger-base.yml -f docker-compose.ranger-build.yml up
I get the error:
ranger-build | The JAVA_HOME environment variable is not defined correctly
ranger-build | This environment variable is needed to run this program
ranger-build | NB: JAVA_HOME should point to a JDK not a JRE
ranger-build | mv: cannot stat 'target/ranger-*': No such file or directory
ranger-build exited with code 1
I have also tried following https://medium.com/swlh/hands-on-apache-ranger-docker-poc-with-hadoop-hdfs-hive-presto-814344a03a17
however it gets stuck in the ranger-admin container and localhost:6080 doesn't work.
[1]: https://i.stack.imgur.com/57ubI.jpg
I was able to solve this by downgrading my maven to 3.6.3 as I was having incompatibility issues, although this particular issue was resolved by adding maven war 2.6 plug in in pom.xml but then more incompatibility issues arose so i had to uninstall and reinstall a completely different maven version and that fixed all the issues.

ERROR: Failed to parse POMs java.io.IOException: Cannot run program " /lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.amzn2.0.1.x86_64/bin/java"

when i Biuld Now manually in jenkins for the maven project and on Source code management i choose Git Repositories (Repository URL https://github.com/sathish-sundar/java-project-NM.git). I am getting below error as image attached. Someone could help me here please i am new to the Devops world.
I was able to figure it out by adding the value in
Dasboard - Manage jenkins -configure system- global properties
under list of variables
Name : JAVA_HOME
Value : /lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.amzn2.0.1.x86_64/jre
and adding the JAVA_HOME in
Dasboard- manage jenkins- global tool configuration- JDK -
JDK installation- Add JDK
Under JDK
Name : JAVA_HOME
Value : /lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.amzn2.0.1.x86_64/jre
and i had recevied the console output as per requirement.

Setting variables in application.properties, the build fails

In application.properties I want to use variables as below.
quarkus.datasource.db-kind=${DATASOURCE_DB_KIND}
quarkus.datasource.jdbc.url=jdbc:postgresql://${DB_URL}:${DB_PORT}/${DB_DATABASENAME}?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory&sslmode=require
quarkus.datasource.username=${DB_USERID}
quarkus.datasource.password=${DB_PWD}
But when I run a build
./mvnw clean package
getting error
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.5.2.Final:build (default) on project graphql-mp: Failed to build quarkus application: java.util.NoSuchElementException: Property DATASOURCE_DB_KIND not found
This fails because you didn't define the environment variable DATASOURCE_DB_KIND.
If you want it to be able to work without one defined, you need to set a default value and use something like ${DATASOURCE_DB_KIND:yourdefaultvalue}.

Unable to build maven project on esclipe

When I try to build a maven project on eclipse, I get this error:
-Dmaven.multiModuleProjectDirectory system property is not set.
Check $M2_HOME environment variable and mvn script match.
Set MAVEN_OPTS = -Dmaven.multiModuleProjectDirectory
If you are developing application on Eclipse RCP and trying to build any project using any procedure (e.g. embedded maven -- by creating your own launch configuration file), then you will have to set "MavenLaunchConstants.ATTR_POM_DIR" attribute, provided the value of project path.
Code for reference :
ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance(launchFileFolder, launchFileName); workingCopy.setAttribute(MavenLaunchConstants.ATTR_POM_DIR, <project_path>);

Liferay theme development using JBoss on Mac

I am creating liferay themes using JBoss on my Mac. In the process of creating a theme, when I execute ant deploy on my terminal, I am getting following errors:
Buildfile:
/Users/saif/Desktop/Liferay/liferay-plugins-sdk-6.1.1/themes/g2y-b2b-theme/build.xml
[copy] Copying 1 file to /usr/share/ant/lib
BUILD FAILED
/Users/saif/Desktop/Liferay/liferay-plugins-sdk-6.1.1/themes/g2y-b2b-theme/build.xml:5:
The following error occurred while executing this line:
/Users/saif/Desktop/Liferay/liferay-plugins-sdk-6.1.1/themes/build-common-theme.xml:7:
The following error occurred while executing this line:
/Users/saif/Desktop/Liferay/liferay-plugins-sdk-6.1.1/build-common-plugin.xml:5:
The following error occurred while executing this line:
/Users/saif/Desktop/Liferay/liferay-plugins-sdk-6.1.1/build-common.xml:68:
Failed to copy
/Users/saif/Desktop/Liferay/liferay-plugins-sdk-6.1.1/lib/ecj.jar to
/usr/share/ant/lib/ecj.jar due to java.io.FileNotFoundException
/usr/share/ant/lib/ecj.jar (Permission denied)
Total time: 0 seconds
Please help me to get rid of this and proceed further. What are the steps I should take in order to do this on a Mac? Please also tell me how to set up the environment variable of ANT on a Mac.
When ant builds your theme and requires ecj.jar (the eclipse compiler for java) it typically downloads it from some internet repository and places it in $ANT_HOME/lib. It seems your $ANT_HOME is usr/share/ant and you don't have write access to that directory. Either download it manually and place it there or open up the directory write permissions for one build (then close it again).
You'll only need to do this once: When ecj.jar is on the classpath for ant, it will just be used for eternity.

Resources