Files
libsignal/java/build.gradle
Jordan Rose b2c2537277 java: Switch from javadoc to Dokka to include our Kotlin sources
The Maven publication will still contain a -javadoc jar for
consistency, but the -dokka jar is likely to have superior rendering
in practice, particularly for Kotlin-only APIs!
2025-06-18 10:57:50 -07:00

140 lines
4.4 KiB
Groovy

import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id "base"
id "signing"
id "com.diffplug.spotless" version "6.20.0"
id "io.github.gradle-nexus.publish-plugin" version "2.0.0"
id "org.jetbrains.kotlin.jvm" version "2.1.0"
id "org.jetbrains.dokka" version "2.0.0"
// These plugins need to be loaded together, so we must declare them up front.
id 'com.android.library' version "8.9.0" apply false
id 'org.jetbrains.kotlin.android' version "2.1.0" apply false
}
allprojects {
version = "0.75.2"
group = "org.signal"
tasks.withType(KotlinCompile).configureEach {
compilerOptions.jvmTarget = JvmTarget.JVM_17
}
}
subprojects {
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
allprojects {
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.compilerArgs += ["-Xlint:deprecation", "-Xlint:fallthrough", "-Xlint:unchecked"]
}
tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
}
apply plugin: "com.diffplug.spotless"
apply plugin: "org.jetbrains.dokka"
spotless {
kotlin {
target('**/*.kt')
targetExclude("**/acknowledgments/**")
ktlint()
}
java {
target('**/*.java')
targetExclude('**/Native.java', '**/NativeTesting.java')
importOrder()
removeUnusedImports()
googleJavaFormat()
formatAnnotations()
licenseHeaderFile rootProject.file('license_header.txt')
}
}
}
task makeJniLibrariesDesktop(type:Exec) {
group 'Rust'
description 'Build the JNI libraries'
def debugLevelLogsFlag = project.hasProperty('debugLevelLogs') ? ['--debug-level-logs'] : []
def jniTypeTaggingFlag = project.hasProperty('jniTypeTagging') ? ['--jni-type-tagging'] : []
def jniCheckAnnotationsFlag = project.hasProperty('jniCheckAnnotations') ? ['--jni-check-annotations'] : []
def debugFlag = project.hasProperty('debugRust') ? ['--debug'] : []
// Explicitly specify 'bash' for Windows compatibility.
commandLine 'bash', './build_jni.sh', *debugLevelLogsFlag, *jniTypeTaggingFlag, *jniCheckAnnotationsFlag, *debugFlag, 'desktop'
}
task makeJniLibrariesServer(type:Exec) {
group 'Rust'
description 'Build the JNI libraries'
def debugLevelLogsFlag = project.hasProperty('debugLevelLogs') ? ['--debug-level-logs'] : []
def jniTypeTaggingFlag = project.hasProperty('jniTypeTagging') ? ['--jni-type-tagging'] : []
def jniCheckAnnotationsFlag = project.hasProperty('jniCheckAnnotations') ? ['--jni-check-annotations'] : []
def debugFlag = project.hasProperty('debugRust') ? ['--debug'] : []
def target = project.hasProperty('crossCompileServer') ? 'server-all' : 'server'
// Explicitly specify 'bash' for Windows compatibility.
commandLine 'bash', './build_jni.sh', *debugLevelLogsFlag, *jniTypeTaggingFlag, *jniCheckAnnotationsFlag, *debugFlag, target
}
task cargoClean(type:Exec) {
group 'Rust'
commandLine 'cargo', 'clean'
}
task cleanJni(type: Delete) {
description 'Clean JNI libs'
delete fileTree('./android/src/main/jniLibs') {
include '**/*.so'
}
delete fileTree('./client/src/main/resources') {
include '**/*.so'
include '**/*.dylib'
include '**/*.dll'
}
delete fileTree('./server/src/main/resources') {
include '**/*.so'
include '**/*.dylib'
include '**/*.dll'
}
}
clean.dependsOn([cargoClean, cleanJni])
// PUBLISHING
ext.setUpSigningKey = { signingExt ->
def signingKeyId = findProperty("signingKeyId")
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
if (signingKeyId && signingKey && signingPassword) {
signingExt.useInMemoryPgpKeys(signingKeyId.trim(), signingKey.trim(), signingPassword.trim())
}
}
nexusPublishing {
repositories {
sonatype {
username = project.findProperty('sonatypeUsername') ?: ""
password = project.findProperty('sonatypePassword') ?: ""
}
}
}
def isReleaseBuild() {
return version.contains("SNAPSHOT") == false
}