Exclude unused shared objects/jni, reducing the jar final size by ~4.5x
Thanks earth for helping with hell
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,6 @@
|
|||||||
# Project exclude paths
|
# Project exclude paths
|
||||||
/.gradle/
|
/.gradle/
|
||||||
|
/.idea/
|
||||||
/build/
|
/build/
|
||||||
|
/run/
|
||||||
|
/out/
|
||||||
|
|||||||
33
build.gradle
33
build.gradle
@@ -126,6 +126,39 @@ jar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.register('excludeUnused', Zip) {
|
||||||
|
//outputs.upToDateWhen { false }
|
||||||
|
archiveExtension.set("jar")
|
||||||
|
entryCompression(ZipEntryCompression.STORED)
|
||||||
|
destinationDirectory.set temporaryDir
|
||||||
|
archiveFileName.set processIncludeJars.outputDirectory.asFileTree.filter {
|
||||||
|
it.name.startsWith('rocksdb')
|
||||||
|
}.first().name
|
||||||
|
processIncludeJars.outputDirectory.asFileTree.each {
|
||||||
|
if (it.name.startsWith('rocksdb')) {
|
||||||
|
from zipTree(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exclude {
|
||||||
|
def file = it.name
|
||||||
|
if (file.endsWith(".jnilib")) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (!file.endsWith(".so")) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return ["osx", "linux32", "s390x", "riscv64", "ppc64le", "aarch64"].any(file::contains)
|
||||||
|
}
|
||||||
|
dependsOn processIncludeJars
|
||||||
|
}
|
||||||
|
|
||||||
|
remapJar {
|
||||||
|
nestedJars = nestedJars.filter {
|
||||||
|
!it.name.startsWith('rocksdb')
|
||||||
|
}
|
||||||
|
nestedJars.from excludeUnused
|
||||||
|
}
|
||||||
|
|
||||||
project.ext.lwjglVersion = "3.3.3"
|
project.ext.lwjglVersion = "3.3.3"
|
||||||
project.ext.lwjglNatives = "natives-windows"
|
project.ext.lwjglNatives = "natives-windows"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user