initial commit
This commit is contained in:
100
core/build.gradle.kts
Normal file
100
core/build.gradle.kts
Normal file
@@ -0,0 +1,100 @@
|
||||
import java.util.*
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.dokka)
|
||||
alias(libs.plugins.kotlin.jvm)
|
||||
alias(libs.plugins.maven.publish)
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.kotlinx.datetime)
|
||||
implementation(libs.ktor.client)
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
testImplementation(kotlin("test"))
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
kotlin {
|
||||
jvmToolchain(11)
|
||||
}
|
||||
|
||||
val javadocJar by tasks.register<Jar>("dokkaJavadocJar") {
|
||||
dependsOn(tasks.dokkaJavadoc)
|
||||
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
|
||||
archiveClassifier.set("javadoc")
|
||||
}
|
||||
|
||||
val sourcesJar by tasks.register<Jar>("sourcesJar") {
|
||||
from(sourceSets.main.get().allSource)
|
||||
archiveClassifier.set("sources")
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
groupId = rootProject.group.toString()
|
||||
artifactId = "time"
|
||||
version = rootProject.version.toString()
|
||||
from(components["java"])
|
||||
artifact(javadocJar)
|
||||
artifact(sourcesJar)
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
val secretFile = rootProject.file("secret.properties")
|
||||
if (secretFile.exists()) {
|
||||
val secret = Properties()
|
||||
secretFile.inputStream().also { secret.load(it) }
|
||||
|
||||
val mavenUrl = secret["neuon.maven.url"] as? String
|
||||
val mavenUsername = secret["neuon.maven.username"] as? String
|
||||
val mavenPassword = secret["neuon.maven.password"] as? String
|
||||
|
||||
if (mavenUrl != null && mavenUsername != null && mavenPassword != null) {
|
||||
maven {
|
||||
requireNotNull(mavenUrl) {
|
||||
"neuon.maven.url is missing from secret.properties"
|
||||
}
|
||||
requireNotNull(mavenUsername) {
|
||||
"neuon.maven.username is missing from secret.properties"
|
||||
}
|
||||
requireNotNull(mavenPassword) {
|
||||
"neuon.maven.password is missing from secret.properties"
|
||||
}
|
||||
name = "neuon"
|
||||
url = uri(mavenUrl)
|
||||
|
||||
credentials(PasswordCredentials::class) {
|
||||
username = mavenUsername
|
||||
password = mavenPassword
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val list = listOfNotNull(
|
||||
"neuon.maven.url".takeIf { mavenUrl == null },
|
||||
"neuon.maven.username".takeIf { mavenUsername == null },
|
||||
"neuon.maven.password".takeIf { mavenPassword == null },
|
||||
)
|
||||
val message = buildString {
|
||||
append("Missing Maven publication in secret.properties: ")
|
||||
append(list.joinToString())
|
||||
append(". Ignore this if you don't plan on publishing this library")
|
||||
}
|
||||
|
||||
logger.error(message)
|
||||
}
|
||||
} else {
|
||||
logger.error(
|
||||
buildString {
|
||||
append("Missing secret.properties. Ignore this if you don't plan on publishing this library")
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
6
core/src/main/kotlin/ai/neuon/utility/time/Instant.kt
Normal file
6
core/src/main/kotlin/ai/neuon/utility/time/Instant.kt
Normal file
@@ -0,0 +1,6 @@
|
||||
@file:OptIn(ExperimentalTime::class)
|
||||
|
||||
package ai.neuon.utility.time
|
||||
|
||||
import kotlin.time.ExperimentalTime
|
||||
|
||||
31
core/src/main/kotlin/ai/neuon/utility/time/InstantPeriod.kt
Normal file
31
core/src/main/kotlin/ai/neuon/utility/time/InstantPeriod.kt
Normal file
@@ -0,0 +1,31 @@
|
||||
@file:OptIn(ExperimentalTime::class)
|
||||
|
||||
package ai.neuon.utility.time
|
||||
|
||||
import kotlin.time.ExperimentalTime
|
||||
import kotlin.time.Instant
|
||||
|
||||
sealed class InstantPeriod {
|
||||
abstract val from: Instant?
|
||||
abstract val until: Instant?
|
||||
|
||||
class From(private val instant: Instant) : InstantPeriod() {
|
||||
override val from: Instant
|
||||
get() = instant
|
||||
override val until: Instant? = null
|
||||
}
|
||||
|
||||
class Until(private val instant: Instant) : InstantPeriod() {
|
||||
override val from: Instant? = null
|
||||
override val until: Instant?
|
||||
get() = instant
|
||||
}
|
||||
|
||||
class Range(private val instant1: Instant, private val instant2: Instant) : InstantPeriod() {
|
||||
override val from: Instant
|
||||
get() = minOf(instant1, instant2)
|
||||
|
||||
override val until: Instant
|
||||
get() = maxOf(instant1, instant2)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user