Few fixes for Workspaces builders.
This commit is contained in:
parent
58e65ba71e
commit
5480d90a36
@ -45,7 +45,7 @@ allprojects {
|
||||
}
|
||||
|
||||
group = "hep.dataforge"
|
||||
version = "0.1.2-dev-2"
|
||||
version = "0.1.2-dev-3"
|
||||
|
||||
// apply bintray configuration
|
||||
apply(from = "${rootProject.rootDir}/gradle/bintray.gradle")
|
||||
@ -117,6 +117,10 @@ subprojects {
|
||||
}
|
||||
|
||||
|
||||
val runJsTests by ext(false)
|
||||
|
||||
if(runJsTests) {
|
||||
|
||||
configure<NodeExtension> {
|
||||
nodeModulesDir = file("$buildDir/node_modules")
|
||||
}
|
||||
@ -150,6 +154,7 @@ subprojects {
|
||||
|
||||
tasks["jsTest"].dependsOn(runMocha)
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
package hep.dataforge.io
|
||||
|
||||
import kotlinx.io.core.Input
|
||||
|
||||
//TODO replace by abstraction
|
||||
typealias Binary = Input
|
@ -1,4 +1,4 @@
|
||||
package hep.dataforge.meta.io
|
||||
package hep.dataforge.io
|
||||
|
||||
import hep.dataforge.meta.*
|
||||
import hep.dataforge.values.*
|
@ -1,4 +1,4 @@
|
||||
package hep.dataforge.meta.io
|
||||
package hep.dataforge.io
|
||||
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.meta.get
|
||||
@ -9,13 +9,6 @@ interface Envelope {
|
||||
val data: Binary?
|
||||
|
||||
companion object {
|
||||
// /**
|
||||
// * Property keys
|
||||
// */
|
||||
// const val TYPE_PROPERTY = "type"
|
||||
// const val META_TYPE_PROPERTY = "metaType"
|
||||
// const val META_LENGTH_PROPERTY = "metaLength"
|
||||
// const val DATA_LENGTH_PROPERTY = "dataLength"
|
||||
|
||||
/**
|
||||
* meta keys
|
@ -1,4 +1,4 @@
|
||||
package hep.dataforge.meta.io
|
||||
package hep.dataforge.io
|
||||
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.meta.MetaItem
|
@ -1,4 +1,4 @@
|
||||
package hep.dataforge.meta.io
|
||||
package hep.dataforge.io
|
||||
|
||||
import hep.dataforge.meta.Meta
|
||||
import kotlinx.io.core.*
|
@ -1,4 +1,4 @@
|
||||
package hep.dataforge.meta.io
|
||||
package hep.dataforge.io
|
||||
|
||||
import hep.dataforge.meta.buildMeta
|
||||
import kotlin.test.Test
|
@ -0,0 +1,2 @@
|
||||
hep.dataforge.io.BinaryMetaFormatFactory
|
||||
hep.dataforge.io.JsonMetaFormatFactory
|
@ -1,7 +0,0 @@
|
||||
package hep.dataforge.meta.io
|
||||
|
||||
import kotlinx.io.ByteBuffer
|
||||
import kotlinx.io.core.Input
|
||||
|
||||
//TODO replace by abstraction
|
||||
typealias Binary = Input
|
@ -1,2 +0,0 @@
|
||||
hep.dataforge.meta.io.BinaryMetaFormatFactory
|
||||
hep.dataforge.meta.io.JsonMetaFormatFactory
|
@ -9,7 +9,7 @@ kotlin {
|
||||
val commonMain by getting{
|
||||
dependencies {
|
||||
api(project(":dataforge-context"))
|
||||
api(project(":dataforge-meta-io"))
|
||||
api(project(":dataforge-io"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package hep.dataforge.scripting
|
||||
|
||||
import hep.dataforge.context.Context
|
||||
import hep.dataforge.context.Global
|
||||
import hep.dataforge.workspace.SimpleWorkspaceBuilder
|
||||
import hep.dataforge.workspace.Workspace
|
||||
import hep.dataforge.workspace.WorkspaceBuilder
|
||||
import java.io.File
|
||||
@ -14,11 +15,12 @@ import kotlin.script.experimental.jvmhost.BasicJvmScriptingHost
|
||||
object Builders {
|
||||
|
||||
fun buildWorkspace(source: SourceCode, context: Context = Global): Workspace {
|
||||
val builder = WorkspaceBuilder(context)
|
||||
val builder = SimpleWorkspaceBuilder(context)
|
||||
|
||||
val workspaceScriptConfiguration = ScriptCompilationConfiguration {
|
||||
baseClass(Any::class)
|
||||
implicitReceivers(WorkspaceBuilder::class)
|
||||
defaultImports("hep.dataforge.workspace.*")
|
||||
jvm {
|
||||
dependenciesFromCurrentContext(wholeClasspath = true)
|
||||
}
|
||||
@ -31,8 +33,10 @@ object Builders {
|
||||
BasicJvmScriptingHost().eval(source, workspaceScriptConfiguration, evaluationConfiguration).onFailure {
|
||||
it.reports.forEach { scriptDiagnostic ->
|
||||
when (scriptDiagnostic.severity) {
|
||||
ScriptDiagnostic.Severity.FATAL, ScriptDiagnostic.Severity.ERROR ->
|
||||
ScriptDiagnostic.Severity.FATAL, ScriptDiagnostic.Severity.ERROR -> {
|
||||
context.logger.error(scriptDiagnostic.exception) { scriptDiagnostic.toString() }
|
||||
error(scriptDiagnostic.toString())
|
||||
}
|
||||
ScriptDiagnostic.Severity.WARNING -> context.logger.warn { scriptDiagnostic.toString() }
|
||||
ScriptDiagnostic.Severity.INFO -> context.logger.info { scriptDiagnostic.toString() }
|
||||
ScriptDiagnostic.Severity.DEBUG -> context.logger.debug { scriptDiagnostic.toString() }
|
||||
|
@ -1,20 +1,33 @@
|
||||
package hep.dataforge.scripting
|
||||
|
||||
import hep.dataforge.context.Global
|
||||
import hep.dataforge.meta.get
|
||||
import hep.dataforge.meta.int
|
||||
import hep.dataforge.workspace.*
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
|
||||
class BuildersKtTest {
|
||||
@Test
|
||||
fun checkBuilder(){
|
||||
val workspace = SimpleWorkspaceBuilder(Global).apply {
|
||||
println("I am working")
|
||||
|
||||
context("test")
|
||||
|
||||
target("testTarget"){
|
||||
"a" to 12
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWorkspaceBuilder() {
|
||||
val script = """
|
||||
println("I am working")
|
||||
|
||||
context{
|
||||
name = "test"
|
||||
}
|
||||
context("test")
|
||||
|
||||
target("testTarget"){
|
||||
"a" to 12
|
||||
|
@ -26,7 +26,7 @@ interface WorkspaceBuilder {
|
||||
/**
|
||||
* Set the context for future workspcace
|
||||
*/
|
||||
fun WorkspaceBuilder.context(name: String, block: ContextBuilder.() -> Unit) {
|
||||
fun WorkspaceBuilder.context(name: String, block: ContextBuilder.() -> Unit = {}) {
|
||||
context = ContextBuilder(name, parentContext).apply(block).build()
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ enableFeaturePreview("GRADLE_METADATA")
|
||||
rootProject.name = "dataforge-core"
|
||||
include(
|
||||
":dataforge-meta",
|
||||
":dataforge-meta-io",
|
||||
":dataforge-io",
|
||||
":dataforge-context",
|
||||
":dataforge-data",
|
||||
":dataforge-output",
|
||||
|
Loading…
Reference in New Issue
Block a user