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
52 changes: 52 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Validation

on:
pull_request:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: validation-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
validate:
runs-on: ubuntu-latest
timeout-minutes: 90

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
packages: platform-tools

- name: Install Android SDK packages
run: |
sdkmanager --install \
"platforms;android-36" \
"build-tools;36.0.0"

- name: Run ktlint (Spotless)
run: ./gradlew --no-daemon --stacktrace spotlessCheck

- name: Run tests and assemble validations
run: |
./gradlew --no-daemon --stacktrace \
:amvi-viewmodel:jvmTest \
:amvi-viewmodel:assembleAndroidMain \
:amvi-component-compose:jvmTest \
:amvi-component-compose:assembleAndroidMain
100 changes: 100 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Release Libraries

on:
push:
tags:
- 'v*'

permissions:
contents: read
packages: write

jobs:
publish-libraries:
# iOS targets only compile on macOS; on Linux they are skipped and the release would ship without them
runs-on: macos-latest
environment: release

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
packages: platform-tools

- name: Install Android SDK packages
run: |
sdkmanager --install \
"platforms;android-36" \
"build-tools;36.0.0"
- name: Run tests
run: |
./gradlew --no-daemon --stacktrace \
:amvi-viewmodel:jvmTest \
:amvi-component-compose:jvmTest

- name: Validate tag matches version
run: |
TAG="${GITHUB_REF#refs/tags/}"
VERSION=$(grep '^versionName=' gradle.properties | cut -d'=' -f2)
if [ "v${VERSION}" != "${TAG}" ] && [ "${VERSION}" != "${TAG}" ]; then
echo "Tag '${TAG}' does not match versionName '${VERSION}' in gradle.properties"
exit 1
fi

- name: Prepare publishing credentials
env:
NEXUS_USERTOKEN_NAME: ${{ secrets.NEXUS_USERTOKEN_NAME }}
NEXUS_USERTOKEN_PASSWORD: ${{ secrets.NEXUS_USERTOKEN_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_SECRET_KEY_RING_FILE_BASE64: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE_BASE64 }}
run: |
required_vars=(
NEXUS_USERTOKEN_NAME
NEXUS_USERTOKEN_PASSWORD
SIGNING_KEY_ID
SIGNING_PASSWORD
SIGNING_SECRET_KEY_RING_FILE_BASE64
)

for var in "${required_vars[@]}"; do
if [ -z "${!var}" ]; then
echo "Missing required secret: ${var}"
exit 1
fi
done

keyring_file="${RUNNER_TEMP}/signing-secring.gpg"
echo "${SIGNING_SECRET_KEY_RING_FILE_BASE64}" | base64 --decode > "${keyring_file}"
chmod 600 "${keyring_file}"

mkdir -p "${HOME}/.gradle"
{
echo "mavenCentralUsername=${NEXUS_USERTOKEN_NAME}"
echo "mavenCentralPassword=${NEXUS_USERTOKEN_PASSWORD}"
echo "NEXUS_USERTOKEN_NAME=${NEXUS_USERTOKEN_NAME}"
echo "NEXUS_USERTOKEN_PASSWORD=${NEXUS_USERTOKEN_PASSWORD}"
echo "signing.keyId=${SIGNING_KEY_ID}"
echo "signing.password=${SIGNING_PASSWORD}"
echo "signing.secretKeyRingFile=${keyring_file}"
} >> "${HOME}/.gradle/gradle.properties"

- name: Publish libraries
run: |
./gradlew --no-daemon --stacktrace \
:amvi-viewmodel:publishAndReleaseToMavenCentral \
:amvi-component-compose:publishAndReleaseToMavenCentral
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ build
!/.idea/codeStyles/
!/.idea/dictionaries/
/local.properties
.kotlin/
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.10.0 - 2026-11-08

