Skip to content

Commit

Permalink
v2.0.0 Coroutine dependencies moved away from core
Browse files Browse the repository at this point in the history
  • Loading branch information
motorro committed Jul 25, 2022
1 parent d31343c commit c531d95
Show file tree
Hide file tree
Showing 24 changed files with 312 additions and 18 deletions.
4 changes: 4 additions & 0 deletions .idea/compiler.xml

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

1 change: 1 addition & 0 deletions .idea/gradle.xml

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

15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,24 @@ version like that:
dependencies {
// Base state-machine components
implementation "com.motorro.commonstatemachine:commonstatemachine:x.x.x"
// Coroutine extensions (in case you need them)
// Coroutine extensions (optional)
implementation "com.motorro.commonstatemachine:coroutines:x.x.x"
}
```

Multiplatform:

```kotlin
val commonMain by getting {
dependencies {
// Base state-machine components
implementation("com.motorro.commonstatemachine:commonstatemachine:x.x.x")
// Coroutine extensions (optional)
implementation("com.motorro.commonstatemachine:coroutines:x.x.x")
}
}
```

## Examples

- [LCE](lce) - basic example of Load-Content-Error application
Expand Down
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ task runStateMachineTests(type: Task, dependsOn: [':commonstatemachine:allTests'
description 'Run unit tests for the common state machine layer.'
}

task runCoroutinesTests(type: Task, dependsOn: [':coroutines:allTests'], group: 'verification') {
description 'Run unit tests for the coroutines extension layer.'
}

task runRegisterUnitTests(type: Task, dependsOn: [':commonregister:allTests'], group: 'verification') {
description 'Run unit tests for the common register layer.'
}
Expand Down Expand Up @@ -120,6 +124,7 @@ task runUnitTests(
type: Task,
dependsOn: [
'runStateMachineTests',
'runCoroutinesTests',
'runLoginUnitTests',
'runRegisterUnitTests',
'runLceUnitTests',
Expand Down
1 change: 1 addition & 0 deletions commonregister/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ kotlin {
val commonMain by getting {
dependencies {
implementation(project(":commonstatemachine"))
implementation(project(":coroutines"))
implementation(project(":commoncore"))
implementation(project(":commonapi"))
implementation(libs.kotlin.coroutines.core)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

package com.motorro.statemachine.register.model.state

import com.motorro.commonstatemachine.CoroutineState
import com.motorro.commonstatemachine.coroutines.CoroutineState
import com.motorro.statemachine.commoncore.log.Logger
import com.motorro.statemachine.register.data.RegisterGesture
import com.motorro.statemachine.register.data.RegisterUiState
Expand Down
7 changes: 1 addition & 6 deletions commonstatemachine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,10 @@ kotlin {
}

sourceSets {
val commonMain by getting {
dependencies {
implementation(libs.kotlin.coroutines.core)
}
}
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(libs.test.kotlin)
implementation(libs.test.kotlin.coroutines)
}
}
val jvmMain by getting
Expand Down
2 changes: 1 addition & 1 deletion commonstatemachine/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
~ limitations under the License.
-->

<manifest package="com.motorro.commonstatemachine" />
<manifest package="com.motorro.commonstatemachine.commonstatemachine" />
204 changes: 204 additions & 0 deletions coroutines/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
/*
* Copyright 2022 Nikolai Kotchetkov.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

@file:Suppress("UNUSED_VARIABLE", "DSL_SCOPE_VIOLATION")

import org.jetbrains.dokka.gradle.DokkaTask
import java.net.URI

plugins {
id("org.jetbrains.kotlin.multiplatform")
id("com.android.library")
id("org.jetbrains.dokka")
id("maven-publish")
id("signing")
}

val versionName: String by project.extra
val androidMinSdkVersion: Int by project.extra
val androidTargetSdkVersion: Int by project.extra
val androidCompileSdkVersion: Int by project.extra

group = rootProject.group
version = rootProject.version

println("== Project version: $versionName ==")

kotlin {

jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
}
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}

android {
publishLibraryVariants("release", "debug")
}

js(IR) {
compilations.all {
kotlinOptions.freeCompilerArgs += listOf(
"-Xopt-in=kotlin.js.ExperimentalJsExport"
)
}
binaries.library()
useCommonJs()
browser {
testTask {
useMocha {
timeout = "10s"
}
}
}
}

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "coroutines"
}
}

sourceSets {
val commonMain by getting {
dependencies {
implementation(project(":commonstatemachine"))
implementation(libs.kotlin.coroutines.core)
}
}
val commonTest by getting {
dependencies {
implementation(libs.test.kotlin)
implementation(libs.test.kotlin.coroutines)
}
}
val jvmMain by getting
val jvmTest by getting
val androidMain by getting {
dependsOn(jvmMain)
}
val androidTest by getting {
dependsOn(commonTest)
}
val jsMain by getting
val jsTest by getting
val iosX64Main by getting
val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val iosMain by creating {
dependsOn(commonMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
}
val iosX64Test by getting
val iosArm64Test by getting
val iosSimulatorArm64Test by getting
val iosTest by creating {
dependsOn(commonTest)
iosX64Test.dependsOn(this)
iosArm64Test.dependsOn(this)
iosSimulatorArm64Test.dependsOn(this)
}
}
targets.all {
compilations.all {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + listOf(
"-opt-in=kotlin.RequiresOptIn"
)
}
}
}
}

android {
compileSdk = androidCompileSdkVersion
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdk = androidMinSdkVersion
targetSdk = androidTargetSdkVersion
}
}
val dokkaHtml by tasks.getting(DokkaTask::class)

val javadocJar by tasks.creating(Jar::class) {
dependsOn(dokkaHtml)
group = "documentation"
archiveClassifier.set("javadoc")
from(tasks.dokkaHtml)
}

val libId = "coroutines"
val libName = "coroutines"
val libDesc = "Coroutines extension for CommonStateMachine"
val projectUrl: String by project.extra
val projectScm: String by project.extra
val ossrhUsername: String? by rootProject.extra
val ossrhPassword: String? by rootProject.extra
val developerId: String by project.extra
val developerName: String by project.extra
val developerEmail: String by project.extra
val signingKey: String? by rootProject.extra
val signingPassword: String? by rootProject.extra

publishing {
repositories {
maven {
name = "sonatype"
url = URI("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}
publications.withType<MavenPublication> {
artifact(javadocJar)
pom {
name.set(libName)
description.set(libDesc)
url.set(projectUrl)
licenses {
license {
name.set("Apache-2.0")
url.set("https://apache.org/licenses/LICENSE-2.0")
}
}
developers {
developer {
id.set(developerId)
name.set(developerName)
email.set(developerEmail)
}
}
scm {
connection.set(projectScm)
developerConnection.set(projectScm)
url.set(projectUrl)
}
}
}

signing {
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications)
}
}
2 changes: 2 additions & 0 deletions coroutines/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.motorro.commonstatemachine.coroutines" />
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
* limitations under the License.
*/

package com.motorro.commonstatemachine
package com.motorro.commonstatemachine.coroutines

import com.motorro.commonstatemachine.CommonMachineState
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
* limitations under the License.
*/

package com.motorro.commonstatemachine
package com.motorro.commonstatemachine.coroutines

import com.motorro.commonstatemachine.CommonMachineState
import com.motorro.commonstatemachine.CommonStateMachine
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.SharedFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@file:OptIn(ExperimentalCoroutinesApi::class)

package com.motorro.commonstatemachine
package com.motorro.commonstatemachine.coroutines

import kotlinx.coroutines.*
import kotlinx.coroutines.test.StandardTestDispatcher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@file:OptIn(ExperimentalCoroutinesApi::class)

package com.motorro.commonstatemachine
package com.motorro.commonstatemachine.coroutines

import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.toList
Expand Down
Loading

0 comments on commit c531d95

Please sign in to comment.