Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 3 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# bdk-jvm

This project builds a .jar package for the JVM platform that provides Kotlin language bindings for the [BDK] libraries. The Kotlin language bindings are created by the `bdk-ffi` project which is included in the root of this repository.
This project builds a .jar package for the JVM platform that provides Kotlin language bindings for the [BDK] libraries. The Kotlin language bindings are created by the [`bdk-ffi`] project which is included in the root of this repository.

## How to Use

To use the Kotlin language bindings for BDK in your JVM project add the following to your gradle dependencies:
To use the Kotlin language bindings for BDK in your JVM project, add the following to your Gradle dependencies:

```kotlin
repositories {
Expand All @@ -16,20 +16,6 @@ dependencies {
}
```

### Snapshot releases

To use a snapshot release, specify the snapshot repository url in the `repositories` block and use the snapshot version in the `dependencies` block:

```kotlin
repositories {
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}

dependencies {
implementation("org.bitcoindevkit:bdk-jvm:<version-SNAPSHOT>")
}
```

## Example Projects

- [Tatooine Faucet](https://github.com/thunderbiscuit/tatooine)
Expand Down Expand Up @@ -61,20 +47,7 @@ You can also list the application tasks. (All examples grouped under application
./gradlew tasks --group application
```

## How to publish to your local Maven repo

```shell
./gradlew publishToMavenLocal -P localBuild
```

Note that the commands assume you don't need the local libraries to be signed. If you do wish to sign them, simply set your `~/.gradle/gradle.properties` signing key values like so:

```properties
signing.gnupg.keyName=<YOUR_GNUPG_ID>
signing.gnupg.passphrase=<YOUR_GNUPG_PASSPHRASE>
```

and use the `publishToMavenLocal` task without the `localBuild` flag:
## Publish to your local Maven repo

```shell
./gradlew publishToMavenLocal
Expand Down
11 changes: 2 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
plugins {
id("org.jetbrains.kotlin.jvm").version("2.1.10").apply(false)
id("org.gradle.java-library")
id("org.gradle.maven-publish")
id("org.gradle.signing")
id("org.jetbrains.kotlin.jvm").version("2.2.0").apply(false)
id("org.jetbrains.dokka").version("2.0.0").apply(false)
id("org.jetbrains.dokka-javadoc").version("2.0.0").apply(false)
id("com.vanniktech.maven.publish").version("0.36.0").apply(false)
}

// library version is defined in gradle.properties
val libraryVersion: String by project
group = "org.bitcoindevkit"
version = libraryVersion
11 changes: 3 additions & 8 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("org.jetbrains.kotlin.jvm") version "2.1.10"
id("application")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an unused plugin.

id("org.jetbrains.kotlin.jvm")
}

repositories {
Expand All @@ -11,24 +11,19 @@ repositories {

dependencies {
implementation(project(":lib"))
testImplementation(kotlin("test"))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were no tests in this module.

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")
implementation("org.slf4j:slf4j-api:2.0.16")
implementation("ch.qos.logback:logback-classic:1.5.13")
}

tasks.test {
useJUnitPlatform()
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withSourcesJar()
withJavadocJar()
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
tasks.withType<KotlinCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
org.gradle.jvmargs=-Xmx1536m
android.enableJetifier=true
kotlin.code.style=official
libraryVersion=2.4.0-SNAPSHOT
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
14 changes: 7 additions & 7 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ clean:
rm -rf ./lib/build/
rm -rf ./examples/build/
rm -rf ./examples/data/
rm -rf ./lib/src/main/kotlin/org/bitcoindevkit/*
rm -rf ./lib/src/main/resources/*

[group("Test")]
[doc("Run all tests, unless a specific test is provided.")]
Expand Down
121 changes: 56 additions & 65 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,106 +1,97 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.*
import org.gradle.api.tasks.testing.logging.TestLogEvent.*
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

// library version is defined in gradle.properties
val libraryVersion: String by project

plugins {
id("org.jetbrains.kotlin.jvm")
id("org.gradle.java-library")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an unused plugin.

id("org.gradle.maven-publish")
id("org.gradle.signing")
id("com.vanniktech.maven.publish")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two are replaced by the vannitech plugin.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its great how vanniktech clears out all the "plumbing" work

id("org.jetbrains.dokka")
id("org.jetbrains.dokka-javadoc")
}

group = "org.bitcoindevkit"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had those in other files initially because of the super old plugin we used for publishing, which we don't use anymore anyway. Bringing those here cleans up the weird locations for the versions.

version = "2.3.0-SNAPSHOT"

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withSourcesJar()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lines are now handled by the vannitech plugin.

withJavadocJar()
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "11"
tasks.withType<KotlinCompile> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the new way to declare compiler options.

compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}

testing {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was never needed.

suites {
val test by getting(JvmTestSuite::class) {
useKotlinTest("1.9.23")
}
}
}
tasks.test {
useJUnitPlatform()

tasks.withType<Test> {
testLogging {
events(PASSED, SKIPPED, FAILED, STANDARD_OUT, STANDARD_ERROR)
exceptionFormat = FULL
events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED, TestLogEvent.STANDARD_OUT)
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showStackTraces = true
showCauses = true
}
}

dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")
// JNA
implementation("net.java.dev.jna:jna:5.14.0")

// Coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")

// Tests
testImplementation(kotlin("test"))
}

afterEvaluate {
publishing {
publications {
create<MavenPublication>("maven") {
groupId = "org.bitcoindevkit"
artifactId = "bdk-jvm"
version = libraryVersion
mavenPublishing {
coordinates(
groupId = group.toString(),
artifactId = "bdk-jvm",
version = version.toString()
)

from(components["java"])
pom {
name.set("bdk-jvm")
description.set("Bitcoin Dev Kit Kotlin language bindings.")
url.set("https://bitcoindevkit.org")
licenses {
license {
name.set("APACHE 2.0")
url.set("https://github.com/bitcoindevkit/bdk/blob/master/LICENSE-APACHE")
}
license {
name.set("MIT")
url.set("https://github.com/bitcoindevkit/bdk/blob/master/LICENSE-MIT")
}
}
developers {
developer {
id.set("bdkdevelopers")
name.set("Bitcoin Dev Kit Developers")
email.set("dev@bitcoindevkit.org")
}
}
scm {
connection.set("scm:git:github.com/bitcoindevkit/bdk-ffi.git")
developerConnection.set("scm:git:ssh://github.com/bitcoindevkit/bdk-ffi.git")
url.set("https://github.com/bitcoindevkit/bdk-ffi/tree/master")
}
}
pom {
name.set("bdk-jvm")
description.set("Bitcoin Dev Kit Kotlin language bindings.")
url.set("https://bitcoindevkit.org")
inceptionYear.set("2021")
licenses {
license {
name.set("APACHE 2.0")
url.set("https://github.com/bitcoindevkit/bdk/blob/master/LICENSE-APACHE")
}
license {
name.set("MIT")
url.set("https://github.com/bitcoindevkit/bdk/blob/master/LICENSE-MIT")
}
}
developers {
developer {
id.set("bdkdevelopers")
name.set("Bitcoin Dev Kit Developers")
email.set("dev@bitcoindevkit.org")
}
}
scm {
url.set("https://github.com/bitcoindevkit/bdk-ffi/")
connection.set("scm:git:github.com/bitcoindevkit/bdk-ffi.git")
developerConnection.set("scm:git:ssh://github.com/bitcoindevkit/bdk-ffi.git")
}
}
}

signing {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed anymore, as if you publish to your local maven the vanniteck plugin doesn't require signature in the first place if your keys are not set.

if (project.hasProperty("localBuild")) {
isRequired = false
}
sign(publishing.publications)
mavenPublishing {
publishToMavenCentral()
signAllPublications()
}

dokka {
moduleName.set("bdk-jvm")
moduleVersion.set(libraryVersion)
moduleVersion.set(version.toString())
dokkaSourceSets.main {
includes.from("README.md")
sourceLink {
Expand Down