Skip to content

Commit

Permalink
Java: Build fix default download hash and dependancy ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
rozza committed Jan 30, 2023
1 parent 3f47e35 commit eef73b8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions bindings/java/mongocrypt/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,15 @@ val gitDescribe by lazy {
val isJavaTag by lazy { gitDescribe.startsWith("java") }
val gitVersion by lazy { gitDescribe.subSequence(gitDescribe.toCharArray().indexOfFirst { it.isDigit() }, gitDescribe.length).toString() }

val gitHash: String by lazy {
val defaultDownloadRevision: String by lazy {
val gitCommandLine = if (gitVersion == version) {
listOf("git", "rev-list", "-n", "1", gitVersion)
} else {
listOf("git", "rev-parse", "HEAD")
}
val describeStdOut = ByteArrayOutputStream()
exec {
commandLine = listOf("git", "rev-parse", "HEAD")
commandLine = gitCommandLine
standardOutput = describeStdOut
}
describeStdOut.toString().trim()
Expand All @@ -99,8 +104,8 @@ val jnaLibsPath: String = System.getProperty("jnaLibsPath", "${jnaResourcesDir}$
val jnaResources: String = System.getProperty("jna.library.path", jnaLibsPath)

// Download jnaLibs that match the git to jnaResourcesBuildDir
val revision: String = System.getProperty("gitRevision", if (gitVersion == version) gitVersion else gitHash)
val downloadUrl: String = "https://mciuploads.s3.amazonaws.com/libmongocrypt/java/$revision/libmongocrypt-java.tar.gz"
val downloadRevision: String = System.getProperty("gitRevision", defaultDownloadRevision)
val downloadUrl: String = "https://mciuploads.s3.amazonaws.com/libmongocrypt/java/$downloadRevision/libmongocrypt-java.tar.gz"

val jnaMapping: Map<String, String> = mapOf(
"rhel-62-64-bit" to "linux-x86-64",
Expand Down Expand Up @@ -308,6 +313,7 @@ tasks.register("publishToSonatype") {
if (isRelease) {
dependsOn("downloadJnaLibs")
dependsOn(tasks.withType<PublishToMavenRepository>())
tasks.withType<PublishToMavenRepository>().forEach { t -> t.mustRunAfter("downloadJnaLibs") }
}
}

Expand Down

0 comments on commit eef73b8

Please sign in to comment.