From 8c6c93ab0f2da7e96b41f1d54b28f79d47c5ecd4 Mon Sep 17 00:00:00 2001 From: Samuel Pantze <83579186+smlpt@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:03:27 +0200 Subject: [PATCH] Make newest sciview compatible with local scenery (stupid jackson) --- build.gradle.kts | 88 ++++++++++--------- gradle.properties | 2 +- .../sc/iview/StartEyeTrackingDirectly.kt | 51 ++++++----- 3 files changed, 71 insertions(+), 70 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8418f8cd..6da63a56 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -149,29 +149,29 @@ dependencies { val isRelease: Boolean get() = System.getProperty("release") == "true" -kotlin { - jvmToolchain(21) -// compilerOptions { -// jvmTarget = JvmTarget.JVM_21 -// freeCompilerArgs = listOf("-Xinline-classes", "-opt-in=kotlin.RequiresOptIn") -// } -} - -java { - targetCompatibility = JavaVersion.VERSION_21 - sourceCompatibility = JavaVersion.VERSION_21 -} +//kotlin { +// jvmToolchain(21) +//// compilerOptions { +//// jvmTarget = JvmTarget.JVM_21 +//// freeCompilerArgs = listOf("-Xinline-classes", "-opt-in=kotlin.RequiresOptIn") +//// } +//} +// +//java { +// targetCompatibility = JavaVersion.VERSION_21 +// sourceCompatibility = JavaVersion.VERSION_21 +//} tasks { -// withType().all { -// val version = System.getProperty("java.version").substringBefore('.').toInt() -// val default = if (version == 1) "21" else "$version" -// kotlinOptions { -// jvmTarget = project.properties["jvmTarget"]?.toString() ?: default -// freeCompilerArgs += listOf("-Xinline-classes", "-Xopt-in=kotlin.RequiresOptIn") -// } -//// sourceCompatibility = project.properties["sourceCompatibility"]?.toString() ?: default -// } + withType().all { + val version = System.getProperty("java.version").substringBefore('.').toInt() + val default = if (version == 1) "21" else "$version" + kotlinOptions { + jvmTarget = project.properties["jvmTarget"]?.toString() ?: default + freeCompilerArgs += listOf("-Xinline-classes", "-Xopt-in=kotlin.RequiresOptIn") + } +// sourceCompatibility = project.properties["sourceCompatibility"]?.toString() ?: default + } test { finalizedBy(jacocoTestReport) // report is always generated after tests run } @@ -428,30 +428,32 @@ tasks { register(name = "run") { classpath = sourceSets.main.get().runtimeClasspath - if (project.hasProperty("target")) { - project.property("target")?.let { target -> - classpath = sourceSets.test.get().runtimeClasspath - - println("Target is $target") - // if(target.endsWith(".kt")) { - // main = target.substringAfter("kotlin${File.separatorChar}").replace(File.separatorChar, '.').substringBefore(".kt") - // } else { - // main = target.substringAfter("java${File.separatorChar}").replace(File.separatorChar, '.').substringBefore(".java") - // } - - mainClass.set("$target") - val props = System.getProperties().filter { (k, _) -> k.toString().startsWith("scenery.") } - - val additionalArgs = System.getenv("SCENERY_JVM_ARGS") - allJvmArgs = if (additionalArgs != null) { - allJvmArgs + props.flatMap { (k, v) -> listOf("-D$k=$v") } + additionalArgs - } else { - allJvmArgs + props.flatMap { (k, v) -> listOf("-D$k=$v") } - } + var target: Any? = null + if (project.hasProperty("target")) + target = project.property("target") + target = "StartEyeTrackingDirectlyKt" + if (target != null) { + classpath = sourceSets.test.get().runtimeClasspath + + println("Target is $target") + // if(target.endsWith(".kt")) { + // main = target.substringAfter("kotlin${File.separatorChar}").replace(File.separatorChar, '.').substringBefore(".kt") + // } else { + // main = target.substringAfter("java${File.separatorChar}").replace(File.separatorChar, '.').substringBefore(".java") + // } + + mainClass.set("$target") + val props = System.getProperties().filter { (k, _) -> k.toString().startsWith("scenery.") } - println("Will run target $target with classpath $classpath, main=${mainClass.get()}") - println("JVM arguments passed to target: $allJvmArgs") + val additionalArgs = System.getenv("SCENERY_JVM_ARGS") + allJvmArgs = if (additionalArgs != null) { + allJvmArgs + props.flatMap { (k, v) -> listOf("-D$k=$v") } + additionalArgs + } else { + allJvmArgs + props.flatMap { (k, v) -> listOf("-D$k=$v") } } + + println("Will run target $target with classpath $classpath, main=${mainClass.get()}") + println("JVM arguments passed to target: $allJvmArgs") } } diff --git a/gradle.properties b/gradle.properties index 91aaef27..a380f1c7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ org.gradle.jvmargs=-XX:MaxMetaspaceSize=2g org.gradle.caching=true jvmTarget=21 -#useLocalScenery=true +useLocalScenery=true kotlinVersion=1.9.23 dokkaVersion=1.9.10 scijavaParentPOMVersion=37.0.0 diff --git a/src/test/kotlin/sc/iview/StartEyeTrackingDirectly.kt b/src/test/kotlin/sc/iview/StartEyeTrackingDirectly.kt index 77767cfb..33164755 100644 --- a/src/test/kotlin/sc/iview/StartEyeTrackingDirectly.kt +++ b/src/test/kotlin/sc/iview/StartEyeTrackingDirectly.kt @@ -1,38 +1,37 @@ -package sc.iview - import graphics.scenery.utils.lazyLogger import graphics.scenery.volumes.RAIVolume import graphics.scenery.volumes.TransferFunction import org.scijava.command.CommandService import org.scijava.ui.UIService +import sc.iview.SciView import sc.iview.commands.demo.advanced.EyeTrackingDemo -object StartEyeTrackingDirectly { +//object StartEye { - val logger by lazyLogger() +// val logger by lazyLogger() - @JvmStatic - fun main(args: Array) { - val sv = SciView.create() - val context = sv.scijavaContext - val uiService = context?.service(UIService::class.java) - uiService?.showUI() +// @JvmStatic +fun main() { + val sv = SciView.create() + val context = sv.scijavaContext + val uiService = context?.service(UIService::class.java) + uiService?.showUI() - sv.open("C:/Software/datasets/MastodonTutorialDataset1/datasethdf5.xml") - val volumes = sv.findNodes { it.javaClass == RAIVolume::class.java } - volumes.first().let { - it as RAIVolume - it.minDisplayRange = 400f - it.maxDisplayRange = 1500f - val tf = TransferFunction() - tf.addControlPoint(0f, 0f) - tf.addControlPoint(1f, 1f) - it.transferFunction = tf - } + sv.open("C:/Software/datasets/MastodonTutorialDataset1/datasethdf5.xml") + val volumes = sv.findNodes { it.javaClass == RAIVolume::class.java } + volumes.first().let { + it as RAIVolume + it.minDisplayRange = 400f + it.maxDisplayRange = 1500f + val tf = TransferFunction() + tf.addControlPoint(0f, 0f) + tf.addControlPoint(1f, 1f) + it.transferFunction = tf + } - val command = sv.scijavaContext!!.getService(CommandService::class.java) - val argmap = HashMap() - command.run(EyeTrackingDemo::class.java, true, argmap) + val command = sv.scijavaContext!!.getService(CommandService::class.java) + val argmap = HashMap() + command.run(EyeTrackingDemo::class.java, true, argmap) - } -} \ No newline at end of file +} +//} \ No newline at end of file