* Kotlin Multiplatform: `jvm`, `android`, `iosArm64`, `iosSimulatorArm64`, `iosX64` targets
* Update to Kotlin 2.3.20, coroutines 1.10.2. Minimum JVM version is 11
* Depend on unicorn `ru.kode:unicorn2:2.3.0` (new groupId, was `ru.dimsuz:unicorn2`)
* Add common `rememberViewIntents(factory)`. The reified no-arg `rememberViewIntents()` stays on JVM and Android
* `amvi-component-compose` depends only on Compose runtime (was Compose Desktop)
* Publish via Maven Central Portal

## 0.9.1 - 2023-02-15

* Fix bug with `ViewModel.attach` calls on a "leaked" view model object
Expand Down
93 changes: 86 additions & 7 deletions amvi-component-compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,95 @@
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinMultiplatform

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
kotlin("jvm")
id(libs.plugins.composeDesktop.get().pluginId)
id(libs.plugins.kotlinMultiplatform.get().pluginId)
id(libs.plugins.androidKmpLibrary.get().pluginId)
alias(libs.plugins.kotlinCompose)
alias(libs.plugins.vanniktech.maven.publish)
}

group = providers.gradleProperty("pomGroupId").get()
version = providers.gradleProperty("versionName").get()

kotlin {
jvmToolchain(11)

jvm()

androidLibrary {
namespace = "ru.kode.amvi.component.compose"
compileSdk = libs.versions.compileSdk.get().toInt()
minSdk = 21
}

iosArm64()
iosSimulatorArm64()
iosX64()

sourceSets {
commonMain.dependencies {
// Compose Multiplatform; on Android it resolves to the androidx artifact below
api(libs.cmpRuntime)
api(project(":amvi-viewmodel"))
}
androidMain.dependencies {
api(libs.composeRuntime)
}
jvmTest.dependencies {
implementation(libs.bundles.koTestCommon)
implementation(libs.bundles.koTestJvm)
}
}
}

tasks.withType<Test>().configureEach {
useJUnitPlatform()
mavenPublishing {
coordinates(artifactId = "amvi-component-compose")
configure(KotlinMultiplatform(javadocJar = JavadocJar.Empty()))

publishToMavenCentral()
signAllPublications()

pom {
val pomName: String by project
val pomDescription: String by project
val pomUrl: String by project
val pomScmUrl: String by project
val pomScmConnection: String by project
val pomScmDevConnection: String by project
val pomLicenseName: String by project
val pomLicenseUrl: String by project
val pomLicenseDist: String by project
val pomDeveloperId: String by project
val pomDeveloperName: String by project

name.set(pomName)
description.set(pomDescription)
url.set(pomUrl)

scm {
url.set(pomScmUrl)
connection.set(pomScmConnection)
developerConnection.set(pomScmDevConnection)
}

licenses {
license {
name.set(pomLicenseName)
url.set(pomLicenseUrl)
distribution.set(pomLicenseDist)
}
}

developers {
developer {
id.set(pomDeveloperId)
name.set(pomDeveloperName)
}
}
}
}

dependencies {
implementation(compose.desktop.currentOs)
api(project(":amvi-viewmodel"))
tasks.named<Test>("jvmTest") {
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package ru.kode.amvi.component.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import ru.kode.amvi.viewmodel.ViewIntents

@Composable
inline fun <reified VI : ViewIntents> rememberViewIntents(): VI =
remember { VI::class.java.getDeclaredConstructor().newInstance() }
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ fun <S : Any, I : ViewIntents> MviComponent(
}

@Composable
inline fun <reified VI : ViewIntents> rememberViewIntents(): VI {
return remember { VI::class.java.getDeclaredConstructor().newInstance() }
}
fun <VI : ViewIntents> rememberViewIntents(factory: () -> VI): VI = remember(calculation = factory)

@Composable
private fun <VI : ViewIntents, VM : ViewModel<*, VI>> LifecycleEffect(viewModel: VM, intents: VI) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package ru.kode.amvi.component.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import ru.kode.amvi.viewmodel.ViewIntents

@Composable
inline fun <reified VI : ViewIntents> rememberViewIntents(): VI =
remember { VI::class.java.getDeclaredConstructor().newInstance() }
Loading
Loading