chore: better bundling of binary

This commit is contained in:
zaaarf 2023-11-18 20:21:50 +01:00
parent 54965a6744
commit b29f353c7c
No known key found for this signature in database
GPG key ID: 82240E075E31FA4C
3 changed files with 13 additions and 15 deletions

2
.gitignore vendored
View file

@ -49,5 +49,3 @@ target
# Do not include generated code
src/main/java/com/codemp/intellij/jni
src/main/resources/*.so
src/main/resources/*.dll

View file

@ -24,6 +24,16 @@ intellij {
type.set("IC")
}
def cargoDir = projectDir.toPath().resolve("target").resolve("release").toFile()
processResources {
from(cargoDir) {
include("*.dll")
include("*.so")
into("natives/")
}
}
tasks {
patchPluginXml {
sinceBuild.set("222")
@ -44,21 +54,11 @@ tasks {
//run cargo build
tasks.register('cargoBuild', Exec) {
workingDir '.'
commandLine 'cargo', 'build'
commandLine 'cargo', 'build', '--release'
}
compileJava.dependsOn cargoBuild
//copy the generated binary into the resources folder
tasks.register('copyBinary', Copy) {
from "target/debug"
into "src/main/resources"
include "*.so", "*.dll"
dependsOn cargoBuild
}
patchPluginXml.dependsOn copyBinary
//delete old jni generated files
tasks.register('deleteGeneratedNativeInterface', Delete) {
delete 'src/main/java/com/codemp/intellij/jni'

View file

@ -21,8 +21,8 @@ public class CodeMP {
if(!loadedLibrary) {
try {
if(SystemInfo.isWindows) //TODO on win for some reason it bundles it twice
NativeUtils.loadLibraryFromJar("/codemp_intellij.dll");
else NativeUtils.loadLibraryFromJar("/libcodemp_intellij.so");
NativeUtils.loadLibraryFromJar("/natives/codemp_intellij.dll");
else NativeUtils.loadLibraryFromJar("/natives/libcodemp_intellij.so");
} catch(IOException e) {
throw new RuntimeException(e);
} finally {