Pizza Samples

This commit is contained in:
Alex Zenla 2023-02-17 10:15:42 -08:00
parent d9b02c847f
commit 36e680454e
Signed by: alex
GPG Key ID: C0780728420EBFE5
13 changed files with 139 additions and 64 deletions

View File

@ -0,0 +1,36 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
`java-base`
kotlin("multiplatform")
kotlin("plugin.serialization")
}
repositories {
mavenCentral()
}
java {
val javaVersion = JavaVersion.toVersion(17)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "17"
}
kotlin {
jvm()
sourceSets {
commonMain {
dependencies {
api("org.jetbrains.kotlin:kotlin-bom")
api("org.jetbrains.kotlin:kotlin-stdlib")
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
}
}
}
}

View File

@ -1,56 +1,4 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
`maven-publish`
kotlin("multiplatform")
kotlin("plugin.serialization")
}
repositories {
mavenCentral()
}
kotlin {
jvm()
sourceSets {
commonMain {
dependencies {
api("org.jetbrains.kotlin:kotlin-bom")
api("org.jetbrains.kotlin:kotlin-stdlib")
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
}
}
}
}
java {
val javaVersion = JavaVersion.toVersion(17)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "17"
}
publishing {
repositories {
mavenLocal()
var githubPackagesToken = System.getenv("GITHUB_TOKEN")
if (githubPackagesToken == null) {
githubPackagesToken = project.findProperty("github.token") as String?
}
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/gaypizzaspecifications/dough")
credentials {
username = project.findProperty("github.username") as String? ?: "gaypizzaspecifications"
password = githubPackagesToken
}
}
}
id("dough_base")
id("dough_publishing")
}

View File

@ -0,0 +1,25 @@
plugins {
id("dough_base")
`maven-publish`
}
publishing {
repositories {
mavenLocal()
var githubPackagesToken = System.getenv("GITHUB_TOKEN")
if (githubPackagesToken == null) {
githubPackagesToken = project.findProperty("github.token") as String?
}
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/gaypizzaspecifications/dough")
credentials {
username = project.findProperty("github.username") as String? ?: "gaypizzaspecifications"
password = githubPackagesToken
}
}
}
}

View File

@ -0,0 +1,3 @@
plugins {
id("dough_base")
}

View File

@ -1,3 +1,3 @@
package gay.pizza.dough.fs
object DefaultFsPathSerializer : FsPathSerializer({ FsPath(it) })
object DefaultFsPathSerializer : FsPathSerializer(PlatformFsProvider)

View File

@ -0,0 +1,5 @@
package gay.pizza.dough.fs
interface FsPathResolver {
fun resolve(path: String): FsPath
}

View File

@ -6,11 +6,11 @@ import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
open class FsPathSerializer(val construct: (String) -> FsPath) : KSerializer<FsPath> {
open class FsPathSerializer(val resolver: FsPathResolver) : KSerializer<FsPath> {
override val descriptor: SerialDescriptor = String.serializer().descriptor
override fun deserialize(decoder: Decoder): FsPath {
return construct(decoder.decodeString())
return resolver.resolve(decoder.decodeString())
}
override fun serialize(encoder: Encoder, value: FsPath) {

View File

@ -1,8 +1,6 @@
package gay.pizza.dough.fs
interface FsProvider {
interface FsProvider : FsPathResolver {
val currentWorkingDirectory: FsPath
val operations: FsOperations
fun resolve(path: String): FsPath
}

View File

@ -0,0 +1,20 @@
plugins {
dough_sample
}
kotlin {
js(IR) {
nodejs()
browser()
binaries.executable()
}
sourceSets {
commonMain {
dependencies {
implementation(project(":dough-core"))
}
}
}
}

View File

@ -0,0 +1,5 @@
import gay.pizza.dough.core.PlatformClock
fun main() {
println(PlatformClock.now().millisecondsSinceEpoch)
}

View File

@ -0,0 +1,13 @@
plugins {
dough_sample
}
kotlin {
sourceSets {
commonMain {
dependencies {
implementation(project(":dough-fs"))
}
}
}
}

View File

@ -0,0 +1,10 @@
import gay.pizza.dough.fs.PlatformFsProvider
import gay.pizza.dough.fs.walk
fun main() {
val currentWorkingDirectory = PlatformFsProvider.currentWorkingDirectory
for (item in currentWorkingDirectory.walk()) {
val relative = item.relativeTo(currentWorkingDirectory)
println(relative.fullPathString)
}
}

View File

@ -1,6 +1,18 @@
rootProject.name = "dough"
include(
"dough-core",
"dough-fs"
)
val topLevelModules = rootProject.projectDir.listFiles { item: File ->
item.name.startsWith("dough-") &&
item.isDirectory &&
item.resolve("build.gradle.kts").exists()
}?.toList() ?: emptyList()
val samples = rootProject.projectDir.resolve("samples").listFiles { item: File ->
item.isDirectory &&
item.resolve("build.gradle.kts").exists()
}?.toList() ?: emptyList()
(topLevelModules + samples).map { file ->
file.relativeTo(rootProject.projectDir)
}.forEach { file ->
include(file.path.replace(File.separator, ":"))
}