I have a simple JUnit test that I successfully run inside Eclipse on macOS Mojave. The class makes a JNA call to a dynamic library, so I had to set the Runtime environment variable DYLD_LIBRARY_PATH
When I try to run mvn test both inside or outsite of Eclipse, they fail.
The reason, so I learned, is macOS' System Integrity Protection which wipes all DYLD variables. However it must be possible to set them, somehow, since the JUnit test inside Eclipse works as designed.
I tried to "hack" the mvn shell script which ar the very end executes:
exec "$JAVACMD" \
$MAVEN_OPTS \
$MAVEN_DEBUG_OPTS \
-classpath "${CLASSWORLDS_JAR}" \
"-Dclassworlds.conf=${MAVEN_HOME}/bin/m2.conf" \
"-Dmaven.home=${MAVEN_HOME}" \
"-Dlibrary.jansi.path=${MAVEN_HOME}/lib/jansi-native" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${CLASSWORLDS_LAUNCHER} "$@"
by setting the DYLD_LIBRARY_PATH immediately before the exec command, without success.
Also tried to patch $JAVACMD to set the variable first, no luck.
What options did I miss (short of disabling SIP)?
I'm not looking for a general solution, running mvn is my goal
Similar questions:
I found a solution, I don't like it, but it seems to work. The JNA call went out to load additional code that uses the
@executable_pathannotation. Running Java, the executable is the JVM, not the original application and thus the JNA call would fail.Linking the whole program directory (and cleaning up thereafter) did the trick for me. My call to
mvnlooks like this:YMMV