mirror of
https://github.com/GayPizzaSpecifications/dough.git
synced 2025-08-03 05:30:55 +00:00
Initial Commit
This commit is contained in:
17
.github/workflows/build.yml
vendored
Normal file
17
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
name: Build
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Set up JDK 17
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: '17'
|
||||||
|
distribution: 'temurin'
|
||||||
|
- name: Build with Gradle
|
||||||
|
uses: gradle/gradle-build-action@v2
|
||||||
|
with:
|
||||||
|
arguments: build
|
22
.github/workflows/publish.yml
vendored
Normal file
22
.github/workflows/publish.yml
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
name: Publish
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Set up JDK 17
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: '17'
|
||||||
|
distribution: 'temurin'
|
||||||
|
- name: Publish with Gradle
|
||||||
|
uses: gradle/gradle-build-action@v2
|
||||||
|
with:
|
||||||
|
arguments: publishAllPublicationsToGitHubPackagesRepository
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
.gradle/
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
build/
|
||||||
|
out/
|
||||||
|
/work
|
||||||
|
/kotlin-js-store
|
||||||
|
/work
|
||||||
|
/.fleet/*
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2023 Gay Pizza Specifications
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
8
build.gradle.kts
Normal file
8
build.gradle.kts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
allprojects {
|
||||||
|
group = "gay.pizza.dough"
|
||||||
|
version = "0.1.0-SNAPSHOT"
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Wrapper> {
|
||||||
|
gradleVersion = "8.0"
|
||||||
|
}
|
12
buildSrc/build.gradle.kts
Normal file
12
buildSrc/build.gradle.kts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
plugins {
|
||||||
|
`kotlin-dsl`
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10")
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-serialization:1.8.10")
|
||||||
|
}
|
56
buildSrc/src/main/kotlin/dough_component.gradle.kts
Normal file
56
buildSrc/src/main/kotlin/dough_component.gradle.kts
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
dough-fs/build.gradle.kts
Normal file
3
dough-fs/build.gradle.kts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
plugins {
|
||||||
|
dough_component
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package gay.pizza.dough.fs
|
||||||
|
|
||||||
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
|
import kotlinx.serialization.SerializationStrategy
|
||||||
|
|
||||||
|
interface FsOperations {
|
||||||
|
fun exists(path: FsPath): Boolean
|
||||||
|
fun isDirectory(path: FsPath): Boolean
|
||||||
|
fun isRegularFile(path: FsPath): Boolean
|
||||||
|
fun isSymbolicLink(path: FsPath): Boolean
|
||||||
|
fun isReadable(path: FsPath): Boolean
|
||||||
|
fun isWritable(path: FsPath): Boolean
|
||||||
|
fun isExecutable(path: FsPath): Boolean
|
||||||
|
|
||||||
|
fun list(path: FsPath): Sequence<FsPath>
|
||||||
|
|
||||||
|
fun walk(path: FsPath): Sequence<FsPath>
|
||||||
|
fun visit(path: FsPath, visitor: FsPathVisitor)
|
||||||
|
|
||||||
|
fun readString(path: FsPath): String
|
||||||
|
fun readAllBytes(path: FsPath): ByteArray
|
||||||
|
fun readBytesChunked(path: FsPath, block: (ByteArray, Int) -> Unit)
|
||||||
|
fun <T> readJsonFile(path: FsPath, deserializer: DeserializationStrategy<T>): T
|
||||||
|
|
||||||
|
fun readLines(path: FsPath, block: (String) -> Unit)
|
||||||
|
fun readLines(path: FsPath): Sequence<String>
|
||||||
|
|
||||||
|
fun <T> readJsonLinesToList(path: FsPath, deserializer: DeserializationStrategy<T>, block: (T) -> Unit)
|
||||||
|
fun <T> readJsonLinesToList(path: FsPath, deserializer: DeserializationStrategy<T>): List<T>
|
||||||
|
|
||||||
|
fun writeString(path: FsPath, content: String)
|
||||||
|
fun writeAllBytes(path: FsPath, bytes: ByteArray)
|
||||||
|
fun <T> writeJsonFile(path: FsPath, serializer: SerializationStrategy<T>, value: T)
|
||||||
|
|
||||||
|
fun delete(path: FsPath)
|
||||||
|
fun deleteOnExit(path: FsPath)
|
||||||
|
fun deleteRecursively(path: FsPath)
|
||||||
|
|
||||||
|
fun createDirectories(path: FsPath)
|
||||||
|
}
|
19
dough-fs/src/commonMain/kotlin/gay/pizza/dough/fs/FsPath.kt
Normal file
19
dough-fs/src/commonMain/kotlin/gay/pizza/dough/fs/FsPath.kt
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package gay.pizza.dough.fs
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable(with = FsPathSerializer::class)
|
||||||
|
interface FsPath : Comparable<FsPath> {
|
||||||
|
val fullPathString: String
|
||||||
|
val entityNameString: String
|
||||||
|
|
||||||
|
val parent: FsPath?
|
||||||
|
val operations: FsOperations
|
||||||
|
|
||||||
|
fun resolve(part: String): FsPath
|
||||||
|
fun relativeTo(path: FsPath): FsPath
|
||||||
|
|
||||||
|
override fun compareTo(other: FsPath): Int {
|
||||||
|
return fullPathString.compareTo(other.fullPathString)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package gay.pizza.dough.fs
|
||||||
|
|
||||||
|
import kotlinx.serialization.KSerializer
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||||
|
import kotlinx.serialization.encoding.Decoder
|
||||||
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
|
||||||
|
object FsPathSerializer : KSerializer<FsPath> {
|
||||||
|
override val descriptor: SerialDescriptor = String.serializer().descriptor
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): FsPath {
|
||||||
|
return FsPath(decoder.decodeString())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, value: FsPath) {
|
||||||
|
encoder.encodeString(value.fullPathString)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package gay.pizza.dough.fs
|
||||||
|
|
||||||
|
interface FsPathVisitor {
|
||||||
|
fun beforeVisitDirectory(path: FsPath): VisitResult
|
||||||
|
fun visitFile(path: FsPath): VisitResult
|
||||||
|
fun visitFileFailed(path: FsPath, exception: Exception): VisitResult
|
||||||
|
fun afterVisitDirectory(path: FsPath): VisitResult
|
||||||
|
|
||||||
|
enum class VisitResult {
|
||||||
|
Continue,
|
||||||
|
Terminate,
|
||||||
|
SkipSubtree,
|
||||||
|
SkipSiblings
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
package gay.pizza.dough.fs
|
||||||
|
|
||||||
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
|
import kotlinx.serialization.SerializationStrategy
|
||||||
|
|
||||||
|
fun FsPath.exists(): Boolean =
|
||||||
|
operations.exists(this)
|
||||||
|
|
||||||
|
fun FsPath.isDirectory(): Boolean =
|
||||||
|
operations.isDirectory(this)
|
||||||
|
|
||||||
|
fun FsPath.isRegularFile(): Boolean =
|
||||||
|
operations.isRegularFile(this)
|
||||||
|
|
||||||
|
fun FsPath.isSymbolicLink(): Boolean =
|
||||||
|
operations.isSymbolicLink(this)
|
||||||
|
|
||||||
|
fun FsPath.isReadable(): Boolean =
|
||||||
|
operations.isReadable(this)
|
||||||
|
|
||||||
|
fun FsPath.isWritable(): Boolean =
|
||||||
|
operations.isWritable(this)
|
||||||
|
|
||||||
|
fun FsPath.isExecutable(): Boolean =
|
||||||
|
operations.isExecutable(this)
|
||||||
|
|
||||||
|
fun FsPath.list(): Sequence<FsPath> =
|
||||||
|
operations.list(this)
|
||||||
|
|
||||||
|
fun FsPath.walk(): Sequence<FsPath> =
|
||||||
|
operations.walk(this)
|
||||||
|
|
||||||
|
fun FsPath.visit(visitor: FsPathVisitor): Unit =
|
||||||
|
operations.visit(this, visitor)
|
||||||
|
|
||||||
|
fun FsPath.readString(): String =
|
||||||
|
operations.readString(this)
|
||||||
|
|
||||||
|
fun FsPath.readAllBytes(): ByteArray =
|
||||||
|
operations.readAllBytes(this)
|
||||||
|
|
||||||
|
fun FsPath.readBytesChunked(block: (ByteArray, Int) -> Unit) =
|
||||||
|
operations.readBytesChunked(this, block)
|
||||||
|
|
||||||
|
fun <T> FsPath.readJsonFile(deserializer: DeserializationStrategy<T>): T =
|
||||||
|
operations.readJsonFile(this, deserializer)
|
||||||
|
|
||||||
|
fun FsPath.readLines(block: (String) -> Unit): Unit =
|
||||||
|
operations.readLines(this, block)
|
||||||
|
|
||||||
|
fun FsPath.readLines(): Sequence<String> =
|
||||||
|
operations.readLines(this)
|
||||||
|
|
||||||
|
fun FsPath.readLinesToList(): List<String> {
|
||||||
|
val lines = mutableListOf<String>()
|
||||||
|
readLines { line -> lines.add(line) }
|
||||||
|
return lines
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> FsPath.readJsonLinesToList(deserializer: DeserializationStrategy<T>, block: (T) -> Unit) =
|
||||||
|
operations.readJsonLinesToList(this, deserializer, block)
|
||||||
|
|
||||||
|
fun <T> FsPath.readJsonLinesToList(deserializer: DeserializationStrategy<T>): List<T> =
|
||||||
|
operations.readJsonLinesToList(this, deserializer)
|
||||||
|
|
||||||
|
fun FsPath.writeString(content: String): Unit =
|
||||||
|
operations.writeString(this, content)
|
||||||
|
|
||||||
|
fun FsPath.writeAllBytes(bytes: ByteArray): Unit =
|
||||||
|
operations.writeAllBytes(this, bytes)
|
||||||
|
|
||||||
|
fun <T> FsPath.writeJsonFile(serializer: SerializationStrategy<T>, value: T): Unit =
|
||||||
|
operations.writeJsonFile(this, serializer, value)
|
||||||
|
|
||||||
|
fun FsPath.delete(): Unit =
|
||||||
|
operations.delete(this)
|
||||||
|
|
||||||
|
fun FsPath.deleteOnExit(): Unit =
|
||||||
|
operations.delete(this)
|
||||||
|
|
||||||
|
fun FsPath.deleteRecursively(): Unit =
|
||||||
|
operations.deleteRecursively(this)
|
||||||
|
|
||||||
|
fun FsPath.createDirectories(): Unit =
|
||||||
|
operations.createDirectories(this)
|
@ -0,0 +1,3 @@
|
|||||||
|
package gay.pizza.dough.fs
|
||||||
|
|
||||||
|
expect fun FsPath(path: String): FsPath
|
@ -0,0 +1,12 @@
|
|||||||
|
package gay.pizza.dough.fs
|
||||||
|
|
||||||
|
import java.nio.file.Path
|
||||||
|
|
||||||
|
fun Path.toFsPath(): FsPath = JavaPath(this)
|
||||||
|
fun FsPath.toJavaPath(): Path {
|
||||||
|
return if (this is JavaPath) {
|
||||||
|
javaPath
|
||||||
|
} else {
|
||||||
|
Path.of(fullPathString)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
package gay.pizza.dough.fs
|
||||||
|
|
||||||
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
|
import kotlinx.serialization.SerializationStrategy
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
|
import java.nio.file.Files
|
||||||
|
import kotlin.io.path.bufferedReader
|
||||||
|
import kotlin.io.path.deleteExisting
|
||||||
|
import kotlin.io.path.inputStream
|
||||||
|
import kotlin.streams.asSequence
|
||||||
|
|
||||||
|
object JavaFsOperations : FsOperations {
|
||||||
|
override fun exists(path: FsPath): Boolean = Files.exists(path.toJavaPath())
|
||||||
|
override fun isDirectory(path: FsPath): Boolean = Files.isDirectory(path.toJavaPath())
|
||||||
|
override fun isRegularFile(path: FsPath): Boolean = Files.isRegularFile(path.toJavaPath())
|
||||||
|
override fun isSymbolicLink(path: FsPath): Boolean = Files.isSymbolicLink(path.toJavaPath())
|
||||||
|
override fun isReadable(path: FsPath): Boolean = Files.isReadable(path.toJavaPath())
|
||||||
|
override fun isWritable(path: FsPath): Boolean = Files.isWritable(path.toJavaPath())
|
||||||
|
override fun isExecutable(path: FsPath): Boolean = Files.isExecutable(path.toJavaPath())
|
||||||
|
|
||||||
|
override fun list(path: FsPath): Sequence<FsPath> = Files.list(path.toJavaPath()).asSequence().map { it.toFsPath() }
|
||||||
|
|
||||||
|
override fun walk(path: FsPath): Sequence<FsPath> = Files.walk(path.toJavaPath()).asSequence().map { it.toFsPath() }
|
||||||
|
override fun visit(path: FsPath, visitor: FsPathVisitor) =
|
||||||
|
Files.walkFileTree(path.toJavaPath(), JavaFsPathVisitorAdapter(visitor)).run {}
|
||||||
|
|
||||||
|
override fun readString(path: FsPath): String = Files.readString(path.toJavaPath())
|
||||||
|
override fun readAllBytes(path: FsPath): ByteArray = Files.readAllBytes(path.toJavaPath())
|
||||||
|
override fun readBytesChunked(path: FsPath, block: (ByteArray, Int) -> Unit) {
|
||||||
|
val javaPath = path.toJavaPath()
|
||||||
|
val stream = javaPath.inputStream()
|
||||||
|
val buffer = ByteArray(1024 * 1024)
|
||||||
|
var count: Int
|
||||||
|
while ((stream.read(buffer).also { count = it }) > 0) {
|
||||||
|
block(buffer, count)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun <T> readJsonFile(path: FsPath, deserializer: DeserializationStrategy<T>): T =
|
||||||
|
Json.decodeFromString(deserializer, readString(path))
|
||||||
|
|
||||||
|
override fun readLines(path: FsPath, block: (String) -> Unit) {
|
||||||
|
readLines(path).forEach(block)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun readLines(path: FsPath): Sequence<String> {
|
||||||
|
val stream = path.toJavaPath().bufferedReader()
|
||||||
|
return stream.lineSequence()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun <T> readJsonLinesToList(path: FsPath, deserializer: DeserializationStrategy<T>, block: (T) -> Unit) {
|
||||||
|
readLines(path) { line ->
|
||||||
|
val trimmed = line.trim()
|
||||||
|
val item = Json.decodeFromString(deserializer, trimmed)
|
||||||
|
block(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun <T> readJsonLinesToList(path: FsPath, deserializer: DeserializationStrategy<T>): List<T> {
|
||||||
|
val results = mutableListOf<T>()
|
||||||
|
readJsonLinesToList(path, deserializer) { item ->
|
||||||
|
results.add(item)
|
||||||
|
}
|
||||||
|
return results
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun writeString(path: FsPath, content: String): Unit = Files.writeString(path.toJavaPath(), content).run {}
|
||||||
|
override fun writeAllBytes(path: FsPath, bytes: ByteArray): Unit = Files.write(path.toJavaPath(), bytes).run {}
|
||||||
|
override fun <T> writeJsonFile(path: FsPath, serializer: SerializationStrategy<T>, value: T) =
|
||||||
|
writeString(path, Json.encodeToString(serializer, value))
|
||||||
|
|
||||||
|
override fun delete(path: FsPath) {
|
||||||
|
path.toJavaPath().deleteExisting()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun deleteOnExit(path: FsPath) {
|
||||||
|
path.toJavaPath().toFile().deleteOnExit()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun deleteRecursively(path: FsPath) {
|
||||||
|
path.toJavaPath().toFile().deleteRecursively()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createDirectories(path: FsPath) {
|
||||||
|
Files.createDirectories(path.toJavaPath())
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package gay.pizza.dough.fs
|
||||||
|
|
||||||
|
import java.io.IOException
|
||||||
|
import java.nio.file.FileVisitResult
|
||||||
|
import java.nio.file.FileVisitor
|
||||||
|
import java.nio.file.Path
|
||||||
|
import java.nio.file.attribute.BasicFileAttributes
|
||||||
|
|
||||||
|
class JavaFsPathVisitorAdapter(private val visitor: FsPathVisitor) : FileVisitor<Path> {
|
||||||
|
override fun preVisitDirectory(dir: Path?, attrs: BasicFileAttributes?): FileVisitResult {
|
||||||
|
return visitor.beforeVisitDirectory(dir!!.toFsPath()).adapt()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun visitFile(file: Path?, attrs: BasicFileAttributes?): FileVisitResult {
|
||||||
|
return visitor.visitFile(file!!.toFsPath()).adapt()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun visitFileFailed(file: Path?, exc: IOException?): FileVisitResult {
|
||||||
|
return visitor.visitFileFailed(file!!.toFsPath(), exc!!).adapt()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun postVisitDirectory(dir: Path?, exc: IOException?): FileVisitResult {
|
||||||
|
return visitor.afterVisitDirectory(dir!!.toFsPath()).adapt()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun FsPathVisitor.VisitResult.adapt(): FileVisitResult = when (this) {
|
||||||
|
FsPathVisitor.VisitResult.Continue -> FileVisitResult.CONTINUE
|
||||||
|
FsPathVisitor.VisitResult.Terminate -> FileVisitResult.TERMINATE
|
||||||
|
FsPathVisitor.VisitResult.SkipSubtree -> FileVisitResult.SKIP_SUBTREE
|
||||||
|
FsPathVisitor.VisitResult.SkipSiblings -> FileVisitResult.SKIP_SIBLINGS
|
||||||
|
}
|
||||||
|
}
|
37
dough-fs/src/jvmMain/kotlin/gay/pizza/dough/fs/JavaPath.kt
Normal file
37
dough-fs/src/jvmMain/kotlin/gay/pizza/dough/fs/JavaPath.kt
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package gay.pizza.dough.fs
|
||||||
|
|
||||||
|
import java.nio.file.Path
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.io.path.relativeTo
|
||||||
|
|
||||||
|
class JavaPath(val javaPath: Path) : FsPath {
|
||||||
|
override val fullPathString: String
|
||||||
|
get() = javaPath.toString()
|
||||||
|
|
||||||
|
override val entityNameString: String
|
||||||
|
get() = javaPath.fileName.toString()
|
||||||
|
|
||||||
|
override val parent: FsPath?
|
||||||
|
get() = javaPath.parent?.toFsPath()
|
||||||
|
|
||||||
|
override val operations: FsOperations = JavaFsOperations
|
||||||
|
|
||||||
|
override fun resolve(part: String): FsPath = javaPath.resolve(part).toFsPath()
|
||||||
|
override fun relativeTo(path: FsPath): FsPath = javaPath.relativeTo(path.toJavaPath()).toFsPath()
|
||||||
|
|
||||||
|
override fun toString(): String = javaPath.toString()
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other == null) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (other !is FsPath) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return other.toJavaPath() == javaPath
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int = Objects.hash(javaPath)
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package gay.pizza.dough.fs
|
||||||
|
|
||||||
|
import java.nio.file.Paths
|
||||||
|
|
||||||
|
actual fun FsPath(path: String): FsPath {
|
||||||
|
return JavaPath(Paths.get(path))
|
||||||
|
}
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
244
gradlew
vendored
Executable file
244
gradlew
vendored
Executable file
@ -0,0 +1,244 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015-2021 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "$( uname )" in #(
|
||||||
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
|
Darwin* ) darwin=true ;; #(
|
||||||
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
|
NONSTOP* ) nonstop=true ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD=java
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
|
case $MAX_FD in #(
|
||||||
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC3045
|
||||||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
|
warn "Could not query maximum file descriptor limit"
|
||||||
|
esac
|
||||||
|
case $MAX_FD in #(
|
||||||
|
'' | soft) :;; #(
|
||||||
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC3045
|
||||||
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command;
|
||||||
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
|
# double quotes to make sure that they get re-expanded; and
|
||||||
|
# * put everything else in single quotes, so that it's not re-expanded.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
92
gradlew.bat
vendored
Normal file
92
gradlew.bat
vendored
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%"=="" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
2
settings.gradle.kts
Normal file
2
settings.gradle.kts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
rootProject.name = "dough"
|
||||||
|
include("dough-fs")
|
Reference in New Issue
Block a user