Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add length #13

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
1 change: 1 addition & 0 deletions length/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
3 changes: 3 additions & 0 deletions length/MODULE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Module distance

Store and convert between units of distance. For example, `1"` --> `2.54 cm`.
109 changes: 109 additions & 0 deletions length/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import org.jetbrains.dokka.gradle.DokkaTaskPartial
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
import java.net.URL

plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.android.library)

alias(libs.plugins.detekt)

alias(libs.plugins.dokka)
id("com.boswelja.publish")
}

android {
namespace = "com.boswelja.length"

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}

lint {
sarifReport = true
htmlReport = false
}
}

repositories {
google()
mavenCentral()
}

kotlin {
jvmToolchain(21)

// Android
androidTarget {
publishLibraryVariants("release")
}

// JVM
jvm()

// Apple
iosArm64()
iosX64()
macosX64()
macosArm64()
tvosX64()
tvosArm64()
watchosArm32()
watchosArm64()

// Windows
mingwX64()

// Linux
linuxArm64()
linuxX64()

// WASM
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser()
}

sourceSets {
commonMain {
dependencies {
implementation(kotlin("stdlib"))
implementation(libs.ionspin.bignum)
}
}
commonTest {
dependencies {
implementation(kotlin("test"))
}
}
}
}

detekt {
buildUponDefaultConfig = true
config.setFrom("$rootDir/config/detekt.yml")
basePath = rootDir.absolutePath
}

publish {
description = "A Length class that allows you to convert between any unit of length"
repositoryUrl = "https://github.com/boswelja/kotlin-datatypes"
license = "MIT"
}

tasks.withType<DokkaTaskPartial>().configureEach {
dokkaSourceSets.configureEach {
includes.from("MODULE.md")
sourceLink {
localDirectory.set(projectDir.resolve("src"))
remoteUrl.set(URL("${publish.repositoryUrl.get()}/tree/main/${project.name}/src"))
remoteLineSuffix.set("#L")
}
}
}
6 changes: 6 additions & 0 deletions length/src/commonMain/kotlin/com/boswelja/length/Length.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.boswelja.length

import kotlin.jvm.JvmInline

@JvmInline
value class Length(val meter: Double)
20 changes: 20 additions & 0 deletions length/src/commonMain/kotlin/com/boswelja/length/LengthUnit.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.boswelja.length

interface LengthUnit {

fun fromMeters(meters: Double): Double

fun toMeters(unit: Double): Double
}

enum class MetricLengthUnit : LengthUnit {
METER;

override fun fromMeters(meters: Double): Double {
TODO("Not yet implemented")
}

override fun toMeters(unit: Double): Double {
TODO("Not yet implemented")
}
}
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ rootProject.name = "kotlin-datatypes"
include(
":bitrate",
":capacity",
":length",
":percentage",
":temperature"
)
Expand Down
Loading