Skip to content

Commit

Permalink
New native plugin + use common coroutines
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinMoskala committed Aug 11, 2018
1 parent 539d4bd commit 57fb7b7
Show file tree
Hide file tree
Showing 27 changed files with 125 additions and 172 deletions.
10 changes: 5 additions & 5 deletions build.gradle
@@ -1,9 +1,9 @@
allprojects {
buildscript {
ext.kotlin_version = '1.2.51'
ext.serialization_version = '0.5.1'
ext.kotlin_version = '1.2.60'
ext.serialization_version = '0.6.1'
ext.nodeVersion = '8.9.4'
ext.kotlin_native_version = '0.7.1'
ext.kotlin_native_version = "0.8.1"

repositories {
maven { url 'http://dl.bintray.com/kotlin/kotlin-eap-1.2' }
Expand All @@ -26,10 +26,10 @@ allprojects {
classpath "org.jetbrains.kotlinx:kotlinx-gradle-serialization-plugin:$serialization_version"
classpath("org.jetbrains.kotlinx:kotlinx-coroutines-core:0.12")
classpath 'com.google.gms:google-services:3.1.1'
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.moowork.gradle:gradle-node-plugin:1.2.0'
classpath "com.github.jengelman.gradle.plugins:shadow:2.0.1"
classpath 'io.fabric.tools:gradle:1.25.3'
classpath 'io.fabric.tools:gradle:1.25.4'
}

}
Expand Down

This file was deleted.

This file was deleted.

32 changes: 25 additions & 7 deletions common-client-native/build.gradle
@@ -1,16 +1,34 @@
apply plugin: 'konan'
buildscript {
repositories {
jcenter()
maven { url 'https://plugins.gradle.org/m2/' }
maven { url 'https://dl.bintray.com/jetbrains/kotlin-native-dependencies' }
}

dependencies {
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version"
}

konanArtifacts {
framework('KotlinAcademyCommon', targets: ['iphone', 'iphone_sim']) {
enableDebug true
enableMultiplatform true
}

apply plugin: 'kotlin-platform-native'

repositories {
jcenter()
}

srcDir 'src/main/kotlin'
srcFiles fileTree('../common-native/src/main/kotlin')
sourceSets {
//noinspection GroovyAssignabilityCheck
main {
component {
target "ios_arm64", "ios_arm32", "ios_x64", "macos_x64", "linux_x64", "mingw_x64"
outputKinds = [EXECUTABLE]
}
}
}

dependencies {
expectedBy project(':common')
expectedBy project(':common-client')
implementation dep.coroutines_native
}
@@ -0,0 +1,42 @@
package org.kotlinacademy

actual data class DateTime(
actual val second: Int,
actual val minute: Int,
actual val hour: Int,
actual val dayOfMonth: Int,
actual val monthOfYear: Int,
actual val year: Int
) : Comparable<DateTime> {

actual fun toDateFormatString(): String = DATE_FORMAT
.replace("yyyy", year.toString(4))
.replace("MM", monthOfYear.toString(2))
.replace("dd", dayOfMonth.toString(2))
.replace("'T'", "T")
.replace("HH", hour.toString(2))
.replace("mm", minute.toString(2))
.replace("ss", second.toString(2))

override operator fun compareTo(other: DateTime): Int
= compareValuesBy(this, other, DateTime::year, DateTime::monthOfYear, DateTime::dayOfMonth, DateTime::hour, DateTime::minute, DateTime::second)

actual operator fun plus(millis: Long): DateTime = this // Sorry
}

actual fun String.parseDateTime() = DateTime(
substring(17, 19).toInt(),
substring(14, 16).toInt(),
substring(11, 13).toInt(),
substring(8, 10).toInt(),
substring(5, 7).toInt(),
substring(0, 4).toInt()
)

actual val now: DateTime
get() = DateTime(0, 0, 0, 0, 0, 0)

private fun Int.toString(minSize: Int): String {
val str = toString()
return if (str.length >= minSize) str else generateSequence { "0" }.take(minSize - str.length).joinToString() + str
}
@@ -0,0 +1,20 @@
package org.kotlinacademy

actual annotation class Serializable

actual interface KSerializer<T> {
actual val serialClassDesc: KSerialClassDesc
actual fun save(output: KOutput, obj: T)
actual fun load(input: KInput): T
}

actual interface KSerialClassDesc
actual open class SerialClassDescImpl: KSerialClassDesc {
actual constructor(name: String)
}
actual abstract class KOutput {
actual abstract fun writeStringValue(value: String)
}
actual abstract class KInput {
actual abstract fun readStringValue(): String
}

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions common-client/build.gradle
Expand Up @@ -3,6 +3,7 @@ apply plugin: 'kotlin-platform-common'
dependencies {
compile project(':common')
implementation dep.kotlin_stdlib_common
implementation dep.coroutines_common
testImplementation dep.kotlin_test_common
}

Expand Down
@@ -1,6 +1,3 @@
package org.kotlinacademy.common

class HttpError(
val code: Int,
override val message: String
) : Throwable()
class HttpError(val code: Int, override val message: String) : Throwable()

This file was deleted.

@@ -1,6 +1,6 @@
package org.kotlinacademy.presentation

import org.kotlinacademy.common.Job
import kotlinx.coroutines.experimental.Job

abstract class BasePresenter : Presenter {

Expand Down
@@ -1,6 +1,6 @@
package org.kotlinacademy.presentation.feedback

import org.kotlinacademy.common.launch
import kotlinx.coroutines.experimental.launch
import org.kotlinacademy.data.Feedback
import org.kotlinacademy.presentation.BasePresenter
import org.kotlinacademy.respositories.FeedbackRepository
Expand Down
@@ -1,6 +1,6 @@
package org.kotlinacademy.presentation.info

import org.kotlinacademy.common.launch
import kotlinx.coroutines.experimental.launch
import org.kotlinacademy.data.InfoData
import org.kotlinacademy.presentation.BasePresenter
import org.kotlinacademy.respositories.InfoRepository
Expand Down
@@ -1,6 +1,6 @@
package org.kotlinacademy.presentation.manager

import org.kotlinacademy.common.launch
import kotlinx.coroutines.experimental.launch
import org.kotlinacademy.presentation.BasePresenter
import org.kotlinacademy.respositories.ManagerRepository
import kotlin.coroutines.experimental.CoroutineContext
Expand Down
@@ -1,6 +1,6 @@
package org.kotlinacademy.presentation.news

import org.kotlinacademy.common.launch
import kotlinx.coroutines.experimental.launch
import org.kotlinacademy.data.NewsData
import org.kotlinacademy.data.news
import org.kotlinacademy.presentation.BasePresenter
Expand Down
@@ -1,6 +1,6 @@
package org.kotlinacademy.presentation.notifications

import org.kotlinacademy.common.launch
import kotlinx.coroutines.experimental.launch
import org.kotlinacademy.data.FirebaseTokenType
import org.kotlinacademy.presentation.BasePresenter
import org.kotlinacademy.respositories.NotificationRepository
Expand Down
@@ -1,6 +1,6 @@
package org.kotlinacademy.presentation.puzzler

import org.kotlinacademy.common.launch
import kotlinx.coroutines.experimental.launch
import org.kotlinacademy.data.PuzzlerData
import org.kotlinacademy.presentation.BasePresenter
import org.kotlinacademy.respositories.ManagerRepository
Expand Down
@@ -1,9 +1,6 @@
package org.kotlinacademy

import org.kotlinacademy.common.Job
import org.kotlinacademy.presentation.BasePresenter
import kotlin.test.Test
import kotlin.test.assertTrue

class BasePresenterUnitTest: BaseUnitTest() {

Expand Down
15 changes: 8 additions & 7 deletions common-native/build.gradle
@@ -1,11 +1,12 @@
apply plugin: 'konan'
apply plugin: 'kotlin-platform-native'

konanArtifacts {
framework('KotlinAcademyCommon', targets: ['iphone', 'iphone_sim']) {
enableDebug true
enableMultiplatform true

srcDir 'src/main'
sourceSets {
//noinspection GroovyAssignabilityCheck
main {
component {
target "ios_arm64", "ios_arm32", "ios_x64", "macos_x64", "linux_x64", "mingw_x64"
outputKinds = [EXECUTABLE]
}
}
}

Expand Down

0 comments on commit 57fb7b7

Please sign in to comment.