Skip to content

Commit

Permalink
Patch POM to include compile dependencies (#162)
Browse files Browse the repository at this point in the history
The ffmpeg decoder extension implicitly depends on the androidx.media3 media3-decoder and media3-exoplayer modules, but didn't publish this in its Maven POM. Because Gradle depends on this information for things like bytecode transformations, this could cause apps using this library to crash if required rewrites weren't applied to this library as well.
Thus, we now manually modify the POM to explicitly depend on the public versions of the library dependencies specified in androidx/media:libraries/decoder_ffmpeg/build.gradle.
  • Loading branch information
Maxr1998 authored Apr 25, 2024
1 parent b097f81 commit ce6e646
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions media3-ffmpeg-decoder/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.api.LibraryVariant
import com.android.build.gradle.tasks.BundleAar
import groovy.namespace.QName
import groovy.util.Node

plugins {
`maven-publish`
signing
}

val decoderProject = project(":androidx-media-lib-decoder-ffmpeg")
val decoderReleaseVersion = checkNotNull(decoderProject.ext["releaseVersion"]?.toString()) {
"Couldn't read release version from androidx.media3 project"
}
val androidExtension = decoderProject.extensions.findByType(LibraryExtension::class.java)
?: error("Could not find android extension")

Expand Down Expand Up @@ -60,6 +65,8 @@ afterEvaluate {
artifact(javadocJar)
artifact(sourcesJar)

println("Version: $decoderReleaseVersion")

pom {
name.set("Jellyfin AndroidX Media3 libraries - $artifactId")
description.set("AndroidX Media3 FFmpeg decoder used in the Jellyfin project")
Expand Down Expand Up @@ -95,6 +102,14 @@ afterEvaluate {
organizationUrl.set("https://jellyfin.org")
}
}

withXml {
// Make implicit dependency on androidx.media3 modules explicit by including them in the POM
asNode().getOrCreateNode("dependencies").apply {
appendDependency("androidx.media3", "media3-decoder", decoderReleaseVersion)
appendDependency("androidx.media3", "media3-exoplayer", decoderReleaseVersion)
}
}
}
}

Expand All @@ -110,3 +125,17 @@ afterEvaluate {
}
}
}

fun Node.getOrCreateNode(name: String): Node {
return getAt(QName(name)).firstOrNull() as Node? ?: appendNode(name)
}

fun Node.appendDependency(group: String, id: String, version: String) {
appendNode("dependency").apply {
appendNode("groupId", group)
appendNode("artifactId", id)
appendNode("version", version)
appendNode("scope", "compile")
appendNode("type", "aar")
}
}

0 comments on commit ce6e646

Please sign in to comment.