No more need in manually adding native library, Gradle does it correctly

This commit is contained in:
DarkCat09 2023-07-03 16:05:05 +04:00
parent 4829cdfc6a
commit be04f698fe

View file

@ -54,43 +54,21 @@ cd_and_exec reqwest4j git apply ../reqwest4j.patch
# ---
export RUSTFLAGS="-C target-feature=-crt-static"
title 'Building reqwest-jni...'
cd_and_exec reqwest4j/reqwest-jni cargo build --release
title 'Building reqwest4j...'
cd_and_exec reqwest4j ./gradlew shadowJar
cd_and_exec reqwest4j ./gradlew --stop
# ---
title 'Adding built reqwest-jni into reqwest4j...'
title 'Copying reqwest4j JAR...'
# Copy JAR into workdir
REQ4J_NAME="reqwest4j.jar"
REQ4J="$WORKDIR/$REQ4J_NAME"
cd_and_exec reqwest4j/build/libs \
find . -maxdepth 1 -name 'reqwest4j-*-all.jar' -exec \
cp {} "$REQ4J" \;
# Copy built reqwest-jni into workdir
REQJNI_NAME="libreqwest_jni.so"
REQJNI="$WORKDIR/$REQJNI_NAME"
cd_and_exec reqwest4j/reqwest-jni/target/release cp libreqwest_jni.so "$REQJNI"
# Create JAR native libraries tree
NATIVES="META-INF/natives/linux/x86_64"
mkdir -p "$NATIVES"
# Move reqwest-jni to native libraries directory
mv "$REQJNI" "$NATIVES/$REQJNI_NAME"
# Add native libraries into JAR
7z u "$REQ4J" META-INF
# Clean up
rm -rf META-INF
rm -f "$REQJNI"
# ---
title 'Adding reqwest4j JAR into Piped...'