-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
2,328 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
public final class com/xemantic/ai/money/JvmMoney : com/xemantic/ai/money/Money { | ||
public fun <init> (Ljava/math/BigDecimal;)V | ||
public fun compareTo (Lcom/xemantic/ai/money/Money;)I | ||
public fun equals (Ljava/lang/Object;)Z | ||
public fun hashCode ()I | ||
public fun minus (Lcom/xemantic/ai/money/Money;)Lcom/xemantic/ai/money/Money; | ||
public fun plus (Lcom/xemantic/ai/money/Money;)Lcom/xemantic/ai/money/Money; | ||
public fun times (Lcom/xemantic/ai/money/Money$Ratio;)Lcom/xemantic/ai/money/Money; | ||
public fun times (Lcom/xemantic/ai/money/Money;)Lcom/xemantic/ai/money/Money; | ||
public fun toString ()Ljava/lang/String; | ||
} | ||
|
||
public final class com/xemantic/ai/money/JvmMoneyKt { | ||
public static final fun Money (Ljava/lang/String;)Lcom/xemantic/ai/money/Money; | ||
public static final fun Ratio (Lcom/xemantic/ai/money/Money$Companion;Ljava/lang/String;)Lcom/xemantic/ai/money/Money$Ratio; | ||
public static final fun getONE (Lcom/xemantic/ai/money/Money$Companion;)Lcom/xemantic/ai/money/Money; | ||
public static final fun getONE (Lcom/xemantic/ai/money/Money$Ratio$Companion;)Lcom/xemantic/ai/money/Money$Ratio; | ||
public static final fun getZERO (Lcom/xemantic/ai/money/Money$Companion;)Lcom/xemantic/ai/money/Money; | ||
} | ||
|
||
public abstract interface class com/xemantic/ai/money/Money { | ||
public static final field Companion Lcom/xemantic/ai/money/Money$Companion; | ||
public abstract fun compareTo (Lcom/xemantic/ai/money/Money;)I | ||
public abstract fun minus (Lcom/xemantic/ai/money/Money;)Lcom/xemantic/ai/money/Money; | ||
public abstract fun plus (Lcom/xemantic/ai/money/Money;)Lcom/xemantic/ai/money/Money; | ||
public abstract fun times (Lcom/xemantic/ai/money/Money$Ratio;)Lcom/xemantic/ai/money/Money; | ||
public abstract fun times (Lcom/xemantic/ai/money/Money;)Lcom/xemantic/ai/money/Money; | ||
} | ||
|
||
public final class com/xemantic/ai/money/Money$Companion { | ||
public final fun serializer ()Lkotlinx/serialization/KSerializer; | ||
} | ||
|
||
public abstract interface class com/xemantic/ai/money/Money$Ratio { | ||
public static final field Companion Lcom/xemantic/ai/money/Money$Ratio$Companion; | ||
public abstract fun times (Lcom/xemantic/ai/money/Money;)Lcom/xemantic/ai/money/Money; | ||
} | ||
|
||
public final class com/xemantic/ai/money/Money$Ratio$Companion { | ||
public final fun serializer ()Lkotlinx/serialization/KSerializer; | ||
} | ||
|
||
public final class com/xemantic/ai/money/serialization/MoneyRatioSerializer : kotlinx/serialization/KSerializer { | ||
public static final field INSTANCE Lcom/xemantic/ai/money/serialization/MoneyRatioSerializer; | ||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lcom/xemantic/ai/money/Money$Ratio; | ||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; | ||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; | ||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lcom/xemantic/ai/money/Money$Ratio;)V | ||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V | ||
} | ||
|
||
public final class com/xemantic/ai/money/serialization/MoneySerializer : kotlinx/serialization/KSerializer { | ||
public static final field INSTANCE Lcom/xemantic/ai/money/serialization/MoneySerializer; | ||
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Lcom/xemantic/ai/money/Money; | ||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; | ||
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; | ||
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Lcom/xemantic/ai/money/Money;)V | ||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,303 @@ | ||
@file:OptIn(ExperimentalWasmDsl::class, ExperimentalKotlinGradlePluginApi::class) | ||
|
||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat | ||
import org.gradle.api.tasks.testing.logging.TestLogEvent | ||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi | ||
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion | ||
import org.jetbrains.kotlin.gradle.swiftexport.ExperimentalSwiftExportDsl | ||
|
||
plugins { | ||
alias(libs.plugins.kotlin.multiplatform) | ||
alias(libs.plugins.kotlin.plugin.serialization) | ||
alias(libs.plugins.kotlin.plugin.power.assert) | ||
alias(libs.plugins.kotlinx.binary.compatibility.validator) | ||
alias(libs.plugins.dokka) | ||
alias(libs.plugins.versions) | ||
`maven-publish` | ||
signing | ||
alias(libs.plugins.publish) | ||
} | ||
|
||
val githubAccount = "xemantic" | ||
|
||
val javaTarget = libs.versions.javaTarget.get() | ||
val kotlinTarget = KotlinVersion.fromVersion(libs.versions.kotlinTarget.get()) | ||
|
||
val isReleaseBuild = !project.version.toString().endsWith("-SNAPSHOT") | ||
val githubActor: String? by project | ||
val githubToken: String? by project | ||
val signingKey: String? by project | ||
val signingPassword: String? by project | ||
val sonatypeUser: String? by project | ||
val sonatypePassword: String? by project | ||
|
||
println(""" | ||
+-------------------------------------------- | ||
| Project: ${project.name} | ||
| Version: ${project.version} | ||
| Release build: $isReleaseBuild | ||
+-------------------------------------------- | ||
""" | ||
) | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
kotlin { | ||
|
||
applyDefaultHierarchyTemplate() | ||
|
||
explicitApi() | ||
|
||
compilerOptions { | ||
apiVersion = kotlinTarget | ||
languageVersion = kotlinTarget | ||
freeCompilerArgs.add("-Xmulti-dollar-interpolation") | ||
extraWarnings.set(true) | ||
progressiveMode = true | ||
} | ||
|
||
jvm { | ||
// set up according to https://jakewharton.com/gradle-toolchains-are-rarely-a-good-idea/ | ||
compilerOptions { | ||
apiVersion = kotlinTarget | ||
languageVersion = kotlinTarget | ||
jvmTarget = JvmTarget.fromTarget(javaTarget) | ||
freeCompilerArgs.add("-Xjdk-release=$javaTarget") | ||
progressiveMode = true | ||
} | ||
} | ||
|
||
js { | ||
browser() | ||
nodejs() | ||
binaries.library() | ||
} | ||
|
||
wasmJs { | ||
browser() | ||
nodejs() | ||
//d8() | ||
binaries.library() | ||
} | ||
|
||
wasmWasi { | ||
nodejs() | ||
binaries.library() | ||
} | ||
|
||
// native, see https://kotlinlang.org/docs/native-target-support.html | ||
// tier 1 | ||
macosX64() | ||
macosArm64() | ||
iosSimulatorArm64() | ||
iosX64() | ||
iosArm64() | ||
|
||
// tier 2 | ||
linuxX64() | ||
linuxArm64() | ||
watchosSimulatorArm64() | ||
watchosX64() | ||
watchosArm32() | ||
watchosArm64() | ||
tvosSimulatorArm64() | ||
tvosX64() | ||
tvosArm64() | ||
|
||
// tier 3 | ||
androidNativeArm32() | ||
androidNativeArm64() | ||
androidNativeX86() | ||
androidNativeX64() | ||
mingwX64() | ||
// can be enabled once it is released in BigNum | ||
//watchosDeviceArm64() | ||
|
||
@OptIn(ExperimentalSwiftExportDsl::class) | ||
swiftExport {} | ||
|
||
sourceSets { | ||
|
||
commonMain { | ||
dependencies { | ||
implementation(libs.xemantic.ai.tool.schema) | ||
implementation(libs.kotlinx.serialization.core) | ||
} | ||
} | ||
|
||
commonTest { | ||
dependencies { | ||
implementation(libs.kotlin.test) | ||
implementation(libs.kotlinx.serialization.json) | ||
} | ||
} | ||
|
||
val nonJvmMain by creating { | ||
dependsOn(commonMain.get()) | ||
dependencies { | ||
implementation(libs.bignum) | ||
} | ||
} | ||
|
||
nativeMain { | ||
dependsOn(nonJvmMain) | ||
} | ||
|
||
jsMain { | ||
dependsOn(nonJvmMain) | ||
} | ||
|
||
wasmJsMain { | ||
dependsOn(nonJvmMain) | ||
} | ||
|
||
wasmWasiMain { | ||
dependsOn(nonJvmMain) | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
//// skip tests which require XCode components to be installed | ||
tasks.named("tvosSimulatorArm64Test") { enabled = false } | ||
tasks.named("watchosSimulatorArm64Test") { enabled = false } | ||
|
||
tasks.withType<Test> { | ||
testLogging { | ||
events( | ||
TestLogEvent.SKIPPED, | ||
TestLogEvent.FAILED | ||
) | ||
showStackTraces = true | ||
exceptionFormat = TestExceptionFormat.FULL | ||
} | ||
} | ||
|
||
powerAssert { | ||
functions = listOf( | ||
"com.xemantic.ai.money.test.shouldBe" | ||
) | ||
} | ||
|
||
// https://kotlinlang.org/docs/dokka-migration.html#adjust-configuration-options | ||
dokka { | ||
pluginsConfiguration.html { | ||
footerMessage.set("(c) 2024 Xemantic") | ||
} | ||
} | ||
|
||
val javadocJar by tasks.registering(Jar::class) { | ||
archiveClassifier.set("javadoc") | ||
from(tasks.dokkaGeneratePublicationHtml) | ||
} | ||
|
||
publishing { | ||
repositories { | ||
if (!isReleaseBuild) { | ||
maven { | ||
name = "GitHubPackages" | ||
setUrl("https://maven.pkg.github.com/$githubAccount/${rootProject.name}") | ||
credentials { | ||
username = githubActor | ||
password = githubToken | ||
} | ||
} | ||
} | ||
} | ||
publications { | ||
withType<MavenPublication> { | ||
artifact(javadocJar) | ||
pom { | ||
name = "xemantic-ai-money" | ||
description = "Kotlin multiplatform library for real-time calculation of LLM usage costs" | ||
url = "https://github.com/$githubAccount/${rootProject.name}" | ||
inceptionYear = "2024" | ||
organization { | ||
name = "Xemantic" | ||
url = "https://xemantic.com" | ||
} | ||
licenses { | ||
license { | ||
name = "The Apache Software License, Version 2.0" | ||
url = "http://www.apache.org/licenses/LICENSE-2.0.txt" | ||
distribution = "repo" | ||
} | ||
} | ||
scm { | ||
url = "https://github.com/$githubAccount/${rootProject.name}" | ||
connection = "scm:git:git:github.com/$githubAccount/${rootProject.name}.git" | ||
developerConnection = "scm:git:https://github.com/$githubAccount/${rootProject.name}.git" | ||
} | ||
ciManagement { | ||
system = "GitHub" | ||
url = "https://github.com/$githubAccount/${rootProject.name}/actions" | ||
} | ||
issueManagement { | ||
system = "GitHub" | ||
url = "https://github.com/$githubAccount/${rootProject.name}/issues" | ||
} | ||
developers { | ||
developer { | ||
id = "morisil" | ||
name = "Kazik Pogoda" | ||
email = "[email protected]" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (isReleaseBuild) { | ||
|
||
// workaround for KMP/gradle signing issue | ||
// https://github.com/gradle/gradle/issues/26091 | ||
tasks { | ||
withType<PublishToMavenRepository> { | ||
dependsOn(withType<Sign>()) | ||
} | ||
} | ||
|
||
// Resolves issues with .asc task output of the sign task of native targets. | ||
// See: https://github.com/gradle/gradle/issues/26132 | ||
// And: https://youtrack.jetbrains.com/issue/KT-46466 | ||
tasks.withType<Sign>().configureEach { | ||
val pubName = name.removePrefix("sign").removeSuffix("Publication") | ||
|
||
// These tasks only exist for native targets, hence findByName() to avoid trying to find them for other targets | ||
|
||
// Task ':linkDebugTest<platform>' uses this output of task ':sign<platform>Publication' without declaring an explicit or implicit dependency | ||
tasks.findByName("linkDebugTest$pubName")?.let { | ||
mustRunAfter(it) | ||
} | ||
// Task ':compileTestKotlin<platform>' uses this output of task ':sign<platform>Publication' without declaring an explicit or implicit dependency | ||
tasks.findByName("compileTestKotlin$pubName")?.let { | ||
mustRunAfter(it) | ||
} | ||
} | ||
|
||
signing { | ||
useInMemoryPgpKeys( | ||
signingKey, | ||
signingPassword | ||
) | ||
sign(publishing.publications) | ||
} | ||
|
||
nexusPublishing { | ||
repositories { | ||
sonatype { //only for users registered in Sonatype after 24 Feb 2021 | ||
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) | ||
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) | ||
username.set(sonatypeUser) | ||
password.set(sonatypePassword) | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
kotlin.code.style=official | ||
kotlin.js.generate.executable.default=false | ||
kotlin.apple.xcodeCompatibility.nowarn=true | ||
kotlin.experimental.swift-export.enabled=true | ||
kotlin.native.enableKlibsCrossCompilation=true | ||
kotlin.incremental.wasm=true | ||
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled | ||
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true | ||
group=com.xemantic.ai | ||
version=0.1-SNAPSHOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.