Files
libsignal/java/client/build.gradle
Jordan Rose 4b87577969 java: Print all test outcomes as they run (not just passes)
Failures would still have been caught in the aggregate test results;
but if we're going to print successes we should print skips and
failures too. (This was just an oversight.)
2024-04-17 10:21:41 -07:00

169 lines
4.7 KiB
Groovy

buildscript {
dependencies {
// This isn't compatible with the `plugins` lookup method, so it has to
// be declared in a `buildscript` block. See
// https://github.com/gradle/gradle/issues/1541 for info.
classpath 'com.guardsquare:proguard-gradle:7.4.2'
}
}
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
}
sourceCompatibility = 17
archivesBaseName = "libsignal-client"
repositories {
mavenCentral()
mavenLocal()
}
sourceSets {
main {
java {
// Include libsignal sources shared between the client and server
srcDir '../shared/java'
}
resources {
srcDir '../shared/resources'
}
}
test {
java {
srcDir '../shared/test/java'
}
}
}
dependencies {
testImplementation 'junit:junit:4.13'
}
test {
jvmArgs '-Xcheck:jni'
testLogging {
events 'passed','skipped','failed'
showStandardStreams = true
showExceptions true
exceptionFormat 'full'
showCauses true
showStackTraces true
}
}
java {
withSourcesJar()
withJavadocJar()
}
tasks.named('jar') {
manifest {
attributes('Automatic-Module-Name': 'org.signal.libsignal')
}
}
processResources {
// TODO: Build a different variant of the JNI library for server.
dependsOn ':makeJniLibrariesDesktop'
}
task proguard(type: proguard.gradle.ProGuardTask) {
dependsOn jar
injars jar.archiveFile
// Include the runtime classes (java.lang.Class, for example)
libraryjars "${System.getProperty('java.home')}/jmods/java.base.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
configuration '../shared/resources/META-INF/proguard/libsignal.pro'
// Assume for reachability purposes that all public methods are reachable.
// This isn't a perfect proxy for analysis under whole-program minimization
// since not all public methods end up being used, but it's good enough.
// The worry is that an unused-but-public method might call some non-public
// method, so our analysis here would find the second one reachable, but
// whole-program minimization would detect it as unreachable. This is
// unlikely enough in practice that we aren't going to try harder to catch
// it.
keep 'public class org.signal.libsignal.** { public *; }'
def destinationDirectory = layout.buildDirectory.dir("proguard").get()
outputs.dir(destinationDirectory)
printseeds destinationDirectory.file("seeds.txt")
printusage destinationDirectory.file("usage.txt")
printmapping destinationDirectory.file("mapping.txt")
}
task diffUnusedProguard {
dependsOn proguard
def expected = file('./proguard-usage.txt.expected')
def actual = proguard.outputs.getFiles().filter({ f -> f.name == "usage.txt"}).singleFile
inputs.file(expected)
inputs.file(actual)
doLast {
if (expected.text != actual.text) {
logger.error "${expected} and ${actual} differ"
logger.error "==== Begin expected contents"
logger.error expected.text
logger.error "==== End expected contents"
logger.error "==== Begin actual contents"
logger.error actual.text
logger.error "==== End actual contents"
logger.error "If this is expected, run the following to fix this:"
logger.error "\$ cp ${actual} ${expected}"
throw new GradleException("${expected} and ${actual} differ")
}
}
}
test {
dependsOn diffUnusedProguard
}
// MARK: Publishing
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = archivesBaseName
from components.java
pom {
name = archivesBaseName
description = 'Signal Protocol cryptography library for Java'
url = 'https://github.com/signalapp/libsignal'
scm {
url = 'scm:git@github.com:signalapp/libsignal.git'
connection = 'scm:git@github.com:signalapp/libsignal.git'
developerConnection = 'scm:git@github.com:signalapp/libsignal.git'
}
licenses {
license {
name = 'AGPLv3'
url = 'https://www.gnu.org/licenses/agpl-3.0.txt'
}
}
developers {
developer {
name = 'Signal Messenger LLC'
}
}
}
}
}
}
setUpSigningKey(signing)
signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask(":client:publish") }
sign publishing.publications.mavenJava
}