Skip to content

Commit cf6a9cb

Browse files
committed
kotlinx.serialization org.json format
1 parent 57ea374 commit cf6a9cb

File tree

12 files changed

+503
-4
lines changed

12 files changed

+503
-4
lines changed

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
plugins {
2+
id("com.android.library") apply false
23
kotlin("jvm") apply false
34
}

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
android.useAndroidX=true
12
kotlin.code.style=official
23
org.gradle.jvmargs=-Xmx512m -XX:+UseParallelGC
34

5+
androidBuildToolsVersion=7.1.3
46
kotlinVersion=1.6.10

gradle/libs.versions.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
[versions]
22
autoService = "1.0.1"
3+
junit4 = "4.13.2"
34
junit-jupiter = "5.8.2"
45
kotlin = "1.6.10"
5-
kotlinpoet = "1.10.2"
6+
kotlinpoet = "1.11.0"
67
kotlinx-serialization = "1.3.2"
78
ksp = "1.6.10-1.0.4"
9+
org-json = "20220320"
10+
robolectric = "4.8.1"
811

912
[plugins]
1013
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
1114

1215
[libraries]
1316
auto-service = { module = "com.google.auto.service:auto-service", version.ref = "autoService" }
1417
auto-service-annotations = { module = "com.google.auto.service:auto-service-annotations", version.ref = "autoService" }
18+
junit4 = { module = "junit:junit", version.ref = "junit4" }
1519
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }
1620
kotlinpoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlinpoet" }
1721
kotlinx-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" }
1822
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
1923
ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }
24+
org-json = { module = "org.json:json", version.ref = "org-json" }
25+
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

json-java/build.gradle.kts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
plugins {
2+
id("com.android.library")
3+
kotlin("multiplatform")
4+
kotlin("plugin.serialization")
5+
}
6+
7+
android {
8+
compileSdk = 31
9+
defaultConfig {
10+
minSdk = 14
11+
}
12+
testOptions.unitTests.isIncludeAndroidResources = true
13+
}
14+
15+
kotlin {
16+
jvm()
17+
android()
18+
19+
sourceSets {
20+
getByName("commonMain") {
21+
dependencies {
22+
implementation(libs.kotlinx.serialization)
23+
}
24+
}
25+
26+
getByName("commonTest") {
27+
dependencies {
28+
implementation(kotlin("test"))
29+
}
30+
}
31+
32+
getByName("jvmMain") {
33+
kotlin.srcDir("src/commonJvmMain/kotlin")
34+
dependencies {
35+
implementation(libs.org.json)
36+
}
37+
}
38+
39+
getByName("androidMain") {
40+
kotlin.srcDir("src/commonJvmMain/kotlin")
41+
}
42+
43+
getByName("jvmTest") {
44+
kotlin.srcDir("src/commonJvmTest/kotlin")
45+
dependencies {
46+
implementation(kotlin("test-junit5"))
47+
implementation(libs.junit.jupiter)
48+
}
49+
}
50+
51+
getByName("androidTest") {
52+
kotlin.srcDir("src/commonJvmTest/kotlin")
53+
dependencies {
54+
implementation(kotlin("test-junit"))
55+
implementation(libs.junit4)
56+
implementation(libs.robolectric)
57+
}
58+
}
59+
}
60+
61+
targets.all {
62+
compilations.all {
63+
kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
64+
}
65+
}
66+
}
67+
68+
tasks.named<Test>("jvmTest") {
69+
useJUnitPlatform()
70+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.github.ephemient.kotlinx.serialization.contrib.jsonjava
2+
3+
import org.junit.runner.RunWith
4+
import org.robolectric.RobolectricTestRunner
5+
6+
typealias AndroidRunWith = RunWith
7+
typealias AndroidRobolectricTestRunner = RobolectricTestRunner
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minSdk=14
2+
maxSdk=31

0 commit comments

Comments
 (0)