// The Android library (AAR): the platform-free half (../core/src/main), the player and attention // integration (src/main), and the JNI layer's libraries for each ABI, built out of band by // scripts/build-native.sh android with the NDK pinned below. // // Published with maven-publish as science.transaction.wai:wai-sink:, the version of // wai/wai-rs/Cargo.toml (the toolchain's) unless -Pwai.version gives it: to the repository // `staging` (build/staging-repo, which scripts/check-publication.sh reads), and, with // -Pwai.maven.url, to the repository `forge` there, its token from the environment variable // WAI_PACKAGES_TOKEN. import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { id("com.android.library") id("org.jetbrains.kotlin.android") id("maven-publish") } val waiVersion: String = providers.gradleProperty("wai.version").orNull ?: Regex("""(?m)^version = "([^"]+)"$""").find(file("../../wai-rs/Cargo.toml").readText())?.groupValues?.get(1) ?: error("no version in wai/wai-rs/Cargo.toml") android { // The package of the library's manifest: the publication's group and the library's name. // The Kotlin classes keep their package, wai.sink, which the JNI layer's symbols name. namespace = "science.transaction.wai.sink" compileSdk = 36 ndkVersion = "29.0.14206865" defaultConfig { minSdk = 24 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") } sourceSets { getByName("main") { kotlin.srcDir("../core/src/main/kotlin") jniLibs.srcDir(layout.buildDirectory.dir("jniLibs")) } getByName("androidTest") { kotlin.srcDir("../core/src/testkit/kotlin") assets.srcDir("../../live-conformance/native-sink") // The integer decode's cases and the files they name, under wai/, staged by // scripts/test-emulator.sh (core/src/testkit/int-cases.json). assets.srcDir(layout.buildDirectory.dir("int-assets")) } } compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } packaging { jniLibs { useLegacyPackaging = false } } buildFeatures { buildConfig = false } publishing { singleVariant("release") { withSourcesJar() } } } kotlin { compilerOptions { jvmTarget.set(JvmTarget.JVM_17) allWarningsAsErrors.set(true) } } dependencies { // The platform's media player library, and its HTTP presentations module. api("androidx.media3:media3-exoplayer:1.11.1") api("androidx.media3:media3-exoplayer-hls:1.11.1") androidTestImplementation("androidx.test:runner:1.7.0") androidTestImplementation("androidx.test:core:1.7.0") androidTestImplementation("androidx.test.ext:junit:1.3.0") androidTestImplementation("junit:junit:4.13.2") } publishing { publications { register("release") { groupId = "science.transaction.wai" artifactId = "wai-sink" version = waiVersion afterEvaluate { from(components["release"]) } pom { name.set("wai-sink") description.set("The WAI native sink for the platform player: libwai's C interface through JNI, the loopback relay, and the player and attention integration (extensions/native-sink.md).") url.set("https://wai.transaction.science") licenses { license { name.set("Apache-2.0") url.set("https://www.apache.org/licenses/LICENSE-2.0") } } scm { url.set("https://git.transaction.science/Transaction-Science/open-standards") } } } } repositories { maven { name = "staging" url = uri(layout.buildDirectory.dir("staging-repo")) } providers.gradleProperty("wai.maven.url").orNull?.let { target -> maven { name = "forge" url = uri(target) // The forge's own address on the private network, which has no TLS. isAllowInsecureProtocol = target.startsWith("http://") credentials(HttpHeaderCredentials::class) { name = "Authorization" value = "token " + (providers.environmentVariable("WAI_PACKAGES_TOKEN").orNull ?: error("publishing to $target needs the environment variable WAI_PACKAGES_TOKEN")) } authentication { create("header") } } } } }