Remove intermediate tasks from Bitcoindevkit group

This ensures they don't show up when using ./gradlew :jvm:tasks. The
only two tasks that will appear in the end will be buildJvmLib and
buildAndroidLib.
This commit is contained in:
thunderbiscuit 2022-04-05 22:17:12 -04:00
parent 35f097542b
commit e566c4017c
No known key found for this signature in database
GPG Key ID: 88253696EB836462
3 changed files with 22 additions and 11 deletions

View File

@ -1,4 +1,4 @@
package org.bitcoindevkit.plugin package org.bitcoindevkit.plugins
enum class Arch { enum class Arch {
AARCH64, AARCH64,

View File

@ -1,4 +1,4 @@
package org.bitcoindevkit.plugin package org.bitcoindevkit.plugins
val operatingSystem: OS = when { val operatingSystem: OS = when {
System.getProperty("os.name").contains("mac", ignoreCase = true) -> OS.MAC System.getProperty("os.name").contains("mac", ignoreCase = true) -> OS.MAC
@ -11,9 +11,12 @@ val architecture: Arch = when (System.getProperty("os.arch")) {
else -> Arch.OTHER else -> Arch.OTHER
} }
// register a task of type Exec called buildJvmBinary
// which will run something like
// cargo build --release --target aarch64-apple-darwin
val buildJvmBinary by tasks.register<Exec>("buildJvmBinary") { val buildJvmBinary by tasks.register<Exec>("buildJvmBinary") {
group = "Bitcoindevkit" // group = "Bitcoindevkit"
description = "Build the JVM binaries for the bitcoindevkit" // description = "Build the JVM binaries for the bitcoindevkit"
workingDir("${project.projectDir}/../bdk-ffi") workingDir("${project.projectDir}/../bdk-ffi")
val cargoArgs: MutableList<String> = mutableListOf("build", "--release", "--target") val cargoArgs: MutableList<String> = mutableListOf("build", "--release", "--target")
@ -34,9 +37,11 @@ val buildJvmBinary by tasks.register<Exec>("buildJvmBinary") {
} }
} }
// move the native libs build by cargo from bdk-ffi/target/.../release/
// to their place in the bdk-jvm library
val moveNativeJvmLib by tasks.register<Copy>("moveNativeJvmLib") { val moveNativeJvmLib by tasks.register<Copy>("moveNativeJvmLib") {
group = "Bitcoindevkit" // group = "Bitcoindevkit"
description = "Move the native libraries to the bdk-jvm project" // description = "Move the native libraries to the bdk-jvm project"
dependsOn(buildJvmBinary) dependsOn(buildJvmBinary)
var targetDir = "" var targetDir = ""
@ -60,14 +65,16 @@ val moveNativeJvmLib by tasks.register<Copy>("moveNativeJvmLib") {
} }
} }
// generate the bindings using the bdk-ffi-bindgen tool
// created in the bdk-ffi submodule
val generateJvmBindings by tasks.register<Exec>("generateJvmBindings") { val generateJvmBindings by tasks.register<Exec>("generateJvmBindings") {
group = "Bitcoindevkit" // group = "Bitcoindevkit"
description = "Building the bindings file for the bitcoindevkit" // description = "Building the bindings file for the bitcoindevkit"
dependsOn(moveNativeJvmLib) dependsOn(moveNativeJvmLib)
workingDir("${project.projectDir}/../bdk-ffi") workingDir("${project.projectDir}/../bdk-ffi")
executable("uniffi-bindgen") executable("cargo")
args("generate", "./src/bdk.udl", "--no-format", "--out-dir", "../jvm/src/main/kotlin", "--language", "kotlin") args("run", "--package", "bdk-ffi-bindgen", "--", "--language", "kotlin", "--out-dir", "../jvm/src/main/kotlin")
doLast { doLast {
println("JVM bindings file successfully created") println("JVM bindings file successfully created")

View File

@ -6,8 +6,12 @@ plugins {
id("java-library") id("java-library")
id("maven-publish") id("maven-publish")
id("signing") id("signing")
// API docs
id("org.jetbrains.dokka") version "1.6.10" id("org.jetbrains.dokka") version "1.6.10"
id("org.bitcoindevkit.plugin.generate-bdk-bindings")
// Custom plugin to generate the native libs and bindings file
id("org.bitcoindevkit.plugins.generate-jvm-bindings")
} }
java { java {