mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Exclude libsignal-client testing libraries
This commit is contained in:
parent
68b7416e57
commit
b92cbc6a7c
3 changed files with 91 additions and 4 deletions
|
@ -46,7 +46,41 @@ graalvmNative {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val artifactType = Attribute.of("artifactType", String::class.java)
|
||||||
|
val minified = Attribute.of("minified", Boolean::class.javaObjectType)
|
||||||
dependencies {
|
dependencies {
|
||||||
|
attributesSchema {
|
||||||
|
attribute(minified)
|
||||||
|
}
|
||||||
|
artifactTypes.getByName("jar") {
|
||||||
|
attributes.attribute(minified, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations.runtimeClasspath.configure {
|
||||||
|
attributes {
|
||||||
|
attribute(minified, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val excludePatterns = mapOf(
|
||||||
|
"libsignal-client" to setOf(
|
||||||
|
"libsignal_jni_testing_amd64.so",
|
||||||
|
"signal_jni_testing_amd64.dll",
|
||||||
|
"libsignal_jni_testing_amd64.dylib",
|
||||||
|
"libsignal_jni_testing_aarch64.dylib",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
registerTransform(JarFileExcluder::class) {
|
||||||
|
from.attribute(minified, false).attribute(artifactType, "jar")
|
||||||
|
to.attribute(minified, true).attribute(artifactType, "jar")
|
||||||
|
|
||||||
|
parameters {
|
||||||
|
excludeFilesByArtifact = excludePatterns
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
implementation(libs.bouncycastle)
|
implementation(libs.bouncycastle)
|
||||||
implementation(libs.jackson.databind)
|
implementation(libs.jackson.databind)
|
||||||
implementation(libs.argparse4j)
|
implementation(libs.argparse4j)
|
||||||
|
@ -92,9 +126,11 @@ tasks.register("fatJar", type = Jar::class) {
|
||||||
"META-INF/NOTICE*",
|
"META-INF/NOTICE*",
|
||||||
"META-INF/LICENSE*",
|
"META-INF/LICENSE*",
|
||||||
"META-INF/INDEX.LIST",
|
"META-INF/INDEX.LIST",
|
||||||
"**/module-info.class"
|
"**/module-info.class",
|
||||||
)
|
)
|
||||||
duplicatesStrategy = DuplicatesStrategy.WARN
|
duplicatesStrategy = DuplicatesStrategy.WARN
|
||||||
from(configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
|
doFirst {
|
||||||
|
from(configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
|
||||||
|
}
|
||||||
with(tasks.jar.get())
|
with(tasks.jar.get())
|
||||||
}
|
}
|
||||||
|
|
53
buildSrc/src/main/kotlin/ExcludeFileFromJar.kt
Normal file
53
buildSrc/src/main/kotlin/ExcludeFileFromJar.kt
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
import org.gradle.api.artifacts.transform.*
|
||||||
|
import org.gradle.api.file.FileSystemLocation
|
||||||
|
import org.gradle.api.provider.Provider
|
||||||
|
import org.gradle.api.tasks.Input
|
||||||
|
import org.gradle.api.tasks.PathSensitive
|
||||||
|
import org.gradle.api.tasks.PathSensitivity
|
||||||
|
import java.io.File
|
||||||
|
import java.io.FileInputStream
|
||||||
|
import java.io.FileOutputStream
|
||||||
|
import java.util.zip.ZipInputStream
|
||||||
|
import java.util.zip.ZipOutputStream
|
||||||
|
|
||||||
|
@CacheableTransform
|
||||||
|
abstract class JarFileExcluder : TransformAction<JarFileExcluder.Parameters> {
|
||||||
|
interface Parameters : TransformParameters {
|
||||||
|
@get:Input
|
||||||
|
var excludeFilesByArtifact: Map<String, Set<String>>
|
||||||
|
}
|
||||||
|
|
||||||
|
@get:PathSensitive(PathSensitivity.NAME_ONLY)
|
||||||
|
@get:InputArtifact
|
||||||
|
abstract val inputArtifact: Provider<FileSystemLocation>
|
||||||
|
|
||||||
|
override
|
||||||
|
fun transform(outputs: TransformOutputs) {
|
||||||
|
val fileName = inputArtifact.get().asFile.name
|
||||||
|
for (entry in parameters.excludeFilesByArtifact) {
|
||||||
|
if (fileName.startsWith(entry.key)) {
|
||||||
|
val nameWithoutExtension = fileName.substring(0, fileName.lastIndexOf("."))
|
||||||
|
excludeFiles(inputArtifact.get().asFile, entry.value, outputs.file("${nameWithoutExtension}.jar"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outputs.file(inputArtifact)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun excludeFiles(artifact: File, excludeFiles: Set<String>, jarFile: File) {
|
||||||
|
ZipInputStream(FileInputStream(artifact)).use { input ->
|
||||||
|
ZipOutputStream(FileOutputStream(jarFile)).use { output ->
|
||||||
|
var entry = input.nextEntry
|
||||||
|
while (entry != null) {
|
||||||
|
if (!excludeFiles.contains(entry.name)) {
|
||||||
|
output.putNextEntry(entry)
|
||||||
|
input.copyTo(output)
|
||||||
|
output.closeEntry()
|
||||||
|
}
|
||||||
|
|
||||||
|
entry = input.nextEntry
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -188,8 +188,6 @@
|
||||||
"pattern":"\\Qlibsignal_jni_amd64.dylib\\E"
|
"pattern":"\\Qlibsignal_jni_amd64.dylib\\E"
|
||||||
}, {
|
}, {
|
||||||
"pattern":"\\Qlibsignal_jni_amd64.so\\E"
|
"pattern":"\\Qlibsignal_jni_amd64.so\\E"
|
||||||
}, {
|
|
||||||
"pattern":"\\Qlibsignal_jni_testing_amd64.so\\E"
|
|
||||||
}, {
|
}, {
|
||||||
"pattern":"\\Qorg/asamk/signal/manager/config/ias.store\\E"
|
"pattern":"\\Qorg/asamk/signal/manager/config/ias.store\\E"
|
||||||
}, {
|
}, {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue