-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate Kotlin bindings into its own module
- Loading branch information
Showing
6 changed files
with
119 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
cd ./native/kotlin | ||
./gradlew \ | ||
:api:bindings:prepareToPublishToS3 $(prepare_to_publish_to_s3_params) \ | ||
:api:bindings:publish | ||
|
||
# Add meta-data for the published version so we can use it in subsequent steps | ||
buildkite-agent meta-data set "PUBLISHED_WP_API_BINDINGS_VERSION" < ./api/bindings/build/published-version.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
plugins { | ||
alias(libs.plugins.rustAndroid) | ||
alias(libs.plugins.kotlinJvm) | ||
alias(libs.plugins.publishToS3) | ||
id("java-library") | ||
} | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
toolchain { | ||
languageVersion.set(JavaLanguageVersion.of(17)) | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation(libs.jna) | ||
implementation(libs.kotlinx.coroutines.core) | ||
} | ||
|
||
sourceSets { | ||
main { | ||
java { | ||
srcDir("${layout.buildDirectory.get()}/generated/source/uniffi/java/uniffi") | ||
} | ||
} | ||
} | ||
|
||
val generateUniFFIBindingsTask = tasks.register<Exec>("generateUniFFIBindings") { | ||
val cargoProjectRoot = rootProject.ext.get("cargoProjectRoot") | ||
val uniffiGeneratedPath = "${layout.buildDirectory.get()}/generated/source/uniffi/java" | ||
val nativeLibraryPath = rootProject.ext.get("nativeLibraryPath")!! | ||
val rustModuleName = rootProject.ext.get("rustModuleName") | ||
|
||
dependsOn(rootProject.tasks.named("cargoBuildLibraryRelease")) | ||
workingDir(project.rootDir) | ||
commandLine( | ||
"cargo", | ||
"run", | ||
"--release", | ||
"--bin", | ||
"wp_uniffi_bindgen", | ||
"generate", | ||
"--library", | ||
nativeLibraryPath, | ||
"--out-dir", | ||
uniffiGeneratedPath, | ||
"--language", | ||
"kotlin" | ||
) | ||
outputs.dir(uniffiGeneratedPath) | ||
// Re-generate if the interface definition changes. | ||
inputs.file(nativeLibraryPath) | ||
// Re-generate if our uniffi-bindgen tooling changes. | ||
inputs.dir("$cargoProjectRoot/wp_uniffi_bindgen/") | ||
// Re-generate if our uniffi-bindgen version changes. | ||
inputs.file("$cargoProjectRoot/Cargo.lock") | ||
// Re-generate if the module source code changes | ||
inputs.dir("$cargoProjectRoot/$rustModuleName/") | ||
} | ||
|
||
tasks.named("compileKotlin").configure { | ||
dependsOn(generateUniFFIBindingsTask) | ||
} | ||
|
||
project.afterEvaluate { | ||
publishing { | ||
publications { | ||
create<MavenPublication>("maven") { | ||
from(components["java"]) | ||
|
||
groupId = "rs.wordpress.api" | ||
artifactId = "bindings" | ||
// version is set by "publish-to-s3" plugin | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters