Skip to content

Commit

Permalink
Update main release workflow (eclipse-zenoh#133)
Browse files Browse the repository at this point in the history
* Using 'android' property to enable/disable Android configuration (eclipse-zenoh#127)

* Enabling snapshot publications for dev/1.0.0

* refactor(gradle): using 'android' property to enable/disable Android configuration

Examples:
- `gradle build -Pandroid=true` enables build with android
- `gradle build` won't consider any android configuration
- `gradle publishAndroidReleaseToMavenLocal -Pandroid=true` publishes to maven local,
	without `-Pandroid=true` it won't work.

* refactor(gradle): updating publication workflows

* refactor(gradle): updating readme instructions

---------

Co-authored-by: zettascale-bot <161707711+zettascale-bot@users.noreply.github.com>

* fix(local publication): triggering compilation of zenoh jni when publishing jvm to maven local (eclipse-zenoh#128)

* Update actions (eclipse-zenoh#130)

* chore: Update setup-java to v4

* chore: update gradle action to newer version

* chore: update gradle/wrapper-validation-action@v3

---------

Co-authored-by: Darius Maitia <darius@zettascale.tech>
Co-authored-by: zettascale-bot <161707711+zettascale-bot@users.noreply.github.com>
  • Loading branch information
3 people committed Aug 5, 2024
1 parent 4a6c49c commit 009de2f
Showing 1 changed file with 100 additions and 0 deletions.
100 changes: 100 additions & 0 deletions zenoh-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,103 @@ fun Project.configureCargo() {
)
}
}

tasks.named("compileKotlinJvm") {
dependsOn("buildZenohJni")
}

tasks.register("buildZenohJni") {
doLast {
if (!githubPublish) {
// This is intended for local publications. For publications done through GitHub workflows,
// the zenoh-jni build is achieved and loaded differently from the CI
buildZenohJNI(buildMode)
}
}
}

fun buildZenohJNI(mode: BuildMode = BuildMode.DEBUG) {
val cargoCommand = mutableListOf("cargo", "build")

if (mode == BuildMode.RELEASE) {
cargoCommand.add("--release")
}

val result = project.exec {
commandLine(*(cargoCommand.toTypedArray()), "--manifest-path", "../zenoh-jni/Cargo.toml")
}

if (result.exitValue != 0) {
throw GradleException("Failed to build Zenoh-JNI.")
}

Thread.sleep(1000)
}

enum class BuildMode {
DEBUG {
override fun toString(): String {
return "debug"
}
},
RELEASE {
override fun toString(): String {
return "release"
}
}
}

fun Project.configureAndroid() {
extensions.configure<com.android.build.gradle.LibraryExtension>("android") {
namespace = "io.zenoh"
compileSdk = 30

ndkVersion = "26.0.10792818"

defaultConfig {
minSdk = 30
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

buildTypes {
getByName("release") {
isMinifyEnabled = false
}
getByName("debug") {
isMinifyEnabled = false
}
}
sourceSets {
getByName("main") {
manifest.srcFile("src/androidMain/AndroidManifest.xml")
}
}
publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}
}
}
}

fun Project.configureCargo() {
extensions.configure<CargoExtension>("cargo") {
pythonCommand = "python3"
module = "../zenoh-jni"
libname = "zenoh-jni"
targetIncludes = arrayOf("libzenoh_jni.so")
targetDirectory = "../zenoh-jni/target/"
profile = "release"
targets = arrayListOf(
"arm",
"arm64",
"x86",
"x86_64",
)
}
}

0 comments on commit 009de2f

Please sign in to comment.