Skip to content

Commit

Permalink
Доработки в презентации
Browse files Browse the repository at this point in the history
  • Loading branch information
LimeBeck committed Apr 14, 2024
1 parent afcd06f commit f5138bb
Show file tree
Hide file tree
Showing 23 changed files with 759 additions and 242 deletions.
1 change: 1 addition & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,26 @@ import kotlin.script.experimental.jvmhost.createJvmScriptDefinitionFromTemplate
import kotlin.script.experimental.jvmhost.jsr223.KotlinJsr223ScriptEngineImpl

class GitlabCiScriptEngineFactory : KotlinJsr223JvmScriptEngineFactoryBase() {

private val scriptDefinition = createJvmScriptDefinitionFromTemplate<GitlabCiKtScript>()
private var lastClassLoader: ClassLoader? = null
private var lastClassPath: List<File>? = null

override fun getExtensions(): List<String> =
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
Expand All @@ -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()) }
}
Binary file modified presentation/assets/IDE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added presentation/assets/IDE_closeup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified presentation/assets/IDE_scriptDefPath.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions presentation/assets/examples/ScriptWithDeps.groovy
Original file line number Diff line number Diff line change
@@ -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

9 changes: 9 additions & 0 deletions presentation/assets/examples/java/11/Prog.java
Original file line number Diff line number Diff line change
@@ -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!"); }
}
3 changes: 3 additions & 0 deletions presentation/assets/examples/java/22/Helper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Helper {
static void run() { System.out.println("Hello!"); }
}
5 changes: 5 additions & 0 deletions presentation/assets/examples/java/22/Prog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
///usr/bin/env java "$0" "$@" ; exit $?

class Prog {
public static void main(String[] args) { Helper.run(); }
}
9 changes: 9 additions & 0 deletions presentation/assets/examples/jbang/JBangEx.groovy
Original file line number Diff line number Diff line change
@@ -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"]
13 changes: 13 additions & 0 deletions presentation/assets/examples/jbang/JBangEx.java
Original file line number Diff line number Diff line change
@@ -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"));
}
}
13 changes: 13 additions & 0 deletions presentation/assets/examples/jbang/JBangEx.kt
Original file line number Diff line number Diff line change
@@ -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<Map<String, String>>(
"""{"key":"Hello, World!"}"""
)

fun main() {
println(value.get("key"))
}
12 changes: 12 additions & 0 deletions presentation/assets/examples/kscript.kts
Original file line number Diff line number Diff line change
@@ -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<Map<String, String>>(
"""{"key":"Hello, World!"}"""
)

println(value["key"])
101 changes: 101 additions & 0 deletions presentation/assets/microkernel-arch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed presentation/assets/plugin-arch.png
Binary file not shown.
Loading

0 comments on commit f5138bb

Please sign in to comment.