Skip to content
This repository has been archived by the owner on Jun 22, 2024. It is now read-only.

Commit

Permalink
chore: Add examples to subprojects
Browse files Browse the repository at this point in the history
  • Loading branch information
sya-ri committed Nov 10, 2023
1 parent 527622f commit 3bb254e
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 33 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build
on: [push]
jobs:
test:
build:
strategy:
matrix:
os:
Expand All @@ -21,10 +21,10 @@ jobs:
with:
java-version: ${{ matrix.java-version }}
distribution: 'adopt'
- name: Run tests
run: ./gradlew check
- name: Build
run: ./gradlew build
dokka:
needs: [test]
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Clone Repository (master)
Expand Down
15 changes: 10 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ plugins {
signing
}

group = "dev.s7a"
version = "1.1.0-SNAPSHOT"
allprojects {
apply(plugin = "org.jmailen.kotlinter")

repositories {
mavenCentral()
group = "dev.s7a"
version = "1.1.0-SNAPSHOT"

repositories {
mavenCentral()
}
}

kotlin {
Expand Down Expand Up @@ -62,6 +66,7 @@ kotlin {
sourceSets {
commonMain {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
implementation("io.ktor:ktor-client-core:2.3.6")
implementation("io.ktor:ktor-client-content-negotiation:2.3.6")
implementation("io.ktor:ktor-serialization-kotlinx-json:2.3.6")
Expand All @@ -71,7 +76,7 @@ kotlin {
dependencies {
implementation(kotlin("test"))
implementation("io.ktor:ktor-client-mock:2.3.6")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")
}
}
}
Expand Down
17 changes: 16 additions & 1 deletion examples/e2e/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

apply(plugin = "kotlin")

plugins {
kotlin("jvm") version "1.9.20"
id("com.github.johnrengelman.shadow") version "7.1.2"
application
}
Expand All @@ -16,6 +19,18 @@ dependencies {
implementation("io.ktor:ktor-client-cio:2.3.6")
}

tasks.withType(KotlinJvmCompile::class.java).configureEach {
kotlinOptions.apply {
jvmTarget = "1.8"
}
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}

application {
mainClass.set("dev.s7a.example.gofile.Main")
}
24 changes: 16 additions & 8 deletions examples/jvm/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

apply(plugin = "kotlin")

plugins {
kotlin("jvm") version "1.9.20"
id("com.github.johnrengelman.shadow") version "7.1.2"
application
}

version = "1.1.0-SNAPSHOT"
dependencies {
implementation(project(":"))
implementation("io.ktor:ktor-client-cio:2.3.6")
}

repositories {
mavenCentral()
mavenLocal()
tasks.withType(KotlinJvmCompile::class.java).configureEach {
kotlinOptions.apply {
jvmTarget = "1.8"
}
}

dependencies {
implementation("dev.s7a:gofile:1.1.0-SNAPSHOT")
implementation("io.ktor:ktor-client-cio:2.3.6")
java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}

application {
Expand Down
16 changes: 10 additions & 6 deletions examples/jvm/src/main/kotlin/dev/s7a/example/gofile/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ suspend fun main() {
onFailure = {
it.printStackTrace()
exitProcess(ExitCode.UploadFailed)
}
},
)
}

private object ExitCode {
const val NoInputPath = 1
const val NoSuchFile = 2
const val IsNotFile = 3
const val UploadFailed = 4
private enum class ExitCode {
NoInputPath,
NoSuchFile,
IsNotFile,
UploadFailed,
}

private fun exitProcess(exitCode: ExitCode): Nothing {
exitProcess(exitCode.ordinal + 1)
}

private fun inputFile(): File {
Expand Down
19 changes: 11 additions & 8 deletions examples/native/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ plugins {
kotlin("multiplatform") version "1.9.20"
}

version = "1.1.0-SNAPSHOT"

repositories {
mavenCentral()
mavenLocal()
}

kotlin {
macosX64 {
binaries {
Expand Down Expand Up @@ -37,10 +30,20 @@ kotlin {
sourceSets {
commonMain {
dependencies {
implementation("dev.s7a:gofile:1.1.0-SNAPSHOT")
implementation(project(":"))
implementation("com.squareup.okio:okio:3.2.0")
}
}
macosMain {
dependencies {
implementation("io.ktor:ktor-client-cio:2.3.6")
}
}
linuxMain {
dependencies {
implementation("io.ktor:ktor-client-cio:2.3.6")
}
}
mingwMain {
dependencies {
implementation("io.ktor:ktor-client-winhttp:2.3.6")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fun main() {
onFailure = {
it.printStackTrace()
exitProcess(ExitCode.UploadFailed)
}
},
)
}
}
Expand Down
6 changes: 6 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
rootProject.name = "gofile"

include(
":examples:e2e",
":examples:jvm",
":examples:native",
)

0 comments on commit 3bb254e

Please sign in to comment.