Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce0203 committed Aug 6, 2023
1 parent 070684d commit 31f85ad
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 11

- run: git tag ${{github.run_number}}
- name:
run: |
type nul > Prop.java
echo "import java.io.File;import java.io.FileInputStream;import java.util.Arrays;import java.util.Iterator;import java.util.Properties;public class Prop {public static void main(String[] args) throws Exception {Iterator<String> iterator = Arrays.stream(args).iterator();if (!iterator.hasNext()) return;String fileName = iterator.next();File file = new File(fileName);Properties props = new Properties();props.load(new FileInputStream(file));while (true) {if (!iterator.hasNext()) return;String key = iterator.next();if (!iterator.hasNext()) return;String value = iterator.next();props.setProperty(key, value);}}}" > Prop.java
java Prop.java gradle.properties server ${{ env.url }}
java Prop.java gradle.properties version v0.0.${{github.run_number}}
- run: git tag ${{github.run_numb er}}

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand Down
1 change: 0 additions & 1 deletion client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ korge {
id = "com.sample.clientserver"
targetJvm()
targetJs()
targetDesktop()
targetDesktopCross()
}

Expand Down
30 changes: 30 additions & 0 deletions client/src/mingwX64Main/kotlin/main.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import io.ktor.client.engine.winhttp.*
import korlibs.io.file.std.resourcesVfs
import korlibs.io.lang.readProperties
import network.ClientEngineFactory
import network.URLProvider
import org.koin.core.context.startKoin
import org.koin.core.qualifier.named
import org.koin.dsl.bind
import org.koin.dsl.module
import org.koin.mp.KoinPlatform

class Main
suspend fun main() {
val clientProps = resourcesVfs["client.properties"].readProperties()
val url = clientProps["server"]!!
val version = clientProps["version"]!!
startKoin {}
KoinPlatform.getKoin().loadModules(listOf(module {
single(named("version")) { version }
factory {
object : URLProvider {
override val url: String get() = url
}
} bind URLProvider::class
factory {
object : ClientEngineFactory { override fun getEngine() = WinHttp }
} bind ClientEngineFactory::class
}))
start()
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ ktor-server-netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor"
ktor-server-websockets = { module = "io.ktor:ktor-server-websockets", version.ref = "ktor" }
ktor-client-websockets = { module = "io.ktor:ktor-client-websockets", version.ref = "ktor" }
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" }
ktor-client-winhttp = { module = "io.ktor:ktor-client-winhttp", version.ref = "ktor" }
ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
ktor-server-cors = { module = "io.ktor:ktor-server-cors", version.ref = "ktor" }
ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor" }
Expand Down
8 changes: 7 additions & 1 deletion shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins { kotlin("multiplatform") }
korge {
targetJvm()
targetJs()
targetDesktop()
targetDesktopCross()
}

kotlin {
Expand All @@ -34,5 +34,11 @@ kotlin {
api(libs.logback)
}
}
val mingwX64Main by getting {
dependencies {
api(libs.ktor.client.winhttp)
api(libs.logback)
}
}
}
}

0 comments on commit 31f85ad

Please sign in to comment.