diff --git a/README.MD b/README.MD index 867ed1f..218dadc 100644 --- a/README.MD +++ b/README.MD @@ -16,6 +16,7 @@ * [KEEP: Kotlin Scripting support](https://github.com/Kotlin/KEEP/blob/master/proposals/scripting-support.md#embedded-scripting) * [Обсуждение KEEP на GitHub](https://github.com/Kotlin/KEEP/issues/75) +* [KotlinConf 2019: Implementing the Gradle Kotlin DSL by Rodrigo Oliveira](https://www.youtube.com/watch?v=OEFwnWxoazI) - доклад от авторов Gradle * [Roadmap развития Kotlin](https://kotlinlang.org/docs/roadmap.html) * [Официальные примеры встраивания Kotlin Script](https://github.com/Kotlin/kotlin-script-examples) * [The Java Scripting API](https://docs.oracle.com/javase/8/docs/technotes/guides/scripting/prog_guide/api.html) diff --git a/gitlab-ci-kts/script-loader-jsr223/src/main/kotlin/jsr223/GitlabCiScriptEngineFactory.kt b/gitlab-ci-kts/script-loader-jsr223/src/main/kotlin/jsr223/GitlabCiScriptEngineFactory.kt index 74daf53..094da7e 100644 --- a/gitlab-ci-kts/script-loader-jsr223/src/main/kotlin/jsr223/GitlabCiScriptEngineFactory.kt +++ b/gitlab-ci-kts/script-loader-jsr223/src/main/kotlin/jsr223/GitlabCiScriptEngineFactory.kt @@ -18,7 +18,6 @@ import kotlin.script.experimental.jvmhost.createJvmScriptDefinitionFromTemplate import kotlin.script.experimental.jvmhost.jsr223.KotlinJsr223ScriptEngineImpl class GitlabCiScriptEngineFactory : KotlinJsr223JvmScriptEngineFactoryBase() { - private val scriptDefinition = createJvmScriptDefinitionFromTemplate() private var lastClassLoader: ClassLoader? = null private var lastClassPath: List? = null @@ -26,6 +25,19 @@ class GitlabCiScriptEngineFactory : KotlinJsr223JvmScriptEngineFactoryBase() { override fun getExtensions(): List = listOf(scriptDefinition.compilationConfiguration[ScriptCompilationConfiguration.fileExtension]!!) + override fun getScriptEngine(): ScriptEngine = + KotlinJsr223ScriptEngineImpl( + this, + scriptDefinition.compilationConfiguration.with { + jvm { + dependenciesFromCurrentContext() + } + }, + scriptDefinition.evaluationConfiguration.with { + implicitReceivers(PipelineBuilder()) + } + ) { ScriptArgsWithTypes(arrayOf(), arrayOf()) } + @Synchronized private fun JvmScriptCompilationConfigurationBuilder.dependenciesFromCurrentContext() { val currentClassLoader = Thread.currentThread().contextClassLoader @@ -41,13 +53,4 @@ class GitlabCiScriptEngineFactory : KotlinJsr223JvmScriptEngineFactoryBase() { } else lastClassPath!! updateClasspath(classPath) } - - override fun getScriptEngine(): ScriptEngine = - KotlinJsr223ScriptEngineImpl( - this, - scriptDefinition.compilationConfiguration.with { }, - scriptDefinition.evaluationConfiguration.with { - implicitReceivers(PipelineBuilder()) - } - ) { ScriptArgsWithTypes(arrayOf(), arrayOf()) } } diff --git a/presentation/assets/IDE.png b/presentation/assets/IDE.png index 05df4f8..45eefb7 100644 Binary files a/presentation/assets/IDE.png and b/presentation/assets/IDE.png differ diff --git a/presentation/assets/IDE_closeup.png b/presentation/assets/IDE_closeup.png new file mode 100644 index 0000000..d3475b9 Binary files /dev/null and b/presentation/assets/IDE_closeup.png differ diff --git a/presentation/assets/IDE_scriptDefPath.png b/presentation/assets/IDE_scriptDefPath.png index 6c89c35..23de270 100644 Binary files a/presentation/assets/IDE_scriptDefPath.png and b/presentation/assets/IDE_scriptDefPath.png differ diff --git a/presentation/assets/examples/ScriptWithDeps.groovy b/presentation/assets/examples/ScriptWithDeps.groovy new file mode 100755 index 0000000..9b3f2c2 --- /dev/null +++ b/presentation/assets/examples/ScriptWithDeps.groovy @@ -0,0 +1,10 @@ +#!/usr/bin/env groovy +@Grab('com.fasterxml.jackson.core:jackson-databind:2.17.0') + +import com.fasterxml.jackson.databind.ObjectMapper + +def value = new ObjectMapper().with { + readValue('{"key":"Hello, World!"}', Map.class)["key"] +} +println value + diff --git a/presentation/assets/examples/java/11/Prog.java b/presentation/assets/examples/java/11/Prog.java new file mode 100755 index 0000000..3eb3912 --- /dev/null +++ b/presentation/assets/examples/java/11/Prog.java @@ -0,0 +1,9 @@ +///usr/bin/env java "$0" "$@" ; exit $? + +class Prog { + public static void main(String[] args) { Helper.run(); } +} + +class Helper { + static void run() { System.out.println("Hello!"); } +} \ No newline at end of file diff --git a/presentation/assets/examples/java/22/Helper.java b/presentation/assets/examples/java/22/Helper.java new file mode 100644 index 0000000..43fc1af --- /dev/null +++ b/presentation/assets/examples/java/22/Helper.java @@ -0,0 +1,3 @@ +class Helper { + static void run() { System.out.println("Hello!"); } +} \ No newline at end of file diff --git a/presentation/assets/examples/java/22/Prog.java b/presentation/assets/examples/java/22/Prog.java new file mode 100755 index 0000000..b2b04c2 --- /dev/null +++ b/presentation/assets/examples/java/22/Prog.java @@ -0,0 +1,5 @@ +///usr/bin/env java "$0" "$@" ; exit $? + +class Prog { + public static void main(String[] args) { Helper.run(); } +} \ No newline at end of file diff --git a/presentation/assets/examples/jbang/JBangEx.groovy b/presentation/assets/examples/jbang/JBangEx.groovy new file mode 100755 index 0000000..ad9bc50 --- /dev/null +++ b/presentation/assets/examples/jbang/JBangEx.groovy @@ -0,0 +1,9 @@ +///usr/bin/env jbang "$0" "$@" ; exit $? +//DEPS com.fasterxml.jackson.core:jackson-databind:2.17.0 + +import com.fasterxml.jackson.databind.ObjectMapper + +def value = new ObjectMapper().with { + readValue('{"key":"Hello, World!"}', Map.class) +} +println value["key"] \ No newline at end of file diff --git a/presentation/assets/examples/jbang/JBangEx.java b/presentation/assets/examples/jbang/JBangEx.java new file mode 100755 index 0000000..6897319 --- /dev/null +++ b/presentation/assets/examples/jbang/JBangEx.java @@ -0,0 +1,13 @@ +///usr/bin/env jbang "$0" "$@" ; exit $? +//DEPS com.fasterxml.jackson.core:jackson-databind:2.17.0 + +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.Map; + +class Main { + public static void main(String[] args) throws Exception { + ObjectMapper mapper = new ObjectMapper(); + var value = mapper.readValue("{\"key\":\"Hello, World!\"}", Map.class); + System.out.println(value.get("key")); + } +} \ No newline at end of file diff --git a/presentation/assets/examples/jbang/JBangEx.kt b/presentation/assets/examples/jbang/JBangEx.kt new file mode 100755 index 0000000..b3f4d8a --- /dev/null +++ b/presentation/assets/examples/jbang/JBangEx.kt @@ -0,0 +1,13 @@ +///usr/bin/env jbang "$0" "$@" ; exit $? +//DEPS com.fasterxml.jackson.module:jackson-module-kotlin:2.17.0 + +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import com.fasterxml.jackson.module.kotlin.readValue + +val value = jacksonObjectMapper().readValue>( + """{"key":"Hello, World!"}""" +) + +fun main() { + println(value.get("key")) +} diff --git a/presentation/assets/examples/kscript.kts b/presentation/assets/examples/kscript.kts new file mode 100755 index 0000000..9bf0555 --- /dev/null +++ b/presentation/assets/examples/kscript.kts @@ -0,0 +1,12 @@ +#!/usr/bin/env kscript + +@file:DependsOn("com.fasterxml.jackson.module:jackson-module-kotlin:2.17.0") + +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import com.fasterxml.jackson.module.kotlin.readValue + +val value = jacksonObjectMapper().readValue>( + """{"key":"Hello, World!"}""" +) + +println(value["key"]) diff --git a/presentation/assets/microkernel-arch.svg b/presentation/assets/microkernel-arch.svg new file mode 100644 index 0000000..94b1b50 --- /dev/null +++ b/presentation/assets/microkernel-arch.svg @@ -0,0 +1,101 @@ +PluginPluginPluginCorePluginPluginPlugin + + + + + + + + + diff --git a/presentation/assets/plugin-arch.png b/presentation/assets/plugin-arch.png deleted file mode 100644 index aadfb7d..0000000 Binary files a/presentation/assets/plugin-arch.png and /dev/null differ diff --git a/presentation/assets/scripting-configuration.svg b/presentation/assets/scripting-configuration.svg index b9bb25a..3c797bd 100644 --- a/presentation/assets/scripting-configuration.svg +++ b/presentation/assets/scripting-configuration.svg @@ -1,16 +1,16 @@ -Scripting Host (app)Script DefinitionCompilerEvaluatorCompilation configurationHost configurationEvaluation configuration + .d2-1907310478 .fill-N1{fill:#ffffff;} + .d2-1907310478 .fill-N2{fill:#BAC2DE;} + .d2-1907310478 .fill-N3{fill:#A6ADC8;} + .d2-1907310478 .fill-N4{fill:#585B70;} + .d2-1907310478 .fill-N5{fill:#45475A;} + .d2-1907310478 .fill-N6{fill:#313244;} + .d2-1907310478 .fill-N7{fill:#191919;} + .d2-1907310478 .fill-B1{fill:#ffffff;} + .d2-1907310478 .fill-B2{fill:#CBA6f7;} + .d2-1907310478 .fill-B3{fill:#6C7086;} + .d2-1907310478 .fill-B4{fill:#585B70;} + .d2-1907310478 .fill-B5{fill:#45475A;} + .d2-1907310478 .fill-B6{fill:#313244;} + .d2-1907310478 .fill-AA2{fill:#f38BA8;} + .d2-1907310478 .fill-AA4{fill:#45475A;} + .d2-1907310478 .fill-AA5{fill:#313244;} + .d2-1907310478 .fill-AB4{fill:#45475A;} + .d2-1907310478 .fill-AB5{fill:#313244;} + .d2-1907310478 .stroke-N1{stroke:#ffffff;} + .d2-1907310478 .stroke-N2{stroke:#BAC2DE;} + .d2-1907310478 .stroke-N3{stroke:#A6ADC8;} + .d2-1907310478 .stroke-N4{stroke:#585B70;} + .d2-1907310478 .stroke-N5{stroke:#45475A;} + .d2-1907310478 .stroke-N6{stroke:#313244;} + .d2-1907310478 .stroke-N7{stroke:#191919;} + .d2-1907310478 .stroke-B1{stroke:#ffffff;} + .d2-1907310478 .stroke-B2{stroke:#CBA6f7;} + .d2-1907310478 .stroke-B3{stroke:#6C7086;} + .d2-1907310478 .stroke-B4{stroke:#585B70;} + .d2-1907310478 .stroke-B5{stroke:#45475A;} + .d2-1907310478 .stroke-B6{stroke:#313244;} + .d2-1907310478 .stroke-AA2{stroke:#f38BA8;} + .d2-1907310478 .stroke-AA4{stroke:#45475A;} + .d2-1907310478 .stroke-AA5{stroke:#313244;} + .d2-1907310478 .stroke-AB4{stroke:#45475A;} + .d2-1907310478 .stroke-AB5{stroke:#313244;} + .d2-1907310478 .background-color-N1{background-color:#ffffff;} + .d2-1907310478 .background-color-N2{background-color:#BAC2DE;} + .d2-1907310478 .background-color-N3{background-color:#A6ADC8;} + .d2-1907310478 .background-color-N4{background-color:#585B70;} + .d2-1907310478 .background-color-N5{background-color:#45475A;} + .d2-1907310478 .background-color-N6{background-color:#313244;} + .d2-1907310478 .background-color-N7{background-color:#191919;} + .d2-1907310478 .background-color-B1{background-color:#ffffff;} + .d2-1907310478 .background-color-B2{background-color:#CBA6f7;} + .d2-1907310478 .background-color-B3{background-color:#6C7086;} + .d2-1907310478 .background-color-B4{background-color:#585B70;} + .d2-1907310478 .background-color-B5{background-color:#45475A;} + .d2-1907310478 .background-color-B6{background-color:#313244;} + .d2-1907310478 .background-color-AA2{background-color:#f38BA8;} + .d2-1907310478 .background-color-AA4{background-color:#45475A;} + .d2-1907310478 .background-color-AA5{background-color:#313244;} + .d2-1907310478 .background-color-AB4{background-color:#45475A;} + .d2-1907310478 .background-color-AB5{background-color:#313244;} + .d2-1907310478 .color-N1{color:#ffffff;} + .d2-1907310478 .color-N2{color:#BAC2DE;} + .d2-1907310478 .color-N3{color:#A6ADC8;} + .d2-1907310478 .color-N4{color:#585B70;} + .d2-1907310478 .color-N5{color:#45475A;} + .d2-1907310478 .color-N6{color:#313244;} + .d2-1907310478 .color-N7{color:#191919;} + .d2-1907310478 .color-B1{color:#ffffff;} + .d2-1907310478 .color-B2{color:#CBA6f7;} + .d2-1907310478 .color-B3{color:#6C7086;} + .d2-1907310478 .color-B4{color:#585B70;} + .d2-1907310478 .color-B5{color:#45475A;} + .d2-1907310478 .color-B6{color:#313244;} + .d2-1907310478 .color-AA2{color:#f38BA8;} + .d2-1907310478 .color-AA4{color:#45475A;} + .d2-1907310478 .color-AA5{color:#313244;} + .d2-1907310478 .color-AB4{color:#45475A;} + .d2-1907310478 .color-AB5{color:#313244;}.appendix text.text{fill:#ffffff}.md{--color-fg-default:#ffffff;--color-fg-muted:#BAC2DE;--color-fg-subtle:#A6ADC8;--color-canvas-default:#191919;--color-canvas-subtle:#313244;--color-border-default:#ffffff;--color-border-muted:#CBA6f7;--color-neutral-muted:#313244;--color-accent-fg:#CBA6f7;--color-accent-emphasis:#CBA6f7;--color-attention-subtle:#BAC2DE;--color-danger-fg:red;}.sketch-overlay-B1{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B2{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-B3{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-B4{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-B5{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-B6{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-AA2{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-AA4{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-AA5{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-AB4{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-AB5{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-N1{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N2{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N3{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N4{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-N5{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-N6{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-N7{fill:url(#streaks-darker);mix-blend-mode:lighten}.light-code{display: none}.dark-code{display: block}]]>Scripting Host (app)Script DefinitionCompilerEvaluatorCompilation configurationHost configurationEvaluation configuration diff --git a/presentation/assets/scripting-host.svg b/presentation/assets/scripting-host.svg index 454c0db..b0768df 100644 --- a/presentation/assets/scripting-host.svg +++ b/presentation/assets/scripting-host.svg @@ -1,9 +1,9 @@ -JVM ClassesScripting Host (app)ScriptResultScript DefinitionCompilerEvaluator + .d2-3967112407 .fill-N1{fill:#ffffff;} + .d2-3967112407 .fill-N2{fill:#BAC2DE;} + .d2-3967112407 .fill-N3{fill:#A6ADC8;} + .d2-3967112407 .fill-N4{fill:#585B70;} + .d2-3967112407 .fill-N5{fill:#45475A;} + .d2-3967112407 .fill-N6{fill:#313244;} + .d2-3967112407 .fill-N7{fill:#191919;} + .d2-3967112407 .fill-B1{fill:#ffffff;} + .d2-3967112407 .fill-B2{fill:#CBA6f7;} + .d2-3967112407 .fill-B3{fill:#6C7086;} + .d2-3967112407 .fill-B4{fill:#585B70;} + .d2-3967112407 .fill-B5{fill:#45475A;} + .d2-3967112407 .fill-B6{fill:#313244;} + .d2-3967112407 .fill-AA2{fill:#f38BA8;} + .d2-3967112407 .fill-AA4{fill:#45475A;} + .d2-3967112407 .fill-AA5{fill:#313244;} + .d2-3967112407 .fill-AB4{fill:#45475A;} + .d2-3967112407 .fill-AB5{fill:#313244;} + .d2-3967112407 .stroke-N1{stroke:#ffffff;} + .d2-3967112407 .stroke-N2{stroke:#BAC2DE;} + .d2-3967112407 .stroke-N3{stroke:#A6ADC8;} + .d2-3967112407 .stroke-N4{stroke:#585B70;} + .d2-3967112407 .stroke-N5{stroke:#45475A;} + .d2-3967112407 .stroke-N6{stroke:#313244;} + .d2-3967112407 .stroke-N7{stroke:#191919;} + .d2-3967112407 .stroke-B1{stroke:#ffffff;} + .d2-3967112407 .stroke-B2{stroke:#CBA6f7;} + .d2-3967112407 .stroke-B3{stroke:#6C7086;} + .d2-3967112407 .stroke-B4{stroke:#585B70;} + .d2-3967112407 .stroke-B5{stroke:#45475A;} + .d2-3967112407 .stroke-B6{stroke:#313244;} + .d2-3967112407 .stroke-AA2{stroke:#f38BA8;} + .d2-3967112407 .stroke-AA4{stroke:#45475A;} + .d2-3967112407 .stroke-AA5{stroke:#313244;} + .d2-3967112407 .stroke-AB4{stroke:#45475A;} + .d2-3967112407 .stroke-AB5{stroke:#313244;} + .d2-3967112407 .background-color-N1{background-color:#ffffff;} + .d2-3967112407 .background-color-N2{background-color:#BAC2DE;} + .d2-3967112407 .background-color-N3{background-color:#A6ADC8;} + .d2-3967112407 .background-color-N4{background-color:#585B70;} + .d2-3967112407 .background-color-N5{background-color:#45475A;} + .d2-3967112407 .background-color-N6{background-color:#313244;} + .d2-3967112407 .background-color-N7{background-color:#191919;} + .d2-3967112407 .background-color-B1{background-color:#ffffff;} + .d2-3967112407 .background-color-B2{background-color:#CBA6f7;} + .d2-3967112407 .background-color-B3{background-color:#6C7086;} + .d2-3967112407 .background-color-B4{background-color:#585B70;} + .d2-3967112407 .background-color-B5{background-color:#45475A;} + .d2-3967112407 .background-color-B6{background-color:#313244;} + .d2-3967112407 .background-color-AA2{background-color:#f38BA8;} + .d2-3967112407 .background-color-AA4{background-color:#45475A;} + .d2-3967112407 .background-color-AA5{background-color:#313244;} + .d2-3967112407 .background-color-AB4{background-color:#45475A;} + .d2-3967112407 .background-color-AB5{background-color:#313244;} + .d2-3967112407 .color-N1{color:#ffffff;} + .d2-3967112407 .color-N2{color:#BAC2DE;} + .d2-3967112407 .color-N3{color:#A6ADC8;} + .d2-3967112407 .color-N4{color:#585B70;} + .d2-3967112407 .color-N5{color:#45475A;} + .d2-3967112407 .color-N6{color:#313244;} + .d2-3967112407 .color-N7{color:#191919;} + .d2-3967112407 .color-B1{color:#ffffff;} + .d2-3967112407 .color-B2{color:#CBA6f7;} + .d2-3967112407 .color-B3{color:#6C7086;} + .d2-3967112407 .color-B4{color:#585B70;} + .d2-3967112407 .color-B5{color:#45475A;} + .d2-3967112407 .color-B6{color:#313244;} + .d2-3967112407 .color-AA2{color:#f38BA8;} + .d2-3967112407 .color-AA4{color:#45475A;} + .d2-3967112407 .color-AA5{color:#313244;} + .d2-3967112407 .color-AB4{color:#45475A;} + .d2-3967112407 .color-AB5{color:#313244;}.appendix text.text{fill:#ffffff}.md{--color-fg-default:#ffffff;--color-fg-muted:#BAC2DE;--color-fg-subtle:#A6ADC8;--color-canvas-default:#191919;--color-canvas-subtle:#313244;--color-border-default:#ffffff;--color-border-muted:#CBA6f7;--color-neutral-muted:#313244;--color-accent-fg:#CBA6f7;--color-accent-emphasis:#CBA6f7;--color-attention-subtle:#BAC2DE;--color-danger-fg:red;}.sketch-overlay-B1{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B2{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-B3{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-B4{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-B5{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-B6{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-AA2{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-AA4{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-AA5{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-AB4{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-AB5{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-N1{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N2{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N3{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N4{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-N5{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-N6{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-N7{fill:url(#streaks-darker);mix-blend-mode:lighten}.light-code{display: none}.dark-code{display: block}]]>JVM ClassesScripting Host (app)ScriptResultScript DefinitionCompilerEvaluator diff --git a/presentation/assets/workflow-engine.svg b/presentation/assets/workflow-engine.svg new file mode 100644 index 0000000..db2005f --- /dev/null +++ b/presentation/assets/workflow-engine.svg @@ -0,0 +1,108 @@ +StartFind userIf B-Day todayMake pushPass truefalse + + + + + + + + + diff --git a/presentation/diagrams/microkernel-arch.d2 b/presentation/diagrams/microkernel-arch.d2 new file mode 100644 index 0000000..b43f0e6 --- /dev/null +++ b/presentation/diagrams/microkernel-arch.d2 @@ -0,0 +1,35 @@ +direction: right +vars: { + d2-config: { + pad: 0 + theme-id: 200 + layout-engine: elk + theme-overrides: { + N1: "#ffffff" + N7: "#191919" + B1: "#ffffff" + } + } +} + +grid-columns: 3 +grid-gap: 50 + +**.style.border-radius: 8 +**.style.font-size: 35 +(** <- scriptDef.*)[*].style.stroke-width: 4 + +plugin-l1: Plugin +plugin-l2: Plugin +plugin-l3: Plugin + +core: Core { + width: 200 + height: 400 +} + +plugin-r4: Plugin +plugin-r5: Plugin +plugin-r6: Plugin + +plugin* -> core diff --git a/presentation/diagrams/scripting-configuration.d2 b/presentation/diagrams/scripting-configuration.d2 index 349533d..c93572b 100644 --- a/presentation/diagrams/scripting-configuration.d2 +++ b/presentation/diagrams/scripting-configuration.d2 @@ -12,6 +12,7 @@ vars: { } } +**.style.border-radius: 8 **.style.font-size: 35 (** <- scriptDef.*)[*].style.stroke-width: 4 diff --git a/presentation/diagrams/scripting-host.d2 b/presentation/diagrams/scripting-host.d2 index 672623c..d43db24 100644 --- a/presentation/diagrams/scripting-host.d2 +++ b/presentation/diagrams/scripting-host.d2 @@ -12,6 +12,7 @@ vars: { } } +**.style.border-radius: 8 **.style.font-size: 35 (** -> **)[*].style.stroke-width: 4 diff --git a/presentation/diagrams/workflow-engine.d2 b/presentation/diagrams/workflow-engine.d2 new file mode 100644 index 0000000..496ffa1 --- /dev/null +++ b/presentation/diagrams/workflow-engine.d2 @@ -0,0 +1,35 @@ +direction: right +vars: { + d2-config: { + pad: 0 + theme-id: 200 + layout-engine: elk + theme-overrides: { + N1: "#ffffff" + N7: "#191919" + B1: "#ffffff" + } + } +} + +**.style.font-size: 35 +(** <- scriptDef.*)[*].style.stroke-width: 4 +*.style.border-radius: 8 + +start: Start +find: Find user +bday: If \nB-Day \ntoday { + shape: diamond +} +push: Make push { + near: top-right +} +pass: Pass { + near: bottom-right +} + +start -> find +find -> bday + +bday -> push: true +bday -> pass: false diff --git a/presentation/kotlin-script.reveal.kts b/presentation/kotlin-script.reveal.kts index 5f7d285..a6a7c98 100755 --- a/presentation/kotlin-script.reveal.kts +++ b/presentation/kotlin-script.reveal.kts @@ -33,13 +33,6 @@ configuration { } slides { - verticalSlide { - slide { - +title { "Kotlin Script" } - +title { "для кого, зачем и как" } - } - } - verticalSlide { regularSlide { +mediumTitle { "Кто я такой?" } @@ -62,8 +55,12 @@ slides { } } } + } + + verticalSlide { slide { - +title { "Тут вступление и т.д." } + +title { "Kotlin Script" } + +title { "для кого, зачем и как" } } } @@ -158,10 +155,26 @@ slides { slide { +smallTitle { "Обобщим" } +unorderedListOf( - "замена BASH-скриптов", - "Read-Eval-Print Loop (REPL)", - "компиляция скриптов с исходниками", - "встраивание скриптового движка", + regular { "Read-Eval-Print Loop (REPL)" }, + regular { "замена BASH-скриптов" }, + regular { "встраивание скриптового движка" }, + regular { "компиляция скриптов с исходниками" }, + fragmented = false + ) + +note { + """ + Называть причину по каждому пункту + К REPL можно отнести и Jupyter Kotlin + """.trimIndent() + } + } + slide { + +smallTitle { "Обобщим" } + +unorderedListOf( + regular { "Read-Eval-Print Loop (REPL)" }, + regular { "замена BASH-скриптов" }, + regular { "встраивание скриптового движка" }, + strike { "компиляция скриптов с исходниками" }, fragmented = false ) +note { @@ -254,6 +267,24 @@ slides { } slide { +replTitle + +smallTitle { "KScript (REPL mode)" } + +kotlinCode { + """ + > kscript --interactive kscript.kts + [kscript] Resolving com.fasterxml.jackson.module:jackson-module-kotlin:2.17.0... + [kscript] Creating REPL + Welcome to Kotlin version 1.9.22 (JRE 22+37) + Type :help for help, :quit for quit + >>> println("Hello, World!") + Hello, World! + >>> + """.trimIndent() + } + } + slide { + +smallTitle { "Kotlin REPL" } + } + slide { +smallTitle { "Kotlin SHELL" } +kotlinCode { """ @@ -311,8 +342,8 @@ slides { } //BASH + val autoTitle = smallTitle { "Замена BASH-скриптов в автоматизации задач" } verticalSlide { - val autoTitle = smallTitle { "Замена BASH-скриптов в автоматизации задач" } slide { +autoTitle } @@ -372,14 +403,122 @@ slides { slide { +smallTitle { "Альтернативы" } - +unorderedListOf( - "Java 22", - "Groovy", - "JBang (Java, Kotlin, Groovy)", - "KScript", - ) } + slide { + +smallTitle { "Java 11 (JEP 330)" } + +code(lang = "java") { + loadAsset("examples/java/11/Prog.java").decodeToString() + } + +code(lang = "bash") { + """ + > ./Prog.java + Hello! + """.trimIndent() + } + } + + slide { + +smallTitle { "Java 22 (JEP 458)" } + +code(lang = "java") { + loadAsset("examples/java/22/Prog.java").decodeToString() + } + +code(lang = "java") { + loadAsset("examples/java/22/Helper.java").decodeToString() + } + +code(lang = "bash") { + """ + > ./Prog.java + Hello! + """.trimIndent() + } + } + slide { + +smallTitle { "Groovy" } + +code(lang = "groovy") { + loadAsset("examples/ScriptWithDeps.groovy").decodeToString() + } + +code(lang = "bash") { + """ + > ./ScriptWithDeps.groovy + Hello, World! + """.trimIndent() + } + } + + slide { + +smallTitle { "JBang (java)" } + +code(lang = "java") { + loadAsset("examples/jbang/JBangEx.java").decodeToString() + } + +code(lang = "bash") { + """ + > ./JBangEx.java + [jbang] Resolving dependencies... + [jbang] com.fasterxml.jackson.core:jackson-databind:2.17.0 + [jbang] Dependencies resolved + [jbang] Building jar for JBangEx.java... + Hello, World! + """.trimIndent() + } + } + slide { + +smallTitle { "JBang (Groovy)" } + +code(lang = "groovy") { + loadAsset("examples/jbang/JBangEx.groovy").decodeToString() + } + +code(lang = "bash") { + """ + > ./JBangEx.groovy + [jbang] Downloading Groovy 4.0.14. Be patient, this can take several minutes... + [jbang] Installing Groovy 4.0.14... + [jbang] Resolving dependencies... + [jbang] com.fasterxml.jackson.core:jackson-databind:2.17.0 + [jbang] org.apache.groovy:groovy:4.0.14 + [jbang] Dependencies resolved + [jbang] Building jar for JBangEx.groovy... + Hello, World! + """.trimIndent() + } + } + slide { + +smallTitle { "JBang (Kotlin)" } + +code(lang = "kotlin") { + loadAsset("examples/jbang/JBangEx.kt").decodeToString() + } + +code(lang = "bash") { + """ + > ./JBangEx.kt + [jbang] Downloading Kotlin 1.8.22. Be patient, this can take several minutes... + [jbang] Installing Kotlin 1.8.22... + [jbang] Resolving dependencies... + [jbang] com.fasterxml.jackson.module:jackson-module-kotlin:2.17.0 + [jbang] Dependencies resolved + [jbang] Building jar for JBangEx.kt... + Hello, World! + """.trimIndent() + } + } + + slide { + +smallTitle { "KScript" } + +code(lang = "kotlin") { + loadAsset("examples/kscript.kts").decodeToString() + } + +code(lang = "bash") { + """ + > ./kscript.kts + [kscript] Resolving com.fasterxml.jackson.module:jackson-module-kotlin:2.17.0... + Hello, World! + """.trimIndent() + } + } + } + + verticalSlide { + slide { + +smallTitle { "Kotlin Script вместо BASH" } + } slide { +autoTitle +smallTitle { "Скрипты .kts" } @@ -413,7 +552,7 @@ slides { "Подключение репозиториев и библиотек", "Конфигурация комплятора в самом скрипте", "Кэширование между запусками", - "Удобная работа \"из коробки\"", + "Поддержка в IDE \"из коробки\"", ) } slide { @@ -466,14 +605,14 @@ slides { slide { +smallTitle { "микроядерная архитектура" } +smallTitle { "(плагинная архитектура)" } - +img("./plugin-arch.png") { + +img("./microkernel-arch.svg") { stretch = true } } slide { +smallTitle { "кастомизация действий пользователем" } - +img("./workflow-engine.png") { + +img("./workflow-engine.svg") { stretch = true } } @@ -502,28 +641,6 @@ slides { } } - //JSR223 -// verticalSlide { -// slide { -// +mediumTitle { "Java Scripting API" } -// +mediumTitle { "(JSR223)" } -// } -// slide { -// +mediumTitle { "Абстракция в JVM для исполнения скриптов" } -// } -// slide { -// +mediumTitle { "Kotlin Script > JSR223" } -// } -// slide { -// +mediumTitle { "Kotlin Script" } -// +unorderedListOf( -// "Компиляция", -// "Исполнение", -// "Работа с IDE" -// ) -// } -// } - verticalSlide { slide { +smallTitle { "Практика" } @@ -573,11 +690,6 @@ slides { } verticalSlide { - slide { - +smallTitle { "Описание скрипта" } - +smallTitle { "(Script Definition)" } - } - slide { +smallTitle { "Script Definition" } +img("scripting-configuration.svg") { @@ -639,6 +751,7 @@ slides { "Конфигурация IDE", "Параметры компилятора Kotlin", "Определение неявных (implicit) ресиверов", + "Доступные в скрипте свойства" ) } @@ -763,7 +876,7 @@ slides { +unorderedListOf( "Параметры запуска JVM", "Подкидывание созданных экземпляров implicit ресиверов", - "Аргументы коструктора для базового класса скрипта (MyShinyKtScript)", + "Аргументы коструктора для базового класса скрипта", "Возможность разделения инстансов скрипта", "Просмотр истории запусков (для REPL)", "Возможность переопределения любых частей скрипта" @@ -772,7 +885,7 @@ slides { slide { +evaluationTitle +exampleTitle - +kotlinCode { + +kotlinCode(lines = "1-3,9") { """ object GitlabCiKtEvaluationConfiguration : ScriptEvaluationConfiguration({ scriptsInstancesSharing(false) @@ -791,7 +904,7 @@ slides { slide { +evaluationTitle +exampleTitle - +kotlinCode { + +kotlinCode(lines = "3,12") { """ object GitlabCiKtEvaluationConfiguration : ScriptEvaluationConfiguration({ scriptsInstancesSharing(false) @@ -827,7 +940,12 @@ slides { compilationCache( CompiledScriptJarsCache { script, scriptCompilationConfiguration -> cacheBaseDir - .resolve(compiledScriptUniqueName(script, scriptCompilationConfiguration) + ".jar") + .resolve( + compiledScriptUniqueName( + script, + scriptCompilationConfiguration + ) + ".jar" + ) } ) } @@ -838,7 +956,7 @@ slides { slide { +hostTitle +exampleTitle - +kotlinCode { + +kotlinCode(lines = "6") { """ @KotlinScript( displayName = "Gitlab CI Kotlin configuration", @@ -898,15 +1016,15 @@ slides { } slide { +ideTitle - +regular("META-INF/kotlin/script/templates/\ndev.limebeck.scripts.MyShinyScript.classname") + +regular("META-INF/kotlin/script/templates/\ndev.limebeck.ci.gitlab.scripts.GitlabCiKtScript.classname") } - slide { //TODO: Заменить скрин на MyShinyScript + slide { +ideTitle +img("IDE_scriptDefPath.png") { stretch = true } } - slide { //TODO Заменить скрин на MyShinyScript + slide { +ideTitle +img("IDE.png") { stretch = true @@ -914,7 +1032,39 @@ slides { } slide { +ideTitle - +smallTitle { "Работает только в Intellij IDEA" } + +img("IDE_closeup.png") { + stretch = true + } + } + slide { + +ideTitle + +unorderedListOf( + "Работает только в IntelliJ IDEA / Fleet", + "Нужен проект Gradle/Maven для работы", + fragmented = false + ) + } + } + + //JSR223 + verticalSlide { + slide { + +smallTitle { "Java Scripting API" } + +smallTitle { "(JSR223)" } + } + slide { + +smallTitle { "Абстракция в JVM для исполнения скриптов" } + } +// slide { +// +smallTitle { "Kotlin Script > JSR223" } +// +unorderedListOf( +// "Интеграция с IDE", +// fragmented = false +// ) +// } + slide { + +smallTitle { "Kotlin Script + JSR223" } + +regular { "Обертка поверх BasicJvmScriptingHost" } } } @@ -929,36 +1079,44 @@ slides { "Ограничение по модулям JVM", "Ограничение по доступным классам" ) - //Безопасности нет - раскрыть } } verticalSlide { - val minusesTitle = smallTitle { "Минусы" } - slide { - +minusesTitle - } slide { - +minusesTitle + +smallTitle { "Минусы встраивания" } +unorderedListOf( "Компилятор Kotlin в приложении", - "Слабая поддержка в IDE", + "Поддержка IDE - Jetbrains only", "Мало документации", "Только на JVM", "Долгий старт", - "Общая сырость, баги", - "Проблемы с применением плагинов компилятора" ) - +note { - """ - Привести примеры - не работает подсветка c @import - Проблемы с необходимостью проекта gradle для подсветки - """.trimIndent() - } + } + slide { + +smallTitle { "Плюсы встраивания" } + +unorderedListOf( + "Нативно для Kotlin", + "Расширяемость", + "Поддержка собственных DSL", + "Нет альтернатив" + ) } } - //Выводы +// slide { +// +smallTitle { "Компиляция скриптов с исходниками" } +// } + + slide { + +smallTitle { "Итого по Kotlin Script" } + +unorderedListOf( + "Зрелое решение (>6 лет)", + "Развивается", + "Лучше всего - со своим DSL", + "Упрощает поддержку скриптов", + ) + } slide { +title { "Ссылка на презентацию и полезные штуки" }