From 5dd40f02264b2f70acdbf38af030daf6051bfd4c Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 27 Jan 2019 17:12:46 +0300 Subject: [PATCH] Build update and minor fixes --- build.gradle.kts | 30 +++++++---- dataforge-context/build.gradle | 40 -------------- dataforge-context/build.gradle.kts | 35 ++++++++++++ .../kotlin/hep/dataforge/context/Plugin.kt | 2 +- .../kotlin/hep/dataforge/context/JSContext.kt | 8 --- .../kotlin/hep/dataforge/data/Action.kt | 2 +- .../kotlin/hep/dataforge/data/Data.kt | 20 +++++-- dataforge-io/build.gradle | 2 +- .../kotlin/hep/dataforge/io/OutputManager.kt | 3 ++ dataforge-meta/build.gradle | 53 ------------------- dataforge-meta/build.gradle.kts | 50 +++++++++++++++++ 11 files changed, 127 insertions(+), 118 deletions(-) delete mode 100644 dataforge-context/build.gradle create mode 100644 dataforge-context/build.gradle.kts delete mode 100644 dataforge-meta/build.gradle create mode 100644 dataforge-meta/build.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts index 92044203..3705ffd4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,13 +1,10 @@ -buildscript { - extra["kotlinVersion"] = "1.3.20" - extra["ioVersion"] = "0.1.2" - extra["serializationVersion"] = "0.9.1" - extra["coroutinesVersion"] = "1.1.1" +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension - val kotlinVersion: String by extra - val ioVersion: String by extra - val coroutinesVersion: String by extra - val serializationVersion: String by extra +buildscript { + val kotlinVersion: String by rootProject.extra("1.3.20") + val ioVersion: String by rootProject.extra("0.1.2") + val coroutinesVersion: String by rootProject.extra("1.1.1") + val serializationVersion: String by rootProject.extra("0.9.1") repositories { jcenter() @@ -36,6 +33,21 @@ allprojects { group = "hep.dataforge" version = "0.1.1-dev-2" + + extensions.findByType()?.apply { + jvm { + compilations.all { + kotlinOptions { + jvmTarget = "1.8" + } + } + } + targets.all { + sourceSets.all { + languageSettings.progressiveMode = true + } + } + } } if (file("artifactory.gradle").exists()) { diff --git a/dataforge-context/build.gradle b/dataforge-context/build.gradle deleted file mode 100644 index 9e727ae2..00000000 --- a/dataforge-context/build.gradle +++ /dev/null @@ -1,40 +0,0 @@ -plugins { - id "org.jetbrains.kotlin.multiplatform" -} - -repositories { - jcenter() -} - -kotlin { - targets { - fromPreset(presets.jvm, 'jvm') - fromPreset(presets.js, 'js') - // For ARM, preset should be changed to presets.iosArm32 or presets.iosArm64 - // For Linux, preset should be changed to e.g. presets.linuxX64 - // For MacOS, preset should be changed to e.g. presets.macosX64 - //fromPreset(presets.iosX64, 'ios') - } - sourceSets { - commonMain { - dependencies { - api project(":dataforge-meta") - api "org.jetbrains.kotlin:kotlin-reflect" - api "io.github.microutils:kotlin-logging-common:1.6.10" - api "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutinesVersion" - } - } - jvmMain{ - dependencies{ - api "io.github.microutils:kotlin-logging:1.6.10" - api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion" - } - } - jsMain{ - dependencies{ - api "io.github.microutils:kotlin-logging-js:1.6.10" - api "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$coroutinesVersion" - } - } - } -} \ No newline at end of file diff --git a/dataforge-context/build.gradle.kts b/dataforge-context/build.gradle.kts new file mode 100644 index 00000000..5b33659e --- /dev/null +++ b/dataforge-context/build.gradle.kts @@ -0,0 +1,35 @@ +plugins { + kotlin("multiplatform") +} + +description = "Context and provider definitions" + +val coroutinesVersion: String by rootProject.extra + +kotlin { + jvm () + js() + + sourceSets { + val commonMain by getting { + dependencies { + api(project(":dataforge-meta")) + api(kotlin("reflect")) + api("io.github.microutils:kotlin-logging-common:1.6.10") + api("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutinesVersion") + } + } + val jvmMain by getting { + dependencies { + api("io.github.microutils:kotlin-logging:1.6.10") + api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") + } + } + val jsMain by getting { + dependencies { + api("io.github.microutils:kotlin-logging-js:1.6.10") + api("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$coroutinesVersion") + } + } + } +} \ No newline at end of file diff --git a/dataforge-context/src/commonMain/kotlin/hep/dataforge/context/Plugin.kt b/dataforge-context/src/commonMain/kotlin/hep/dataforge/context/Plugin.kt index ccd979b3..780855a6 100644 --- a/dataforge-context/src/commonMain/kotlin/hep/dataforge/context/Plugin.kt +++ b/dataforge-context/src/commonMain/kotlin/hep/dataforge/context/Plugin.kt @@ -65,7 +65,7 @@ interface Plugin : Named, Metoid, ContextAware, Provider, MetaRepr { override fun toMeta(): Meta = buildMeta { "context" to context.name - "type" to this::class.qualifiedName + "type" to this::class.simpleName "tag" to tag "meta" to meta } diff --git a/dataforge-context/src/jsMain/kotlin/hep/dataforge/context/JSContext.kt b/dataforge-context/src/jsMain/kotlin/hep/dataforge/context/JSContext.kt index 8c803777..95ae8aea 100644 --- a/dataforge-context/src/jsMain/kotlin/hep/dataforge/context/JSContext.kt +++ b/dataforge-context/src/jsMain/kotlin/hep/dataforge/context/JSContext.kt @@ -4,7 +4,6 @@ import hep.dataforge.meta.* import mu.KLogger import mu.KotlinLogging import kotlin.jvm.Synchronized -import kotlin.reflect.KClass actual object Global: Context, JSContext("GLOBAL", null){ /** @@ -51,13 +50,6 @@ open class JSContext( override val plugins: PluginManager by lazy { PluginManager(this) } override val logger: KLogger = KotlinLogging.logger(name) - /** - * A property showing that dispatch thread is started in the context - */ - private var started = false - - override fun services(type: KClass): Sequence = TODO("Not implemented") - /** * Free up resources associated with this context * diff --git a/dataforge-data/src/commonMain/kotlin/hep/dataforge/data/Action.kt b/dataforge-data/src/commonMain/kotlin/hep/dataforge/data/Action.kt index e4b35e39..895cc764 100644 --- a/dataforge-data/src/commonMain/kotlin/hep/dataforge/data/Action.kt +++ b/dataforge-data/src/commonMain/kotlin/hep/dataforge/data/Action.kt @@ -50,7 +50,7 @@ class PipeAction(val transform: (Name, Data, Meta) - /** * A simple pipe that performs transformation on the data and copies input meta into the output */ - fun simple(transform: suspend (Name, T, Meta) -> R) = PipeAction { name, data: Data, meta -> + inline fun simple(noinline transform: suspend (Name, T, Meta) -> R) = PipeAction { name, data: Data, meta -> val goal = data.goal.pipe { transform(name, it, meta) } return@PipeAction Data.of(goal, data.meta) } diff --git a/dataforge-data/src/commonMain/kotlin/hep/dataforge/data/Data.kt b/dataforge-data/src/commonMain/kotlin/hep/dataforge/data/Data.kt index e8cd20e9..6d74a788 100644 --- a/dataforge-data/src/commonMain/kotlin/hep/dataforge/data/Data.kt +++ b/dataforge-data/src/commonMain/kotlin/hep/dataforge/data/Data.kt @@ -32,15 +32,25 @@ interface Data : MetaRepr { companion object { fun of(type: KClass, goal: Goal, meta: Meta): Data = DataImpl(type, goal, meta) inline fun of(goal: Goal, meta: Meta): Data = of(T::class, goal, meta) - fun of(name: String, goal: Goal, meta: Meta): Data = NamedData(name, of(goal, meta)) - fun static(context: CoroutineContext, value: T, meta: Meta): Data = DataImpl(value::class, Goal.static(context, value), meta) + fun of(name: String, type: KClass, goal: Goal, meta: Meta): Data = + NamedData(name, of(type, goal, meta)) + + inline fun of(name: String, goal: Goal, meta: Meta): Data = + of(name, T::class, goal, meta) + + fun static(context: CoroutineContext, value: T, meta: Meta): Data = + DataImpl(value::class, Goal.static(context, value), meta) } } /** * Generic Data implementation */ -private class DataImpl(override val type: KClass, override val goal: Goal, override val meta: Meta) : Data +private class DataImpl( + override val type: KClass, + override val goal: Goal, + override val meta: Meta +) : Data class NamedData(val name: String, data: Data) : Data by data @@ -200,8 +210,8 @@ fun DataNode.builder(): DataTreeBuilder = DataTreeBuilder().a fun DataNode<*>.startAll() = asSequence().forEach { (_, data) -> data.goal.start() } fun DataNode.filter(predicate: (Name, Data) -> Boolean): DataNode = DataNode.build { - asSequence().forEach {(name, data)-> - if(predicate(name,data)){ + asSequence().forEach { (name, data) -> + if (predicate(name, data)) { this[name] = data } } diff --git a/dataforge-io/build.gradle b/dataforge-io/build.gradle index 7ee283bd..570e9d28 100644 --- a/dataforge-io/build.gradle +++ b/dataforge-io/build.gradle @@ -9,7 +9,7 @@ repositories { kotlin { targets { fromPreset(presets.jvm, 'jvm') - //fromPreset(presets.js, 'js') + fromPreset(presets.js, 'js') // For ARM, preset should be changed to presets.iosArm32 or presets.iosArm64 // For Linux, preset should be changed to e.g. presets.linuxX64 // For MacOS, preset should be changed to e.g. presets.macosX64 diff --git a/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/OutputManager.kt b/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/OutputManager.kt index aa648dfa..7a8c1eee 100644 --- a/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/OutputManager.kt +++ b/dataforge-io/src/commonMain/kotlin/hep/dataforge/io/OutputManager.kt @@ -28,6 +28,9 @@ interface OutputManager : Plugin { } +/** + * Get an output with given [name], [stage] and reified content type + */ inline fun OutputManager.typed(name: Name, stage: Name = EmptyName, meta: Meta = EmptyMeta): Output { return typed(T::class, name, stage, meta) } diff --git a/dataforge-meta/build.gradle b/dataforge-meta/build.gradle deleted file mode 100644 index 994ee882..00000000 --- a/dataforge-meta/build.gradle +++ /dev/null @@ -1,53 +0,0 @@ -plugins { - id "org.jetbrains.kotlin.multiplatform" -} - -kotlin { - targets { - fromPreset(presets.jvm, 'jvm') - fromPreset(presets.js, 'js') - // For ARM, preset should be changed to presets.iosArm32 or presets.iosArm64 - // For Linux, preset should be changed to e.g. presets.linuxX64 - // For MacOS, preset should be changed to e.g. presets.macosX64 - //fromPreset(presets.iosX64, 'ios') - } - sourceSets { - commonMain { - dependencies { - api "org.jetbrains.kotlin:kotlin-stdlib-common" - - } - } - commonTest { - dependencies { - implementation 'org.jetbrains.kotlin:kotlin-test-common' - implementation 'org.jetbrains.kotlin:kotlin-test-annotations-common' - } - } - jvmMain { - dependencies { - api "org.jetbrains.kotlin:kotlin-stdlib-jdk8" - } - } - jvmTest { - dependencies { - implementation 'org.jetbrains.kotlin:kotlin-test' - implementation 'org.jetbrains.kotlin:kotlin-test-junit' - } - } - jsMain { - dependencies { - api 'org.jetbrains.kotlin:kotlin-stdlib-js' - } - } - jsTest { - dependencies { - implementation 'org.jetbrains.kotlin:kotlin-test-js' - } - } -// iosMain { -// } -// iosTest { -// } - } -} \ No newline at end of file diff --git a/dataforge-meta/build.gradle.kts b/dataforge-meta/build.gradle.kts new file mode 100644 index 00000000..c2d39d6c --- /dev/null +++ b/dataforge-meta/build.gradle.kts @@ -0,0 +1,50 @@ +plugins { + kotlin("multiplatform") +} + +description = "Meta definition and basic operations on meta" + +kotlin { + jvm() + js() + + sourceSets { + + val commonMain by getting { + dependencies { + api(kotlin("stdlib")) + } + } + val commonTest by getting { + dependencies { + implementation(kotlin("test-common")) + implementation(kotlin("test-annotations-common")) + } + } + val jvmMain by getting { + dependencies { + api(kotlin("stdlib-jdk8")) + } + } + val jvmTest by getting { + dependencies { + implementation(kotlin("test")) + implementation(kotlin("test-junit")) + } + } + val jsMain by getting { + dependencies { + api(kotlin("stdlib-js")) + } + } + val jsTest by getting { + dependencies { + implementation(kotlin("test-js")) + } + } +// mingwMain { +// } +// mingwTest { +// } + } +} \ No newline at end of file