mirror of
https://github.com/GayPizzaSpecifications/dough.git
synced 2025-08-02 21:20:55 +00:00
Pizza Samples
This commit is contained in:
parent
d9b02c847f
commit
36e680454e
36
buildSrc/src/main/kotlin/dough_base.gradle.kts
Normal file
36
buildSrc/src/main/kotlin/dough_base.gradle.kts
Normal 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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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")
|
||||
}
|
||||
|
25
buildSrc/src/main/kotlin/dough_publishing.gradle.kts
Normal file
25
buildSrc/src/main/kotlin/dough_publishing.gradle.kts
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
3
buildSrc/src/main/kotlin/dough_sample.gradle.kts
Normal file
3
buildSrc/src/main/kotlin/dough_sample.gradle.kts
Normal file
@ -0,0 +1,3 @@
|
||||
plugins {
|
||||
id("dough_base")
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
package gay.pizza.dough.fs
|
||||
|
||||
object DefaultFsPathSerializer : FsPathSerializer({ FsPath(it) })
|
||||
object DefaultFsPathSerializer : FsPathSerializer(PlatformFsProvider)
|
||||
|
@ -0,0 +1,5 @@
|
||||
package gay.pizza.dough.fs
|
||||
|
||||
interface FsPathResolver {
|
||||
fun resolve(path: String): FsPath
|
||||
}
|
@ -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) {
|
||||
|
@ -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
|
||||
}
|
||||
|
20
samples/current-time/build.gradle.kts
Normal file
20
samples/current-time/build.gradle.kts
Normal file
@ -0,0 +1,20 @@
|
||||
plugins {
|
||||
dough_sample
|
||||
}
|
||||
|
||||
kotlin {
|
||||
js(IR) {
|
||||
nodejs()
|
||||
browser()
|
||||
|
||||
binaries.executable()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation(project(":dough-core"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
5
samples/current-time/src/commonMain/kotlin/main.kt
Normal file
5
samples/current-time/src/commonMain/kotlin/main.kt
Normal file
@ -0,0 +1,5 @@
|
||||
import gay.pizza.dough.core.PlatformClock
|
||||
|
||||
fun main() {
|
||||
println(PlatformClock.now().millisecondsSinceEpoch)
|
||||
}
|
13
samples/fs-walk/build.gradle.kts
Normal file
13
samples/fs-walk/build.gradle.kts
Normal file
@ -0,0 +1,13 @@
|
||||
plugins {
|
||||
dough_sample
|
||||
}
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation(project(":dough-fs"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
10
samples/fs-walk/src/commonMain/kotlin/main.kt
Normal file
10
samples/fs-walk/src/commonMain/kotlin/main.kt
Normal 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)
|
||||
}
|
||||
}
|
@ -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, ":"))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user