Environment variable is null in Java test during mvn build on Mac - java

I have different Java test behaviours (probably after a MacOS update to Big Sur 11.2.3 or another system).
My JUnit test requires the variable DYLD_LIBRARY_PATH on Mac and LD_LIBRARY_PATH on Ubuntu (mvn surefire is used, see below) to find some dylibs / shared objects.
Test works in IntelliJ without any problems on both OS.
But during the mvn build the DYLD_LIBRARY_PATH variable (System.getenv(..)) is null and the test fails on Mac (on Ubuntu it works). Starting mvn with '-X' shows that surefire sets the DYLD_LIBRARY_PATH, but later it is still null.
I am using maven-3.6.3, surefire 3.0.0-M5 and OpenJDK 11.0.10.
Any ideas, how I can with the environment issue?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<environmentVariables>
<LD_LIBRARY_PATH>${basedir}/src/main/resources/libs</LD_LIBRARY_PATH>
<DYLD_LIBRARY_PATH>${basedir}/src/main/resources/libs</DYLD_LIBRARY_PATH>
</environmentVariables>
</configuration>
</plugin>

Pls report a bug in our JIRA and attach your project in ZIP. We need to reproduce it and debug the plugin but the project is required.

Related

How to add GRAALVM PATH in maven pom file JavaFX

I have used GRAALVM to compile native JavaFX apps. in commands ports. Here I want to do the same thing using maven.
I have GRAALVM latest version install in C and added the Environment variable as the name GRAALVM_HOME. and in PATH %GRAALVM_HOME%\bin but when I Run client:build-in IntelliJ. it says GRAAL_PATH didn't find.
I tried to do it with the client plugin.
<plugin>
<groupId>com.gluonhq</groupId>
<artifactId>client-maven-plugin</artifactId>
<version>${client.plugin.version}</version>
<configuration>
<target>${client.target}</target>
<mainClass>${main.class}</mainClass>
<bundlesList>
<list>com.example.sample.main</list>
</bundlesList>
<reflectionList>
<list>com.example.sample.MainController</list>
</reflectionList>
<graalvmHome>GRAALVM_HOME</graalvmHome>
</configuration>
</plugin>
inline graalvmhome I set to add the entire path that's didn't work. then I added a GRAALVM_HOME in it. but this didn't work either.
it's <graalvmHome>path to graal</graalvmHome> where path to graal is the path in your local machine e.g. /home/user/graal

How can I add setup goal to clover in Jenkins?

I have a maven project, and I can run coverage on it on my own machine, no problem after following instructions here: https://confluence.atlassian.com/clover/clover-for-maven-2-and-3-quick-start-guide-160399608.html
When I use Jenkins to run clean clover:setup test clover:aggregate clover:clover, it complains that it Could not find goal 'setup' in plugin org.apache.maven.plugins:maven-clover-plugin:2.4 among available goals aggregate, check, instrumentInternal, instrument, log, clover, save-history
Obviously there is no settings file on the Jenkins box. I'm not sure how it even knows those available goals offhand. And I'm not sure how to add that last goal.
I tried this to no avail:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.3.2</version>
</plugin>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jira-plugin</artifactId>
<version>5.0.18</version>
</plugin>
</plugins>
</pluginManagement>
The second plugin is what I added, in the hopes to mirror what the settings.xml file was doing on my local machine.
I figure another option is to edit the settings file on Jenkins itself. That is probably the best one...
My Jenkins is in Docker so I just ran docker exec -it abc /bin/bash and got in. When I go to .m2 I don't see a settings.xml. So not sure what Jenkins is saying it's going to reference. I'm going to try out just putting settings.xml here and see how that goes
I made sure that it was using my global settings file, and made that file match what was on my machine. Didn't need to touch my pom.xml at all.

imported maven project tries to use jre system library

ive imported a bunch on maven projects from svn and they all (...a lot) try to use
JRE System Library [JavaSE-1.7]
But i only have
jdk1.8.0_102_64Bit
Which i told eclipse about in eclipse.ini with:
-vm C:\Users\myuser\Downloads\jdk1.8.0_102_64Bit\bin
Yet all the imported maven projects insist to use the "System JRE" which is unbound when i check it.
How do you tell maven to use what eclipse knows about? or where does maven get its information about JDK's / JRE'S?
Maven by default uses JAVA_HOME Environment Variable to know which java version to use. Unless you set different one in pom.xml.
Try check every pom.xml of your projects, they must have a plugin section like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable>${JAVA_1_6_HOME}/bin/javac</executable>
</configuration>
</plugin>
Executable tag tell maven to use java 6 in this example.
In this case i probably did something wrong while importing it from svn..a second try worked, but im not sure why :(

Setup JRebel for GAE

I need to try JRebel for my web app development:
Using GAE SDK version 1.8.0
Run through maven appengine:devserver
Under M2E plugin (Eclipse) or console, running Linux (Ubuntu) desktop
Documents I found online points into editing the GAE script, however what would be the approach for GAE run from Maven?
The problem here is starting up the GAE process with the JRebel JVM arguments or in general adding JVM arguments to the GAE process.
There are multiple ways of adding JVM arguments to the process, I would recommend adding those arguments to the appengine plugin
You can set JVM arguments for JRebel in your pom.xml:
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.target.version}</version>
<configuration>
<jvmFlags>
<jvmFlag>-agentpath:{jrebel install directory}/lib/libjrebel64.dylib</jvmFlag>
</jvmFlags>
<disableUpdateCheck>true</disableUpdateCheck>
</configuration>
</plugin>
Where libjrebel64.dylib works for macOS, and you'd use libjrebel64.so on Linux and jrebel64.dll on Windows.

0.20.2 API hadoop version with java 5

I have started a maven project trying to implement the MapReduce algorithm in java 1.5.0_14. I have chosen the 0.20.2 API hadoop version. In the pom.xml i'm using thus the following dependency:
< dependency>
< groupId>org.apache.hadoop< /groupId>
< artifactId>hadoop-core< /artifactId>
< version>0.20.2< /version>
< /dependency>
But when I'm using an import to the org.apache.hadoop classes, I get the following error:
bad class file: ${HOME_DIR}\repository\org\apache\hadoop\hadoop-core\0.20.2\hadoop-core-0.20.2.jar(org/apache/hadoop/fs/Path.class)
class file has wrong version 50.0, should be 49.0.
Does someone know how can I solve this issue.
Thanks.
Maven by default compiles to JDK 1.4 compatibility. You need to change this.
You need to add this to your pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
[Edit: thank you Sean for pointing out Hadoop requires JDK 6]
I ran into this exact same problem. Turned out sbt itself was running on Java 5, which is the default on my Mac for a silly but valid reason. Once I changed my sbt script to explicitly start with Java6, everything worked fine.
Regardless of your maven-compiler-plugin's source & target configurations (that only controls how your own source code is compiled) you must use a 1.6 JVM to run Hadoop's code since it is compiled targetting "1.6" JVM.
So, just install a 1.6 java runtime and use that to run your program.

Categories