This commit is contained in:
Andrea Cavalli 2023-04-27 16:53:44 +02:00
parent 4c0cb6c62f
commit 0edcf4b0ed
3 changed files with 4 additions and 77 deletions

View File

@ -119,13 +119,13 @@ cd ..
# Copy to resources
echo "Copying to resources..."
[ -d ./src/main/resources/libs/${OPERATING_SYSTEM_NAME_SHORT}/${CPU_ARCHITECTURE_NAME}/ ] || mkdir -p ./src/main/resources/libs/${OPERATING_SYSTEM_NAME_SHORT}/${CPU_ARCHITECTURE_NAME}/
[ -d ./src/main/resources/META-INF/tdlight-jni/${OPERATING_SYSTEM_NAME_SHORT}/${CPU_ARCHITECTURE_NAME}/ ] || mkdir -p ./src/main/resources/META-INF/tdlight-jni/${OPERATING_SYSTEM_NAME_SHORT}/${CPU_ARCHITECTURE_NAME}/
if [[ "$OPERATING_SYSTEM_NAME" == "windows" ]]; then
cp ./tdjni_bin/tdjni.dll ./src/main/resources/libs/${OPERATING_SYSTEM_NAME_SHORT}/${CPU_ARCHITECTURE_NAME}/tdjni.dll
cp ./tdjni_bin/tdjni.dll ./src/main/resources/META-INF/tdlight-jni/${OPERATING_SYSTEM_NAME_SHORT}/${CPU_ARCHITECTURE_NAME}/tdjni.dll
elif [[ "$OPERATING_SYSTEM_NAME" == "osx" ]]; then
cp ./tdjni_bin/libtdjni.dylib ./src/main/resources/libs/${OPERATING_SYSTEM_NAME_SHORT}/${CPU_ARCHITECTURE_NAME}/tdjni.dylib
cp ./tdjni_bin/libtdjni.dylib ./src/main/resources/META-INF/tdlight-jni/${OPERATING_SYSTEM_NAME_SHORT}/${CPU_ARCHITECTURE_NAME}/tdjni.dylib
elif [[ "$OPERATING_SYSTEM_NAME" == "linux" ]]; then
cp ./tdjni_bin/libtdjni.so ./src/main/resources/libs/${OPERATING_SYSTEM_NAME_SHORT}/${CPU_ARCHITECTURE_NAME}/tdjni.so
cp ./tdjni_bin/libtdjni.so ./src/main/resources/META-INF/tdlight-jni/${OPERATING_SYSTEM_NAME_SHORT}/${CPU_ARCHITECTURE_NAME}/tdjni.so
fi
echo "Done."

View File

@ -1,40 +0,0 @@
package it.tdlight.jni.implementation_name.operating_system_name.cpu_architecture_name.version;
import java.lang.ClassLoader;
import java.io.InputStream;
import java.io.File;
public class LoadLibrary {
public static InputStream getLibraryAsStream() {
return LoadLibrary.class.getResourceAsStream("/libs/" + getOsName() + "/" + getArchName() + "/"
+ getFileName() + getExtension());
}
private static String getOsName() {
return LoadLibrary.class.getPackage().getName().split("\\.")[4];
}
private static String getArchName() {
return LoadLibrary.class.getPackage().getName().split("\\.")[5];
}
private static String getVersionName() {
return LoadLibrary.class.getPackage().getName().split("\\.")[6];
}
private static String getFileName() {
return "tdjni";
}
private static String getExtension() {
switch (getOsName()) {
case "win":
return ".dll";
case "osx":
return ".dylib";
case "linux":
default:
return ".so";
}
}
}

View File

@ -73,39 +73,6 @@
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>it.tdlight.jni.implementation_name.operating_system_name.cpu_architecture_name.version</pattern>
<shadedPattern>it.tdlight.jni.${IMPLEMENTATION_NAME}.${OPERATING_SYSTEM_NAME_SHORT}.${CPU_ARCHITECTURE_NAME}.${safeVersionName}</shadedPattern>
</relocation>
<relocation>
<pattern>it.tdlight.jni.implementation_name.operating_system_name.cpu_architecture_name</pattern>
<shadedPattern>it.tdlight.jni.${IMPLEMENTATION_NAME}.${OPERATING_SYSTEM_NAME_SHORT}.${CPU_ARCHITECTURE_NAME}</shadedPattern>
</relocation>
<relocation>
<pattern>it.tdlight.jni.implementation_name.operating_system_name</pattern>
<shadedPattern>it.tdlight.jni.${IMPLEMENTATION_NAME}.${OPERATING_SYSTEM_NAME_SHORT}</shadedPattern>
</relocation>
<relocation>
<pattern>it.tdlight.jni.implementation_name</pattern>
<shadedPattern>it.tdlight.jni.${IMPLEMENTATION_NAME}</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>