From 72607f39453e01e29bce41ee73dc6a4a33c9e556 Mon Sep 17 00:00:00 2001 From: Deep Shah Date: Mon, 10 Aug 2026 10:03:23 +0530 Subject: [PATCH] build: publish AAR + sources via maven-publish for JitPack consumption Wire both library modules for artifact publication so downstream consumers can depend on a pinned version instead of a git submodule or an ad-hoc AAR drop. The same publication block will later target Maven Central or a private registry without changing consumer coordinates. - `featbit-client` and `featbit-client-android` gain the `maven-publish` plugin and a `MavenPublication("release")` bound to the existing AGP `singleVariant("release") { withSourcesJar() }` block. Generated POMs get the usual `name`/`description`/`url`/`licenses` (Apache-2.0)/`scm` blocks. - Coordinates come from `GROUP` and `VERSION_NAME` in `gradle.properties`. The publication `version` prefers JitPack's `VERSION` env var over the gradle property so the file names on disk match the tag JitPack asked for (JitPack looks up `-.aar`, not `-0.1.0-SNAPSHOT.aar`). - New `jitpack.yml` pins the build JDK to 17 (matching CI) and points JitPack at the two-module `publishToMavenLocal` invocation so it produces both artifacts + their sources jar + POM in one pass. - `README.md` `Installation` section now documents the real JitPack coordinate (`com.github.Fluent-Health.featbit-android-sdk::`) instead of the earlier `co.featbit:*:` placeholder. Verified locally: bare `./gradlew publishToMavenLocal` publishes `co.featbit:*:0.1.0-SNAPSHOT`, and `VERSION=v0.1.0 ./gradlew publishToMavenLocal` publishes `v0.1.0` end-to-end (parent + cross-module transitive POM entries). Co-Authored-By: Claude Opus 4.7 (1M context) --- README.md | 28 ++++++++++++++++-- featbit-client-android/build.gradle.kts | 38 ++++++++++++++++++++++++ featbit-client/build.gradle.kts | 39 +++++++++++++++++++++++++ gradle.properties | 6 ++++ jitpack.yml | 16 ++++++++++ 5 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 jitpack.yml diff --git a/README.md b/README.md index 821c274..b4a3445 100644 --- a/README.md +++ b/README.md @@ -16,17 +16,41 @@ servers. For server-side use, see FeatBit's server SDKs. ### Installation -Add the dependency (coordinates depend on where you publish it): +Artifacts are built on demand by [JitPack](https://jitpack.io) whenever a consumer +requests a git tag from this repository, so no separate publish step is needed. + +Add the JitPack repository in `settings.gradle.kts`: + +```kotlin +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { url = uri("https://jitpack.io") } + } +} +``` + +Then depend on either the core SDK or, on Android, the optional lifecycle connector: ```kotlin dependencies { - implementation("co.featbit:featbit-client:") + // Core SDK — flag evaluation, polling, streaming, event tracking. + implementation("com.github.Fluent-Health.featbit-android-sdk:featbit-client:") + + // Optional: Android lifecycle glue. Depends on the core SDK transitively. + implementation("com.github.Fluent-Health.featbit-android-sdk:featbit-client-android:") } ``` +Replace `` with a released git tag (e.g. `v0.1.0`). JitPack pins the artifact to the +exact commit that tag points at, so the version you see is the version you get. + The library requires `minSdk 21` and the `INTERNET` permission (declared by the library manifest and merged automatically). +Groovy DSL is identical apart from the string form: +`implementation 'com.github.Fluent-Health.featbit-android-sdk:featbit-client:'`. + ### Prerequisite Before using the SDK, obtain your environment secret and SDK URLs: diff --git a/featbit-client-android/build.gradle.kts b/featbit-client-android/build.gradle.kts index 0daf83b..47e388b 100644 --- a/featbit-client-android/build.gradle.kts +++ b/featbit-client-android/build.gradle.kts @@ -1,6 +1,7 @@ plugins { alias(libs.plugins.android.library) alias(libs.plugins.kotlin.android) + `maven-publish` } android { @@ -37,3 +38,40 @@ dependencies { api(project(":featbit-client")) implementation(libs.androidx.lifecycle.process) } + +// Publishes the `release` AAR + sources jar under `co.featbit:featbit-client-android:`. +// See the sibling `featbit-client/build.gradle.kts` for the full rationale behind the version +// resolution rule — the same pattern is applied here so both modules pick up identical +// coordinates from JitPack's `VERSION` env var (or the `VERSION_NAME` gradle property locally). +publishing { + publications { + register("release") { + groupId = providers.gradleProperty("GROUP").get() + artifactId = "featbit-client-android" + version = System.getenv("VERSION") ?: providers.gradleProperty("VERSION_NAME").get() + afterEvaluate { from(components["release"]) } + + pom { + name.set("FeatBit Client — Android Lifecycle Connector") + description.set( + "Optional Android lifecycle glue for the FeatBit client SDK: wires " + + "ProcessLifecycleOwner + ConnectivityManager into `setForeground` / " + + "`setNetworkAvailable` so the underlying client suspends streaming while " + + "the app is backgrounded or offline." + ) + url.set("https://github.com/Fluent-Health/featbit-android-sdk") + licenses { + license { + name.set("Apache-2.0") + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + scm { + url.set("https://github.com/Fluent-Health/featbit-android-sdk") + connection.set("scm:git:https://github.com/Fluent-Health/featbit-android-sdk.git") + developerConnection.set("scm:git:ssh://git@github.com/Fluent-Health/featbit-android-sdk.git") + } + } + } + } +} diff --git a/featbit-client/build.gradle.kts b/featbit-client/build.gradle.kts index 458913c..c14fcbb 100644 --- a/featbit-client/build.gradle.kts +++ b/featbit-client/build.gradle.kts @@ -2,6 +2,7 @@ plugins { alias(libs.plugins.android.library) alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.serialization) + `maven-publish` } android { @@ -59,3 +60,41 @@ dependencies { testImplementation(libs.testcontainers) testRuntimeOnly("org.slf4j:slf4j-simple:2.0.13") } + +// Publishes the `release` AAR + sources jar under `co.featbit:featbit-client:`. +// `./gradlew publishToMavenLocal` publishes to `~/.m2/repository` with no extra config, so +// consumers can smoke-test the artifact locally before any remote repository exists. +// +// Version resolution prefers JitPack's `VERSION` env var (populated with the git tag being +// built, e.g. `v0.1.0`) so the file names JitPack looks for match what Gradle publishes. The +// `VERSION_NAME` gradle property is the local fallback for `publishToMavenLocal`. +publishing { + publications { + register("release") { + groupId = providers.gradleProperty("GROUP").get() + artifactId = "featbit-client" + version = System.getenv("VERSION") ?: providers.gradleProperty("VERSION_NAME").get() + afterEvaluate { from(components["release"]) } + + pom { + name.set("FeatBit Client") + description.set( + "FeatBit feature-flag client SDK for Kotlin/Android — local evaluation " + + "with real-time WebSocket streaming and lifecycle-aware sync." + ) + url.set("https://github.com/Fluent-Health/featbit-android-sdk") + licenses { + license { + name.set("Apache-2.0") + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + scm { + url.set("https://github.com/Fluent-Health/featbit-android-sdk") + connection.set("scm:git:https://github.com/Fluent-Health/featbit-android-sdk.git") + developerConnection.set("scm:git:ssh://git@github.com/Fluent-Health/featbit-android-sdk.git") + } + } + } + } +} diff --git a/gradle.properties b/gradle.properties index 0252058..4e588e9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,3 +6,9 @@ android.useAndroidX=true android.nonTransitiveRClass=true kotlin.code.style=official + +# Publication coordinates. `groupId` + `version` are consumed by the `maven-publish` +# block in each library module; `artifactId` is set per-module because the group ships +# two artifacts (`featbit-client`, `featbit-client-android`). +GROUP=co.featbit +VERSION_NAME=0.1.0-SNAPSHOT diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 0000000..a9426d5 --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,16 @@ +# JitPack build configuration. +# +# JitPack builds a public Maven artifact per git tag on demand: when a consumer requests +# `com.github.Fluent-Health:featbit-android-sdk:`, JitPack clones the tag, runs +# `./gradlew publishToMavenLocal`, and serves whatever landed in `~/.m2`. +# +# The install command below matches what a maintainer would run locally, so a consumer +# fetching from JitPack sees the same AAR + sources jar + POM as `publishToMavenLocal`. +# +# JDK 17 matches the toolchain the CI workflow uses; both library modules target JVM 11, +# so the compile toolchain and target bytecode are independent. +jdk: + - openjdk17 + +install: + - ./gradlew :featbit-client:publishToMavenLocal :featbit-client-android:publishToMavenLocal