Skip to content

Commit

Permalink
Align JNI name override with JNA property
Browse files Browse the repository at this point in the history
(This property has not been used in a release)
  • Loading branch information
sebbASF committed Nov 21, 2023
1 parent 7955c91 commit 5ce38e7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
# environment variables: $env:VARNAME instead of $VARNAME
# Also, note that Windows stores all the DLLs in the same directory.
# Instead of defining jni.library.path and jna.library.path we need to define
# jni.library.name and commons.crypto.OpenSslNativeJna to override the file names
# commons.crypto.OpenSslNativeJni and commons.crypto.OpenSslNativeJna to override the file names
- name: Build with Maven (Windows)
if: ${{ startsWith(matrix.os,'windows') }}
# OPENSSL_HOME is needed for Windows build to find some header files
Expand All @@ -123,7 +123,7 @@ jobs:
env:
OPENSSL_HOME: "C:\\Miniconda\\Library"
run: |
mvn -V -B -ntp -DtrimStackTrace=false -D"jni.library.name=$env:NAME" -D"commons.crypto.OpenSslNativeJna=$env:NAME"
mvn -V -B -ntp -DtrimStackTrace=false -D"commons.crypto.OpenSslNativeJni=$env:NAME" -D"commons.crypto.OpenSslNativeJna=$env:NAME"
- name: Build with Maven (not Windows)
if: ${{ ! startsWith(matrix.os,'windows') }}
run: |
Expand All @@ -141,4 +141,4 @@ jobs:
if: ${{ matrix.java == '8' && startsWith(matrix.os,'ubuntu') }}
run: |
mvn -V -B -ntp test -Ptestjni -D"jni.library.path=$ENGINESDIR" -Dcommons.crypto.OpenSslNativeJna=___
mvn -V -B -ntp test -Ptestjna -D"jna.library.path=$ENGINESDIR" -Djni.library.name=___
mvn -V -B -ntp test -Ptestjna -D"jna.library.path=$ENGINESDIR" -Dcommons.crypto.OpenSslNativeJni=___
4 changes: 2 additions & 2 deletions LIBRARY_NAMES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jna.library.path

On Windows, multiple library versions may be installed in the system directory under a different name.
The following properties can be used to override the JNI and JNA file names respectively:
jni.library.name
commons.crypto.OpenSslNativeJni
commons.crypto.OpenSslNativeJna

For testing with Maven, these properties can be defined on the command-line:
Expand All @@ -40,6 +40,6 @@ $ mvn ... -Djni.library.path=/usr/local/lib -Djna.library.path=/usr/local/lib ..

Windows:

> mvn ... -D"jni.library.name=libcrypto-1_1-x64" -D"commons.crypto.OpenSslNativeJna=libcrypto-1_1-x64" ...
> mvn ... -D"commons.crypto.OpenSslNativeJni=libcrypto-1_1-x64" -D"commons.crypto.OpenSslNativeJna=libcrypto-1_1-x64" ...


2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ The following provides more details on the included cryptographic software:
<id>testjna</id>
<properties>
<!-- prevent JNI code from loading -->
<jni.library.name>_</jni.library.name>
<commons.crypto.OpenSslNativeJni>_</commons.crypto.OpenSslNativeJni>
</properties>
<build>
<plugins>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/commons/crypto/Crypto.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private static Properties getComponentProperties() {
/**
* Override property for the default SSL crypto library name when using JNI
*/
public static final String JNI_LIBRARY_NAME = "jni.library.name";
public static final String JNI_LIBRARY_NAME = "commons.crypto.OpenSslNativeJni";

/**
* Where to find the SSL crypto library when using JNA
Expand Down

0 comments on commit 5ce38e7

Please sign in to comment.