Skip to content
Open
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
26 changes: 9 additions & 17 deletions .idea/codeStyles/Project.xml

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

13 changes: 11 additions & 2 deletions sample/build.gradle.kts → androidSample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,19 @@ androidExtensions {
isExperimental = true
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class.java) {
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
}

tasks.withType(Test::class.java) {
useJUnitPlatform()
testLogging { events("passed", "skipped", "failed") }
}

dependencies {
// decide whether to use local dep for testing changes or latest released version
implementation(project(":skadi-lib"))
// implementation("io.github.syex:skadi:0.1.0")
implementation(project(":skadi"))
// implementation("io.github.syex:skadi-android-debug:0.5.0-SNAPSHOT")

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:${Dependencies.coroutines}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import kotlinx.coroutines.plus

class MainViewModel(
private val loadMovies: LoadMoviesUseCase,
private val coroutineScope: CoroutineScope? = null,
private val dispatcher: CoroutineDispatcher = Dispatchers.Default
coroutineScope: CoroutineScope? = null,
dispatcher: CoroutineDispatcher = Dispatchers.Default
) : ViewModel() {

val skadiStore = SkadiStore<MainViewState, MainViewAction, MainViewSignal>(
Expand Down
24 changes: 6 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
plugins {
kotlin("jvm") version "1.4.31"
}

buildscript {
repositories {
google()
jcenter()
}

dependencies {
classpath("com.android.tools.build:gradle:4.0.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32")
classpath("com.android.tools.build:gradle:4.1.1")
classpath("com.vanniktech:gradle-maven-publish-plugin:0.14.2")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.4.30")
}
}

allprojects {
repositories {
jcenter()
mavenLocal()
google()
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class.java) {
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
}

// Enable JUnit5
tasks.withType(Test::class.java) {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
jcenter()
}
}
18 changes: 17 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,20 @@ org.gradle.parallel=true
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
android.enableJetifier=true
GROUP=io.github.syex
POM_ARTIFACT_ID=skadi
VERSION_NAME=0.5.0-SNAPSHOT
POM_NAME=skadi
POM_DESCRIPTION=A Kotlin JVM library featuring a redux-like architecture with coroutines
POM_INCEPTION_YEAR=2021
POM_URL=https://github.com/Syex/skadi
POM_SCM_URL=https://github.com/Syex/skadi
POM_SCM_CONNECTION=scm:git:git://github.com/Syex/skadi.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/Syex/skadi.git
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=Syex
POM_DEVELOPER_NAME=Tom Seifert
POM_DEVELOPER_URL=https://github.com/Syex/
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
rootProject.name = "skadi"
include("skadi-lib", "sample")
include("skadi", "androidSample")
87 changes: 0 additions & 87 deletions skadi-lib/build.gradle.kts

This file was deleted.

84 changes: 84 additions & 0 deletions skadi/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
plugins {
kotlin("multiplatform")
id("com.android.library")
id("com.vanniktech.maven.publish")
id("org.jetbrains.dokka")
// signing
}

kotlin {
jvm()
android {
publishLibraryVariants("release", "debug")
}
ios()
linuxX64()
macosX64()
mingwX64()
tvosArm64()
tvosX64()
watchosArm32()
watchosArm64()
watchosX86()

sourceSets {
val commonMain by getting {
dependencies {
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Dependencies.coroutines}")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
implementation("app.cash.turbine:turbine:${Dependencies.turbine}")
}
}
val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("org.junit.jupiter:junit-jupiter:${Dependencies.jUnit}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${Dependencies.coroutines}")
}

tasks.named("jvmTest", Test::class.java) {
useJUnitPlatform()
testLogging { events("passed", "skipped", "failed") }
}
}
}
}

android {
compileSdkVersion(30)
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdkVersion(1)
targetSdkVersion(30)
}
}

publishing {
repositories {
val releasesRepoUrl = "https://s01.oss.sonatype.org/content/repositories/releases"
val snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
val repoUrl = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)

maven(url = repoUrl) {
authentication {
credentials {
username = System.getenv("OSS_SONATYPE_USERNAME")
password = System.getenv("OSS_SONATYPE_PASSWORD")
}
}
}
}
}

//@Suppress("UnstableApiUsage")
//signing {
// val signingPrivateKey = System.getenv("MAVEN_GPG_PRIVATE_KEY")
// val signingPassword = System.getenv("MAVEN_GPG_PASSPHRASE")
// useInMemoryPgpKeys(signingPrivateKey, signingPassword)
// sign(publishing.publications)
//}
2 changes: 2 additions & 0 deletions skadi/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="io.github.syex"/>
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package io.github.syex.skadi

import com.google.common.truth.Truth.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertTrue

class EffectBuilderTest {

Expand All @@ -11,9 +12,9 @@ class EffectBuilderTest {
val testState = TestSkadiState()
val effect = state<TestSkadiState, Nothing, Nothing> { testState }

assertThat(effect.state).isEqualTo(testState)
assertThat(effect.actions).isEmpty()
assertThat(effect.signals).isEmpty()
assertEquals(effect.state, testState)
assertTrue(effect.actions.isEmpty())
assertTrue(effect.signals.isEmpty())
}

@Test
Expand All @@ -27,9 +28,9 @@ class EffectBuilderTest {
signals { signals }
}

assertThat(effect.state).isEqualTo(testState)
assertThat(effect.actions).isEqualTo(actions)
assertThat(effect.signals).isEqualTo(signals)
assertEquals(effect.state, testState)
assertEquals(effect.actions, actions)
assertEquals(effect.signals, signals)
}

@Test
Expand All @@ -41,9 +42,9 @@ class EffectBuilderTest {
action { action }
}

assertThat(effect.state).isEqualTo(testState)
assertThat(effect.actions).isEqualTo(listOf(action))
assertThat(effect.signals).isEmpty()
assertEquals(effect.state, testState)
assertEquals(effect.actions, listOf(action))
assertTrue(effect.signals.isEmpty())
}

@Test
Expand All @@ -55,18 +56,18 @@ class EffectBuilderTest {
signal { signal }
}

assertThat(effect.state).isEqualTo(testState)
assertThat(effect.actions).isEmpty()
assertThat(effect.signals).isEqualTo(listOf(signal))
assertEquals(effect.state, testState)
assertTrue(effect.actions.isEmpty())
assertEquals(effect.signals, listOf(signal))
}

@Test
fun `dsl method effect() throws if no state is passed`() {
val action = TestSkadiAction()
assertThrows<IllegalStateException> {
assertFailsWith<IllegalStateException> {
effect<TestSkadiState, TestSkadiAction, Nothing> {
action { action }
}
}
}
}
}
Loading