Skip to content

Commit 8f2d838

Browse files
committed
chore: build tool and data proj changes
1 parent 9be9392 commit 8f2d838

File tree

7 files changed

+98
-20
lines changed

7 files changed

+98
-20
lines changed

backend/data/build.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ kotlin.sourceSets {
77
commonMain { dependencies { implementation(projects.shared) } }
88

99
jvmMain {
10-
dependencies {}
10+
dependencies {
11+
implementation(libs.pty4j.get().toString()) {
12+
exclude(group = "org.jetbrains.pty4j", module = "purejavacomm")
13+
}
14+
implementation(fileTree("lib") { include("*.jar") })
15+
}
1116

1217
kotlin.srcDir("src/main/kotlin")
1318
resources.srcDir("src/main/resources")
138 KB
Binary file not shown.

backend/data/src/main/kotlin/Main.kt

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package dev.suresh
2+
3+
import com.ionspin.kotlin.bignum.integer.BigInteger
4+
import com.pty4j.PtyProcessBuilder
5+
import java.util.concurrent.CountDownLatch
6+
7+
fun main() {
8+
println("Hello Kotlin Data! ${Greeting().greeting()}")
9+
10+
val b1 = BigInteger.parseString("12345678901234567890", 10)
11+
val b2 = BigInteger.parseString("323456789012345678901", 10)
12+
val s = b1 + b2
13+
14+
println(b1.bitLength())
15+
println(b2.bitLength())
16+
println(s)
17+
println(s.bitLength())
18+
ssh()
19+
}
20+
21+
fun ssh() {
22+
val ptyProcess =
23+
PtyProcessBuilder().run {
24+
setCommand(arrayOf("/bin/sh", "-l"))
25+
setEnvironment(mapOf("TERM" to "xterm-256color"))
26+
setDirectory(System.getProperty("user.home"))
27+
start()
28+
}
29+
30+
println("PTY child process started ${ptyProcess.pid()}, size: ${ptyProcess.winSize}")
31+
println(ptyProcess.isConsoleMode)
32+
println(ptyProcess.isAlive)
33+
val tos = ptyProcess.outputStream
34+
val tis = ptyProcess.inputReader()
35+
36+
val size = 10
37+
val latch = CountDownLatch(size)
38+
39+
Thread.ofVirtual().start {
40+
runCatching {
41+
for (i in 1..size) {
42+
tos.write("echo $i".encodeToByteArray())
43+
tos.write(byteArrayOf(ptyProcess.enterKeyCode))
44+
tos.flush()
45+
Thread.sleep(100)
46+
latch.countDown()
47+
}
48+
}
49+
}
50+
51+
Thread.ofVirtual().start { runCatching { tis.forEachLine { println(it) } } }
52+
53+
latch.await()
54+
tos.close()
55+
tis.close()
56+
57+
// wait until the PTY child process is terminated
58+
val result = ptyProcess.waitFor()
59+
println("PTY child process terminated with exit code $result")
60+
ptyProcess.destroyForcibly()
61+
}

gradle/.githooks/pre-commit

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
# Auto format Kotlin files in the staging area
3+
CHANGED_KT_FILES="$(git --no-pager diff --name-only --cached --diff-filter=ACMRTUXB --relative | grep '\.kt[s"]\?$')"
4+
if [ -z "${CHANGED_KT_FILES}" ]; then
5+
echo "No Kotlin staged files."
6+
else
7+
echo "There area some changed files. Running spotless..."
8+
./gradlew :spotlessApply
9+
echo "Adding files to Git."
10+
echo "${CHANGED_KT_FILES}" | while read -r file; do
11+
if [ -f "$file" ]; then
12+
git add "$file"
13+
fi
14+
done
15+
fi

gradle/build-logic/src/main/kotlin/plugins/misc.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ moduleGraphConfig {
6161
}
6262

6363
tasks {
64+
65+
// Set up git hooks
66+
register<Copy>("setUpGitHooks") {
67+
group = "help"
68+
from("$rootDir/gradle/.githooks")
69+
into("$rootDir/.git/hooks")
70+
}
71+
6472
// Dependency version updates
6573
dependencyUpdates {
6674
checkConstraints = true

gradle/libs.versions.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ kotlinx-coroutines = "1.8.0-RC2"
2828
kotlinx-datetime = "0.5.0"
2929
kotlinx-serialization = "1.6.2"
3030
kotlinx-collections-immutable = "0.3.7"
31-
kotlinx-lincheck = "2.23"
31+
kotlinx-lincheck = "2.24"
3232
kotlinx-html = "0.11.0"
3333
kotlinx-benchmark = "0.4.10"
3434
kotlinx-metadata = "0.9.0"
3535
kotlinx-reflect-lite = "1.1.0"
3636
kotlinx-bincompat = "0.14.0"
37-
kotlin-wrappers = "1.0.0-pre.693"
37+
kotlin-wrappers = "1.0.0-pre.694"
3838
kotlin-redacted = "1.8.0-alpha01"
3939
kotlinx-multik = "0.2.2"
4040
kotlinx-dataframe = "0.12.1"
@@ -56,6 +56,8 @@ intellij-markdown = "0.6.1"
5656
jgit = "6.5.0.202303070854-r"
5757
jte = "3.1.9"
5858
jimfs = "1.3.0"
59+
sshj = "0.38.0"
60+
pty4j = "0.12.25"
5961
junit = "5.10.2"
6062
koin = "3.4.1"
6163
kotest = "5.7.1"
@@ -154,8 +156,8 @@ exposed-plugin = "0.2.1"
154156
jib-plugin = "3.4.0"
155157
jib-nativeimage-extn = "0.1.0"
156158
includegit-plugin = "0.1.6"
157-
jetbrains-compose = "1.6.0-beta01"
158-
jetbrains-compose-compiler = "1.5.7.1"
159+
jetbrains-compose = "1.6.0-beta02"
160+
jetbrains-compose-compiler = "1.5.8"
159161
kobweb = "0.15.2"
160162

161163
[libraries]
@@ -278,6 +280,8 @@ ktor-client-tests = { module = "io.ktor:ktor-client-tests"
278280
airlift-aircompressor = { module = "io.airlift:aircompressor" , version.ref = "airlift-aircompressor"}
279281
airlift-security = { module = "io.airlift:security" , version.ref = "airlift-security"}
280282
airlift-security-jwks = { module = "io.airlift:security-jwks" , version.ref = "airlift-security"}
283+
pty4j = { module = "org.jetbrains.pty4j:pty4j" , version.ref = "pty4j"}
284+
sshj = { module = "com.hierynomus:sshj" , version.ref = "sshj"}
281285

282286
arrow-suspendapp = { module = "io.arrow-kt:suspendapp" , version.ref = "arrow-suspendapp" }
283287
arrow-suspendapp-ktor = { module = "io.arrow-kt:suspendapp-ktor" , version.ref = "arrow-suspendapp" }

0 commit comments

Comments
 (0)