Skip to content

Commit 866b9a5

Browse files
committed
init project, and commit initial skeleton
polymorphism, lists, maps aren't working.
0 parents  commit 866b9a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2424
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 2
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.gitattributes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
* text eol=lf
2+
3+
*.java text diff=java
4+
*.kt text diff=java
5+
*.kts text diff=java
6+
7+
# These are explicitly windows files and should use crlf
8+
*.bat text eol=crlf

.gitignore

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
2+
3+
### Gradle ###
4+
build/
5+
.gradle/
6+
.gradletasknamecache
7+
gradle-app.setting
8+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
9+
!gradle-wrapper.jar
10+
11+
### Linux ###
12+
*~
13+
14+
# temporary files which can be created if a process still has a handle open of a deleted file
15+
.fuse_hidden*
16+
17+
# KDE directory preferences
18+
.directory
19+
20+
# Linux trash folder which might appear on any partition or disk
21+
.Trash-*
22+
23+
# .nfs files are created when an open file is removed but is still being accessed
24+
.nfs*
25+
26+
### macOS ###
27+
# General
28+
.DS_Store
29+
.AppleDouble
30+
.LSOverride
31+
32+
# Icon must end with two \r
33+
Icon
34+
35+
# Thumbnails
36+
._*
37+
38+
# Files that might appear in the root of a volume
39+
.DocumentRevisions-V100
40+
.fseventsd
41+
.Spotlight-V100
42+
.TemporaryItems
43+
.Trashes
44+
.VolumeIcon.icns
45+
.com.apple.timemachine.donotpresent
46+
47+
# Directories potentially created on remote AFP share
48+
.AppleDB
49+
.AppleDesktop
50+
Network Trash Folder
51+
Temporary Items
52+
.apdisk
53+
54+
### Windows ###
55+
# Windows thumbnail cache files
56+
Thumbs.db
57+
Thumbs.db:encryptable
58+
ehthumbs.db
59+
ehthumbs_vista.db
60+
61+
# Dump file
62+
*.stackdump
63+
64+
# Folder config file
65+
[Dd]esktop.ini
66+
67+
# Recycle Bin used on file shares
68+
$RECYCLE.BIN/
69+
70+
# Windows Installer files
71+
*.cab
72+
*.msi
73+
*.msix
74+
*.msm
75+
*.msp
76+
77+
# Windows shortcuts
78+
*.lnk
79+
80+
### STS ###
81+
.apt_generated
82+
.classpath
83+
.factorypath
84+
.project
85+
.settings
86+
.springBeans
87+
.sts4-cache
88+
89+
### IntelliJ IDEA ###
90+
.idea/
91+
*.iws
92+
*.iml
93+
*.ipr
94+
out/
95+
!**/src/main/**/out/
96+
!**/src/test/**/out/
97+
98+
### NetBeans ###
99+
/nbproject/private/
100+
/nbbuild/
101+
/dist/
102+
/nbdist/
103+
/.nb-gradle/
104+
105+
### VS Code ###
106+
.vscode/

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Kotlinx Serialization TypeScript Generator
2+
3+
Create TypeScript interfaces from Kotlin classes
4+
5+
```kotlin
6+
@Serializable
7+
data class PlayerDetails(
8+
val name: String,
9+
val health: Float,
10+
)
11+
12+
println(
13+
KxsTsGenerator().generate(Color.serializer().descriptor)
14+
)
15+
```
16+
17+
```typescript
18+
interface PlayerDetails {
19+
name: string;
20+
health: number;
21+
}
22+
```
23+
24+
See [the docs](./docs) for working examples.

build.gradle.kts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import buildsrc.config.excludeGeneratedGradleDsl
2+
3+
plugins {
4+
base
5+
id("me.qoomon.git-versioning") version "5.1.2"
6+
idea
7+
buildsrc.convention.`kotlin-jvm`
8+
kotlin("plugin.serialization")
9+
id("org.jetbrains.kotlinx.knit")
10+
}
11+
12+
13+
project.group = "dev.adamko"
14+
project.version = "0.0.0-SNAPSHOT"
15+
gitVersioning.apply {
16+
refs {
17+
branch(".+") { version = "\${ref}-SNAPSHOT" }
18+
tag("v(?<version>.*)") { version = "\${ref.version}" }
19+
}
20+
21+
// optional fallback configuration in case of no matching ref configuration
22+
rev { version = "\${commit}" }
23+
}
24+
25+
26+
tasks.wrapper {
27+
gradleVersion = "7.4"
28+
distributionType = Wrapper.DistributionType.ALL
29+
}
30+
31+
idea {
32+
module {
33+
isDownloadSources = true
34+
isDownloadJavadoc = true
35+
excludeGeneratedGradleDsl(layout)
36+
excludeDirs = excludeDirs + layout.files(
37+
".idea",
38+
"gradle/kotlin-js-store",
39+
"gradle/wrapper",
40+
)
41+
}
42+
}
43+
44+
45+
val kotlinxSerializationVersion = "1.3.2"
46+
47+
dependencies {
48+
implementation(projects.modules.kxsTsGenCore)
49+
50+
implementation(platform("org.jetbrains.kotlinx:kotlinx-serialization-bom:${kotlinxSerializationVersion}"))
51+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core")
52+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json")
53+
54+
testImplementation(kotlin("test"))
55+
56+
testImplementation("org.jetbrains.kotlinx:kotlinx-knit-test:0.3.0")
57+
}
58+
59+
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
60+
kotlinOptions.freeCompilerArgs += listOf(
61+
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
62+
)
63+
}
64+
65+
sourceSets.test {
66+
java.srcDirs("docs/example", "docs/test")
67+
}
68+
69+
//knit {
70+
// rootDir = layout.projectDirectory.asFile
71+
// files = rootProject.fileTree("docs")
72+
//}
73+
74+
tasks.test {
75+
dependsOn(tasks.knit)
76+
}
77+
78+
tasks.compileKotlin { mustRunAfter(tasks.knit) }

