From 31f85ade741af9b10a09a75a361891e0dcb27d1d Mon Sep 17 00:00:00 2001 From: Bruce0203 Date: Mon, 7 Aug 2023 02:22:46 +0900 Subject: [PATCH] init --- .github/workflows/release.yml | 9 ++++++-- client/build.gradle.kts | 1 - client/src/mingwX64Main/kotlin/main.kt | 30 ++++++++++++++++++++++++++ gradle/libs.versions.toml | 2 ++ shared/build.gradle.kts | 8 ++++++- 5 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 client/src/mingwX64Main/kotlin/main.kt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 82c929d..e42c62d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 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 diff --git a/client/build.gradle.kts b/client/build.gradle.kts index 85f000f..8459e1e 100644 --- a/client/build.gradle.kts +++ b/client/build.gradle.kts @@ -8,7 +8,6 @@ korge { id = "com.sample.clientserver" targetJvm() targetJs() - targetDesktop() targetDesktopCross() } diff --git a/client/src/mingwX64Main/kotlin/main.kt b/client/src/mingwX64Main/kotlin/main.kt new file mode 100644 index 0000000..7ad1da6 --- /dev/null +++ b/client/src/mingwX64Main/kotlin/main.kt @@ -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() +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b923bbd..83f4629 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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" } diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index cbfe0fa..b9395ac 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -8,7 +8,7 @@ plugins { kotlin("multiplatform") } korge { targetJvm() targetJs() - targetDesktop() + targetDesktopCross() } kotlin { @@ -34,5 +34,11 @@ kotlin { api(libs.logback) } } + val mingwX64Main by getting { + dependencies { + api(libs.ktor.client.winhttp) + api(libs.logback) + } + } } } \ No newline at end of file