From e89dff297578217b647a511d9b6ebeb0ecac99c1 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 20 Feb 2022 17:26:01 +0300 Subject: [PATCH] Fix build, update versions --- buildSrc/build.gradle.kts | 15 -------- gradle.properties | 15 ++++++++ numass-data-proto/build.gradle.kts | 2 +- .../data/proto/TaggedNumassEnvelopeFormat.kt | 2 +- numass-detector-client/build.gradle.kts | 12 ++++++ .../ru/inr/mass/detector/DetectorClient.kt | 37 +++++++++++++++++++ numass-model/build.gradle.kts | 3 +- numass-workspace/build.gradle.kts | 2 +- settings.gradle.kts | 29 +++++++++++++-- 9 files changed, 94 insertions(+), 23 deletions(-) delete mode 100644 buildSrc/build.gradle.kts create mode 100644 gradle.properties create mode 100644 numass-detector-client/build.gradle.kts create mode 100644 numass-detector-client/src/main/kotlin/ru/inr/mass/detector/DetectorClient.kt diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts deleted file mode 100644 index 2f0a5a8..0000000 --- a/buildSrc/build.gradle.kts +++ /dev/null @@ -1,15 +0,0 @@ -plugins { - `kotlin-dsl` -} - -repositories { - mavenLocal() - maven("https://repo.kotlin.link") - mavenCentral() - gradlePluginPortal() -} - -dependencies { - api("com.squareup.wire:wire-gradle-plugin:3.7.1") - api("ru.mipt.npm:gradle-tools:0.10.7") -} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..7dd9e6d --- /dev/null +++ b/gradle.properties @@ -0,0 +1,15 @@ +# +# Copyright 2018-2021 KMath contributors. +# Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. +# + +kotlin.code.style=official +kotlin.mpp.stability.nowarn=true + +kotlin.jupyter.add.scanner=false + +org.gradle.configureondemand=true +org.gradle.parallel=true +org.gradle.jvmargs=-XX:MaxMetaspaceSize=1G + +toolsVersion=0.11.1-kotlin-1.6.10 diff --git a/numass-data-proto/build.gradle.kts b/numass-data-proto/build.gradle.kts index 9aa36ec..db50773 100644 --- a/numass-data-proto/build.gradle.kts +++ b/numass-data-proto/build.gradle.kts @@ -1,7 +1,7 @@ plugins { kotlin("jvm") id("ru.mipt.npm.gradle.common") - id("com.squareup.wire") + id("com.squareup.wire") version "4.2.0" `maven-publish` } diff --git a/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/TaggedNumassEnvelopeFormat.kt b/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/TaggedNumassEnvelopeFormat.kt index dd0020c..7be3302 100644 --- a/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/TaggedNumassEnvelopeFormat.kt +++ b/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/TaggedNumassEnvelopeFormat.kt @@ -27,7 +27,7 @@ import space.kscience.dataforge.names.plus import java.util.* -internal class TaggedNumassEnvelopeFormat(private val io: IOPlugin) : EnvelopeFormat { +public class TaggedNumassEnvelopeFormat(private val io: IOPlugin) : EnvelopeFormat { private fun Tag.toBinary() = Binary(24) { writeRawString(START_SEQUENCE) diff --git a/numass-detector-client/build.gradle.kts b/numass-detector-client/build.gradle.kts new file mode 100644 index 0000000..de6b6bb --- /dev/null +++ b/numass-detector-client/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + id("ru.mipt.npm.gradle.jvm") +} + +val dataforgeVersion: String by rootProject.extra + +dependencies { +// implementation("io.ktor:ktor-client-cio:$ktorVersion") +// implementation("io.ktor:ktor-client-logging:$ktorVersion") + implementation(npmlibs.ktor.client.cio) + api(projects.numassDataProto) +} \ No newline at end of file diff --git a/numass-detector-client/src/main/kotlin/ru/inr/mass/detector/DetectorClient.kt b/numass-detector-client/src/main/kotlin/ru/inr/mass/detector/DetectorClient.kt new file mode 100644 index 0000000..277eb52 --- /dev/null +++ b/numass-detector-client/src/main/kotlin/ru/inr/mass/detector/DetectorClient.kt @@ -0,0 +1,37 @@ +package ru.inr.mass.detector + +import io.ktor.network.selector.ActorSelectorManager +import io.ktor.network.sockets.* +import kotlinx.coroutines.Dispatchers +import ru.inr.mass.data.proto.TaggedNumassEnvelopeFormat +import space.kscience.dataforge.context.Context +import space.kscience.dataforge.context.ContextAware +import space.kscience.dataforge.io.* +import space.kscience.dataforge.meta.MutableMeta +import java.net.InetSocketAddress + +public class DetectorClient(override val context: Context) : ContextAware { + private val format: EnvelopeFormat = TaggedNumassEnvelopeFormat(context.io) + + private var connection: Connection? = null + + private suspend fun request(metaBuilder: MutableMeta.() -> Unit): Envelope { + return connection?.let { connection -> +// val requestEnvelope = Envelope { +// meta(metaBuilder) +// } +// val request = format.toBinary(requestEnvelope).toByteArray() +// connection.output.writeAvailable(request) +// val response = connection.input.read + + + + connection.output.цкasOut + } ?: error("Not connected") + } + + public suspend fun connect(host: String, port: Int) { + connection = aSocket(ActorSelectorManager(Dispatchers.IO)) + .tcp().connect(InetSocketAddress(host, port)).connection() + } +} \ No newline at end of file diff --git a/numass-model/build.gradle.kts b/numass-model/build.gradle.kts index 40db9d1..3df8a43 100644 --- a/numass-model/build.gradle.kts +++ b/numass-model/build.gradle.kts @@ -1,6 +1,5 @@ plugins { - kotlin("multiplatform") - id("ru.mipt.npm.gradle.common") + id("ru.mipt.npm.gradle.mpp") `maven-publish` } diff --git a/numass-workspace/build.gradle.kts b/numass-workspace/build.gradle.kts index 3dd15b5..f867802 100644 --- a/numass-workspace/build.gradle.kts +++ b/numass-workspace/build.gradle.kts @@ -9,7 +9,7 @@ kotlin { } val dataforgeVersion: String by rootProject.extra -val plotlyVersion: String by rootProject.extra +val plotlyVersion: String by rootProject.extra("0.5.0") val kmathVersion: String by rootProject.extra val tablesVersion: String by rootProject.extra diff --git a/settings.gradle.kts b/settings.gradle.kts index 1a94292..75583be 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,7 +1,29 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") enableFeaturePreview("VERSION_CATALOGS") +pluginManagement { + + val toolsVersion: String by extra + + repositories { + mavenLocal() + maven("https://repo.kotlin.link") + mavenCentral() + gradlePluginPortal() + } + + plugins { + id("ru.mipt.npm.gradle.project") version toolsVersion + id("ru.mipt.npm.gradle.mpp") version toolsVersion + id("ru.mipt.npm.gradle.jvm") version toolsVersion + id("ru.mipt.npm.gradle.js") version toolsVersion + } +} + dependencyResolutionManagement { + + val toolsVersion: String by extra + repositories { mavenLocal() maven("https://repo.kotlin.link") @@ -9,8 +31,8 @@ dependencyResolutionManagement { } versionCatalogs { - create("npm") { - from("ru.mipt.npm:version-catalog:0.10.7") + create("npmlibs") { + from("ru.mipt.npm:version-catalog:$toolsVersion") } } } @@ -21,5 +43,6 @@ include( ":numass-data-proto", //":numass-data-server", ":numass-workspace", - ":numass-model" + ":numass-model", + //":numass-detector-client" )