buildSrc/build.gradle.kts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
3+
plugins {
4+
idea
5+
`kotlin-dsl`
6+
kotlin("jvm") version "1.6.10"
7+
`project-report`
8+
}
9+
10+
11+
object Versions {
12+
const val jvmTarget = "11"
13+
const val kotlinTarget = "1.6"
14+
const val kotlin = "1.6.10"
15+
const val ksp = "1.6.10-1.0.2"
16+
const val kotlinxSerializationVersion = "1.3.2"
17+
const val kotlinxKnit = "0.3.0"
18+
19+
const val kotest = "5.1.0"
20+
}
21+
22+
23+
dependencies {
24+
implementation(enforcedPlatform("org.jetbrains.kotlin:kotlin-bom:${Versions.kotlin}"))
25+
implementation("org.jetbrains.kotlin:kotlin-serialization")
26+
implementation("org.jetbrains.kotlin:kotlin-reflect")
27+
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}")
28+
29+
implementation("com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:${Versions.ksp}")
30+
31+
implementation(platform("org.jetbrains.kotlinx:kotlinx-serialization-bom:${Versions.kotlinxSerializationVersion}"))
32+
33+
implementation("io.kotest:kotest-framework-multiplatform-plugin-gradle:${Versions.kotest}")
34+
35+
implementation("org.jetbrains.kotlinx:kotlinx-knit:${Versions.kotlinxKnit}")
36+
}
37+
38+
39+
tasks.withType<KotlinCompile>().configureEach {
40+
41+
kotlinOptions {
42+
jvmTarget = Versions.jvmTarget
43+
apiVersion = Versions.kotlinTarget
44+
languageVersion = Versions.kotlinTarget
45+
}
46+
47+
kotlinOptions.freeCompilerArgs += listOf(
48+
"-opt-in=kotlin.RequiresOptIn",
49+
"-opt-in=kotlin.ExperimentalStdlibApi",
50+
"-opt-in=kotlin.time.ExperimentalTime",
51+
)
52+
}
53+
54+
kotlin {
55+
jvmToolchain {
56+
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(Versions.jvmTarget))
57+
}
58+
59+
kotlinDslPluginOptions {
60+
jvmTarget.set(Versions.jvmTarget)
61+
}
62+
}
63+
64+
idea {
65+
module {
66+
isDownloadSources = true
67+
isDownloadJavadoc = true
68+
}
69+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@Suppress("UnstableApiUsage") // centralised repository definitions are incubating
2+
dependencyResolutionManagement {
3+
4+
repositories {
5+
mavenCentral()
6+
jitpack()
7+
gradlePluginPortal()
8+
}
9+
10+
pluginManagement {
11+
repositories {
12+
jitpack()
13+
gradlePluginPortal()
14+
mavenCentral()
15+
}
16+
}
17+
}
18+
19+
fun RepositoryHandler.jitpack() {
20+
maven("https://jitpack.io")
21+
}

buildSrc/settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
apply(from = "./repositories.settings.gradle.kts")
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package buildsrc.config
2+
3+
import org.gradle.api.file.ProjectLayout
4+
import org.gradle.plugins.ide.idea.model.IdeaModule
5+
6+
/** exclude generated Gradle code, so it doesn't clog up search results */
7+
fun IdeaModule.excludeGeneratedGradleDsl(layout: ProjectLayout) {
8+
excludeDirs.addAll(
9+
layout.files(
10+
"buildSrc/build/generated-sources/kotlin-dsl-accessors",
11+
"buildSrc/build/generated-sources/kotlin-dsl-accessors/kotlin",
12+
"buildSrc/build/generated-sources/kotlin-dsl-accessors/kotlin/gradle",
13+
"buildSrc/build/generated-sources/kotlin-dsl-external-plugin-spec-builders",
14+
"buildSrc/build/generated-sources/kotlin-dsl-external-plugin-spec-builders/kotlin",
15+
"buildSrc/build/generated-sources/kotlin-dsl-external-plugin-spec-builders/kotlin/gradle",
16+
"buildSrc/build/generated-sources/kotlin-dsl-plugins",
17+
"buildSrc/build/generated-sources/kotlin-dsl-plugins/kotlin",
18+
"buildSrc/build/generated-sources/kotlin-dsl-plugins/kotlin/dev",
19+
"buildSrc/build/pluginUnderTestMetadata",
20+
)
21+
)
22+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package buildsrc.convention
2+
3+
import org.gradle.kotlin.dsl.`jacoco-report-aggregation`
4+
import org.gradle.kotlin.dsl.base
5+
import org.gradle.kotlin.dsl.dependencies
6+
7+
plugins {
8+
base
9+
`jacoco-report-aggregation`
10+
}
11+
12+
13+
dependencies {
14+
subprojects
15+
.filter { it.buildFile.exists() }
16+
.forEach { jacocoAggregation(it) }
17+
}
18+
19+
20+
@Suppress("UnstableApiUsage") // jacoco-report-aggregation is incubating
21+
val testCodeCoverageReport by reporting.reports.creating(JacocoCoverageReport::class) {
22+
testType.set(TestSuiteType.UNIT_TEST)
23+
}
24+
25+
26+
tasks.check {
27+
dependsOn(testCodeCoverageReport.reportTask)
28+
}

0 commit comments

Comments
 (0)