Few fixes for Workspaces builders.
This commit is contained in:
parent
58e65ba71e
commit
5480d90a36
@ -45,7 +45,7 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "hep.dataforge"
|
group = "hep.dataforge"
|
||||||
version = "0.1.2-dev-2"
|
version = "0.1.2-dev-3"
|
||||||
|
|
||||||
// apply bintray configuration
|
// apply bintray configuration
|
||||||
apply(from = "${rootProject.rootDir}/gradle/bintray.gradle")
|
apply(from = "${rootProject.rootDir}/gradle/bintray.gradle")
|
||||||
@ -117,38 +117,43 @@ subprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
configure<NodeExtension>{
|
val runJsTests by ext(false)
|
||||||
nodeModulesDir = file("$buildDir/node_modules")
|
|
||||||
}
|
|
||||||
|
|
||||||
val compileKotlinJs by tasks.getting(Kotlin2JsCompile::class)
|
if(runJsTests) {
|
||||||
val compileTestKotlinJs by tasks.getting(Kotlin2JsCompile::class)
|
|
||||||
|
|
||||||
val populateNodeModules by tasks.registering(Copy::class) {
|
configure<NodeExtension> {
|
||||||
dependsOn(compileKotlinJs)
|
nodeModulesDir = file("$buildDir/node_modules")
|
||||||
from(compileKotlinJs.destinationDir)
|
|
||||||
|
|
||||||
compilations["test"].runtimeDependencyFiles.forEach {
|
|
||||||
if (it.exists() && !it.isDirectory) {
|
|
||||||
from(zipTree(it.absolutePath).matching { include("*.js") })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
into("$buildDir/node_modules")
|
val compileKotlinJs by tasks.getting(Kotlin2JsCompile::class)
|
||||||
}
|
val compileTestKotlinJs by tasks.getting(Kotlin2JsCompile::class)
|
||||||
|
|
||||||
val installMocha by tasks.registering(NpmTask::class) {
|
val populateNodeModules by tasks.registering(Copy::class) {
|
||||||
setWorkingDir(buildDir)
|
dependsOn(compileKotlinJs)
|
||||||
setArgs(listOf("install", "mocha"))
|
from(compileKotlinJs.destinationDir)
|
||||||
}
|
|
||||||
|
|
||||||
val runMocha by tasks.registering(NodeTask::class) {
|
compilations["test"].runtimeDependencyFiles.forEach {
|
||||||
dependsOn(compileTestKotlinJs, populateNodeModules, installMocha)
|
if (it.exists() && !it.isDirectory) {
|
||||||
setScript(file("$buildDir/node_modules/mocha/bin/mocha"))
|
from(zipTree(it.absolutePath).matching { include("*.js") })
|
||||||
setArgs(listOf(compileTestKotlinJs.outputFile))
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks["jsTest"].dependsOn(runMocha)
|
into("$buildDir/node_modules")
|
||||||
|
}
|
||||||
|
|
||||||
|
val installMocha by tasks.registering(NpmTask::class) {
|
||||||
|
setWorkingDir(buildDir)
|
||||||
|
setArgs(listOf("install", "mocha"))
|
||||||
|
}
|
||||||
|
|
||||||
|
val runMocha by tasks.registering(NodeTask::class) {
|
||||||
|
dependsOn(compileTestKotlinJs, populateNodeModules, installMocha)
|
||||||
|
setScript(file("$buildDir/node_modules/mocha/bin/mocha"))
|
||||||
|
setArgs(listOf(compileTestKotlinJs.outputFile))
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks["jsTest"].dependsOn(runMocha)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
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.meta.*
|
||||||
import hep.dataforge.values.*
|
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.Meta
|
||||||
import hep.dataforge.meta.get
|
import hep.dataforge.meta.get
|
||||||
@ -9,13 +9,6 @@ interface Envelope {
|
|||||||
val data: Binary?
|
val data: Binary?
|
||||||
|
|
||||||
companion object {
|
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
|
* meta keys
|
@ -1,4 +1,4 @@
|
|||||||
package hep.dataforge.meta.io
|
package hep.dataforge.io
|
||||||
|
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
import hep.dataforge.meta.MetaItem
|
import hep.dataforge.meta.MetaItem
|
@ -1,4 +1,4 @@
|
|||||||
package hep.dataforge.meta.io
|
package hep.dataforge.io
|
||||||
|
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
import kotlinx.io.core.*
|
import kotlinx.io.core.*
|
@ -1,4 +1,4 @@
|
|||||||
package hep.dataforge.meta.io
|
package hep.dataforge.io
|
||||||
|
|
||||||
import hep.dataforge.meta.buildMeta
|
import hep.dataforge.meta.buildMeta
|
||||||
import kotlin.test.Test
|
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{
|
val commonMain by getting{
|
||||||
dependencies {
|
dependencies {
|
||||||
api(project(":dataforge-context"))
|
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.Context
|
||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
|
import hep.dataforge.workspace.SimpleWorkspaceBuilder
|
||||||
import hep.dataforge.workspace.Workspace
|
import hep.dataforge.workspace.Workspace
|
||||||
import hep.dataforge.workspace.WorkspaceBuilder
|
import hep.dataforge.workspace.WorkspaceBuilder
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@ -14,11 +15,12 @@ import kotlin.script.experimental.jvmhost.BasicJvmScriptingHost
|
|||||||
object Builders {
|
object Builders {
|
||||||
|
|
||||||
fun buildWorkspace(source: SourceCode, context: Context = Global): Workspace {
|
fun buildWorkspace(source: SourceCode, context: Context = Global): Workspace {
|
||||||
val builder = WorkspaceBuilder(context)
|
val builder = SimpleWorkspaceBuilder(context)
|
||||||
|
|
||||||
val workspaceScriptConfiguration = ScriptCompilationConfiguration {
|
val workspaceScriptConfiguration = ScriptCompilationConfiguration {
|
||||||
baseClass(Any::class)
|
baseClass(Any::class)
|
||||||
implicitReceivers(WorkspaceBuilder::class)
|
implicitReceivers(WorkspaceBuilder::class)
|
||||||
|
defaultImports("hep.dataforge.workspace.*")
|
||||||
jvm {
|
jvm {
|
||||||
dependenciesFromCurrentContext(wholeClasspath = true)
|
dependenciesFromCurrentContext(wholeClasspath = true)
|
||||||
}
|
}
|
||||||
@ -31,8 +33,10 @@ object Builders {
|
|||||||
BasicJvmScriptingHost().eval(source, workspaceScriptConfiguration, evaluationConfiguration).onFailure {
|
BasicJvmScriptingHost().eval(source, workspaceScriptConfiguration, evaluationConfiguration).onFailure {
|
||||||
it.reports.forEach { scriptDiagnostic ->
|
it.reports.forEach { scriptDiagnostic ->
|
||||||
when (scriptDiagnostic.severity) {
|
when (scriptDiagnostic.severity) {
|
||||||
ScriptDiagnostic.Severity.FATAL, ScriptDiagnostic.Severity.ERROR ->
|
ScriptDiagnostic.Severity.FATAL, ScriptDiagnostic.Severity.ERROR -> {
|
||||||
context.logger.error(scriptDiagnostic.exception) { scriptDiagnostic.toString() }
|
context.logger.error(scriptDiagnostic.exception) { scriptDiagnostic.toString() }
|
||||||
|
error(scriptDiagnostic.toString())
|
||||||
|
}
|
||||||
ScriptDiagnostic.Severity.WARNING -> context.logger.warn { scriptDiagnostic.toString() }
|
ScriptDiagnostic.Severity.WARNING -> context.logger.warn { scriptDiagnostic.toString() }
|
||||||
ScriptDiagnostic.Severity.INFO -> context.logger.info { scriptDiagnostic.toString() }
|
ScriptDiagnostic.Severity.INFO -> context.logger.info { scriptDiagnostic.toString() }
|
||||||
ScriptDiagnostic.Severity.DEBUG -> context.logger.debug { scriptDiagnostic.toString() }
|
ScriptDiagnostic.Severity.DEBUG -> context.logger.debug { scriptDiagnostic.toString() }
|
||||||
|
@ -1,20 +1,33 @@
|
|||||||
package hep.dataforge.scripting
|
package hep.dataforge.scripting
|
||||||
|
|
||||||
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.meta.get
|
import hep.dataforge.meta.get
|
||||||
import hep.dataforge.meta.int
|
import hep.dataforge.meta.int
|
||||||
|
import hep.dataforge.workspace.*
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
|
||||||
class BuildersKtTest {
|
class BuildersKtTest {
|
||||||
|
@Test
|
||||||
|
fun checkBuilder(){
|
||||||
|
val workspace = SimpleWorkspaceBuilder(Global).apply {
|
||||||
|
println("I am working")
|
||||||
|
|
||||||
|
context("test")
|
||||||
|
|
||||||
|
target("testTarget"){
|
||||||
|
"a" to 12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testWorkspaceBuilder() {
|
fun testWorkspaceBuilder() {
|
||||||
val script = """
|
val script = """
|
||||||
println("I am working")
|
println("I am working")
|
||||||
|
|
||||||
context{
|
context("test")
|
||||||
name = "test"
|
|
||||||
}
|
|
||||||
|
|
||||||
target("testTarget"){
|
target("testTarget"){
|
||||||
"a" to 12
|
"a" to 12
|
||||||
|
@ -26,7 +26,7 @@ interface WorkspaceBuilder {
|
|||||||
/**
|
/**
|
||||||
* Set the context for future workspcace
|
* 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()
|
context = ContextBuilder(name, parentContext).apply(block).build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ enableFeaturePreview("GRADLE_METADATA")
|
|||||||
rootProject.name = "dataforge-core"
|
rootProject.name = "dataforge-core"
|
||||||
include(
|
include(
|
||||||
":dataforge-meta",
|
":dataforge-meta",
|
||||||
":dataforge-meta-io",
|
":dataforge-io",
|
||||||
":dataforge-context",
|
":dataforge-context",
|
||||||
":dataforge-data",
|
":dataforge-data",
|
||||||
":dataforge-output",
|
":dataforge-output",
|
||||||
|
Loading…
Reference in New Issue
Block a user