diff --git a/README.md b/README.md index 8c7cfee..a613589 100644 --- a/README.md +++ b/README.md @@ -17,14 +17,21 @@ val size: UInt = interval.size // 10 ``` This protects against overflows (e.g. if `size > Int.MAX_VALUE`) but also offers better semantics. -For example, you can create intervals for [kotlinx datetime](https://github.com/Kotlin/kotlinx-datetime) `Instant` values which are a `Duration` apart. +For example, this library supports [kotlinx datetime](https://github.com/Kotlin/kotlinx-datetime) `Instant` values which are a `Duration` apart. + +```kotlin +val now = Clock.System.now() +val interval: InstantInterval = interval( now, now + 100.seconds ) +val areIncluded = now + 50.seconds in interval // true +val size: Duration = interval.size // 100 seconds +``` ## Interval Types This library includes a generic base class `Interval` which can be used to create intervals for any type. To achieve this, it directs type operations to `IntervalTypeOperations` which the constructor takes as a parameter. -The following interval types are included by default: +The following interval types are included in `io.github.whathecode.kotlinx.interval:kotlinx-interval` on Maven: | Type | Values (`T`) | Distances (`TSize`) | |:----------------:|:------------:|:-------------------:| @@ -38,4 +45,8 @@ The following interval types are included by default: | `UShortInterval` | `UShort` | `UShort` | | `UIntInterval` | `UInt` | `UInt` | | `ULongInterval` | `ULong` | `ULong` | -| `CharInterval` | `Char` | `UShort` | \ No newline at end of file +| `CharInterval` | `Char` | `UShort` | + +### Date/time intervals +Date/time intervals are implemented as `InstantInterval` using the [kotlinx datetime](https://github.com/Kotlin/kotlinx-datetime) library. +Since you may not always want to pull in this dependency, this class is published separately in `io.github.whathecode.kotlinx.interval:kotlinx-interval-datetime`. diff --git a/build.gradle.kts b/build.gradle.kts index 3707c71..f71f761 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,66 +1,7 @@ -import java.io.FileInputStream -import java.util.Properties -import org.gradle.jvm.tasks.Jar -import org.jetbrains.dokka.Platform -import org.jetbrains.dokka.gradle.DokkaTask - - plugins { - kotlin("multiplatform") version "1.6.20" - `maven-publish` - signing - id("org.jetbrains.dokka") version "1.6.21" id("io.github.gradle-nexus.publish-plugin") version "1.1.0" } -group = "io.github.whathecode.kotlinx.interval" -version = "1.0.0-alpha.2" - -repositories { - mavenCentral() - gradlePluginPortal() -} - -kotlin { - jvm { - compilations.all { - kotlinOptions.jvmTarget = "1.8" - } - withJava() - testRuns["test"].executionTask.configure { - useJUnitPlatform() - } - } - js(BOTH) { - browser { } - } - val hostOs = System.getProperty("os.name") - val isMingwX64 = hostOs.startsWith("Windows") - val nativeTarget = when { - hostOs == "Mac OS X" -> macosX64("native") - hostOs == "Linux" -> linuxX64("native") - isMingwX64 -> mingwX64("native") - else -> throw GradleException("Host OS is not supported in Kotlin/Native.") - } - - - sourceSets { - val commonMain by getting - val commonTest by getting { - dependencies { - implementation(kotlin("test")) - } - } - val jvmMain by getting - val jvmTest by getting - val jsMain by getting - val jsTest by getting - val nativeMain by getting - val nativeTest by getting - } -} - - // Publish configuration. // For signing and publishing to work, a 'publish.properties' file needs to be added to the root containing: // The OpenPGP credentials to sign all artifacts: @@ -69,70 +10,13 @@ kotlin { // A username and password to upload artifacts to the Sonatype repository: // > repository.username= // > repository.password= -val publishProperties = Properties() +val publishProperties = java.util.Properties() val publishPropertiesFile = File("publish.properties") if (publishPropertiesFile.exists()) { - publishProperties.load(FileInputStream(publishPropertiesFile)) -} -val dokkaJvmJavadoc by tasks.creating(DokkaTask::class) { - dokkaSourceSets { - register("jvm") { - platform.set(Platform.jvm) - sourceRoots.from(kotlin.sourceSets.getByName("jvmMain").kotlin.srcDirs) - } - } -} -val javadocJar by tasks.creating(Jar::class) { - group = JavaBasePlugin.DOCUMENTATION_GROUP - description = "Create javadoc jar using Dokka" - archiveClassifier.set("javadoc") - from(dokkaJvmJavadoc) -} -publishing { - repositories { - maven { - name = "local" - url = uri("$buildDir/repo") - } - } - publications.filterIsInstance().forEach { - if (it.name == "jvm") { - it.artifact(javadocJar) - } - it.pom { - name.set("kotlinx.interval") - description.set("Kotlin multiplatform bounded open/closed generic intervals.") - url.set("https://github.com/Whathecode/kotlinx.interval") - licenses { - license { - name.set("The Apache Licence, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") - } - } - developers { - developer { - id.set("Whathecode") - name.set("Steven Jeuris") - email.set("steven.jeuris@gmail.com") - } - } - scm { - connection.set("scm:git:git://github.com/Whathecode/kotlinx.interval.git") - developerConnection.set("scm:git:ssh://github.com/Whathecode/carp.core-kotlin.git") - url.set("https://github.com/Whathecode/kotlinx.interval") - } - } - } -} -signing { - val signingKeyFile = publishProperties["signing.keyFile"] as? String - if (signingKeyFile != null) { - val signingKey = File(signingKeyFile).readText() - val signingPassword = publishProperties["signing.password"] as? String - useInMemoryPgpKeys(signingKey, signingPassword) - sign(publishing.publications) - } + publishProperties.load(java.io.FileInputStream(publishPropertiesFile)) } +group = "io.github.whathecode.kotlinx.interval" +version = "1.0.0-alpha.3" nexusPublishing { repositories { sonatype { @@ -143,10 +27,12 @@ nexusPublishing { } } } -val setSnapshotVersion by tasks.creating { +val setSnapshotVersion: Task by tasks.creating { doFirst { val versionSplit = version.toString().split("-") val snapshotVersion = "${versionSplit[0]}-SNAPSHOT" version = snapshotVersion + + rootProject.subprojects.forEach { it.version = snapshotVersion } } } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..5f40a73 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,13 @@ +plugins { + `kotlin-dsl` +} + +repositories { + mavenCentral() + gradlePluginPortal() +} + +dependencies { + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20") + implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.6.21") +} diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts new file mode 100644 index 0000000..e69de29 diff --git a/buildSrc/src/main/kotlin/interval.library-conventions.gradle.kts b/buildSrc/src/main/kotlin/interval.library-conventions.gradle.kts new file mode 100644 index 0000000..c631114 --- /dev/null +++ b/buildSrc/src/main/kotlin/interval.library-conventions.gradle.kts @@ -0,0 +1,124 @@ +import java.io.FileInputStream +import java.util.Properties +import org.jetbrains.dokka.Platform +import org.jetbrains.dokka.gradle.DokkaTask + + +plugins { + kotlin("multiplatform") + id("org.jetbrains.dokka") + `maven-publish` + signing +} + +repositories { + mavenCentral() +} + + +kotlin { + jvm { + compilations.all { + kotlinOptions.jvmTarget = "1.8" + } + withJava() + testRuns["test"].executionTask.configure { + useJUnitPlatform() + } + } + js(BOTH) { + browser { } + } + val hostOs = System.getProperty("os.name") + val isMingwX64 = hostOs.startsWith("Windows") + val nativeTarget = when { + hostOs == "Mac OS X" -> macosX64("native") + hostOs == "Linux" -> linuxX64("native") + isMingwX64 -> mingwX64("native") + else -> throw GradleException("Host OS is not supported in Kotlin/Native.") + } + + + sourceSets { + val commonMain by getting + val commonTest by getting { + dependencies { + implementation(kotlin("test")) + } + } + val jvmMain by getting + val jvmTest by getting + val jsMain by getting + val jsTest by getting + val nativeMain by getting + val nativeTest by getting + } +} + + +// Documentation. +val dokkaJvmJavadoc by tasks.creating(DokkaTask::class) { + dokkaSourceSets { + register("jvm") { + platform.set(Platform.jvm) + sourceRoots.from(kotlin.sourceSets.getByName("jvmMain").kotlin.srcDirs) + } + } +} +val javadocJar by tasks.creating(Jar::class) { + group = JavaBasePlugin.DOCUMENTATION_GROUP + description = "Create javadoc jar using Dokka" + archiveClassifier.set("javadoc") + from(dokkaJvmJavadoc) +} + + +// Publish configuration. +val publishProperties = Properties() +val publishPropertiesFile = File("publish.properties") +if (publishPropertiesFile.exists()) { + publishProperties.load(FileInputStream(publishPropertiesFile)) +} +publishing { + repositories { + maven { + name = "local" + url = uri("$buildDir/repo") + } + } + publications.filterIsInstance().forEach { + if (it.name == "jvm") { + it.artifact(javadocJar) + } + it.pom { + url.set("https://github.com/Whathecode/kotlinx.interval") + licenses { + license { + name.set("The Apache Licence, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + developers { + developer { + id.set("Whathecode") + name.set("Steven Jeuris") + email.set("steven.jeuris@gmail.com") + } + } + scm { + connection.set("scm:git:git://github.com/Whathecode/kotlinx.interval.git") + developerConnection.set("scm:git:ssh://github.com/Whathecode/carp.core-kotlin.git") + url.set("https://github.com/Whathecode/kotlinx.interval") + } + } + } +} +signing { + val signingKeyFile = publishProperties["signing.keyFile"] as? String + if (signingKeyFile != null) { + val signingKey = File(signingKeyFile).readText() + val signingPassword = publishProperties["signing.password"] as? String + useInMemoryPgpKeys(signingKey, signingPassword) + sign(publishing.publications) + } +} diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock index 7a554ce..4c90fc0 100644 --- a/kotlin-js-store/yarn.lock +++ b/kotlin-js-store/yarn.lock @@ -7,6 +7,11 @@ resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== +"@js-joda/core@3.2.0": + version "3.2.0" + resolved "https://registry.yarnpkg.com/@js-joda/core/-/core-3.2.0.tgz#3e61e21b7b2b8a6be746df1335cf91d70db2a273" + integrity sha512-PMqgJ0sw5B7FKb2d5bWYIoxjri+QlW/Pys7+Rw82jSH0QN3rB05jZ/VrrsUdh1w4+i2kw9JOejXGq/KhDOX7Kg== + "@types/component-emitter@^1.2.10": version "1.2.11" resolved "https://registry.yarnpkg.com/@types/component-emitter/-/component-emitter-1.2.11.tgz#50d47d42b347253817a39709fef03ce66a108506" diff --git a/kotlinx.interval.datetime/build.gradle.kts b/kotlinx.interval.datetime/build.gradle.kts new file mode 100644 index 0000000..0992cf1 --- /dev/null +++ b/kotlinx.interval.datetime/build.gradle.kts @@ -0,0 +1,31 @@ +group = rootProject.group +version = rootProject.version + +plugins { + id( "interval.library-conventions" ) +} + +publishing { + publications.filterIsInstance().forEach { + it.pom { + name.set("kotlinx-interval-datetime") + description.set("Kotlin multiplatform bounded open/closed date/time intervals.") + } + } +} + +kotlin { + sourceSets { + commonMain { + dependencies { + api(project(":kotlinx-interval")) + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.3.2") + } + } + commonTest { + dependencies { + implementation(project(":kotlinx-interval-test")) + } + } + } +} diff --git a/kotlinx.interval.datetime/src/commonMain/kotlin/DateTimeTypeOperations.kt b/kotlinx.interval.datetime/src/commonMain/kotlin/DateTimeTypeOperations.kt new file mode 100644 index 0000000..98dc63b --- /dev/null +++ b/kotlinx.interval.datetime/src/commonMain/kotlin/DateTimeTypeOperations.kt @@ -0,0 +1,37 @@ +package io.github.whathecode.kotlinx.interval.datetime + +import io.github.whathecode.kotlinx.interval.TypeOperations +import kotlinx.datetime.Instant +import kotlin.time.Duration +import kotlin.time.Duration.Companion.milliseconds + + +internal object InstantOperations : TypeOperations +{ + override val additiveIdentity: Instant = Instant.fromEpochMilliseconds( 0 ) + override val minValue: Instant = Instant.fromEpochSeconds( Long.MIN_VALUE, Long.MIN_VALUE ) + override val maxValue: Instant = Instant.fromEpochSeconds( Long.MAX_VALUE, Long.MAX_VALUE ) + + override fun unsafeAdd( a: Instant, b: Instant ): Instant = Instant.fromEpochSeconds( + a.epochSeconds + b.epochSeconds, + a.nanosecondsOfSecond + b.nanosecondsOfSecond + ) + + override fun unsafeSubtract( a: Instant, b: Instant ): Instant = Instant.fromEpochSeconds( + a.epochSeconds - b.epochSeconds, + a.nanosecondsOfSecond - b.nanosecondsOfSecond + ) +} + + +internal object DurationOperations : TypeOperations +{ + override val additiveIdentity: Duration = Duration.ZERO + + private const val MAX_MILLIS = Long.MAX_VALUE / 2 + override val minValue: Duration = -MAX_MILLIS.milliseconds + override val maxValue: Duration = MAX_MILLIS.milliseconds + + override fun unsafeAdd( a: Duration, b: Duration ): Duration = a + b + override fun unsafeSubtract( a: Duration, b: Duration ): Duration = a - b +} diff --git a/kotlinx.interval.datetime/src/commonMain/kotlin/InstantInterval.kt b/kotlinx.interval.datetime/src/commonMain/kotlin/InstantInterval.kt new file mode 100644 index 0000000..2d74655 --- /dev/null +++ b/kotlinx.interval.datetime/src/commonMain/kotlin/InstantInterval.kt @@ -0,0 +1,30 @@ +package io.github.whathecode.kotlinx.interval.datetime + +import io.github.whathecode.kotlinx.interval.Interval +import io.github.whathecode.kotlinx.interval.IntervalTypeOperations +import kotlinx.datetime.Instant +import kotlin.time.Duration +import kotlin.time.Duration.Companion.nanoseconds +import kotlin.time.Duration.Companion.seconds + + +/** + * An [Interval] representing the set of all [Instant] values lying between a provided [start] and [end] value. + * The interval can be closed, open, or half-open, as determined by [isStartIncluded] and [isEndIncluded]. + */ +class InstantInterval( start: Instant, isStartIncluded: Boolean, end: Instant, isEndIncluded: Boolean ) + : Interval( start, isStartIncluded, end, isEndIncluded, Operations ) +{ + companion object + { + internal val Operations = IntervalTypeOperations( InstantOperations, DurationOperations ) + { time: Instant -> (time.epochSeconds.seconds + time.nanosecondsOfSecond.nanoseconds).absoluteValue } + } +} + +/** + * Create an [InstantInterval] representing the set of all [Instant] values lying between [start] and [end]. + * To exclude endpoints, set [isStartIncluded] or [isEndIncluded] to false; a closed interval is created by default. + */ +fun interval( start: Instant, end: Instant, isStartIncluded: Boolean = true, isEndIncluded: Boolean = true ) = + InstantInterval( start, isStartIncluded, end, isEndIncluded ) diff --git a/kotlinx.interval.datetime/src/commonTest/kotlin/DateTimeOperationsTest.kt b/kotlinx.interval.datetime/src/commonTest/kotlin/DateTimeOperationsTest.kt new file mode 100644 index 0000000..4aff0ec --- /dev/null +++ b/kotlinx.interval.datetime/src/commonTest/kotlin/DateTimeOperationsTest.kt @@ -0,0 +1,17 @@ +package io.github.whathecode.kotlinx.interval.datetime + +import io.github.whathecode.kotlinx.interval.test.TypeOperationsTest +import kotlinx.datetime.Instant +import kotlin.time.Duration +import kotlin.time.Duration.Companion.seconds + + +object InstantOperationsTest : TypeOperationsTest( + InstantOperations, + a = Instant.fromEpochSeconds( 10, 10 ), + b = Instant.fromEpochSeconds( 5, 15 ), + aMinusB = Instant.fromEpochSeconds( 4, 1_000_000_000 - 5 ) +) + + +object DurationOperationsTest : TypeOperationsTest( DurationOperations, 10.seconds, 5.seconds, 5.seconds ) diff --git a/kotlinx.interval.datetime/src/commonTest/kotlin/InstantIntervalTest.kt b/kotlinx.interval.datetime/src/commonTest/kotlin/InstantIntervalTest.kt new file mode 100644 index 0000000..9dbde3c --- /dev/null +++ b/kotlinx.interval.datetime/src/commonTest/kotlin/InstantIntervalTest.kt @@ -0,0 +1,12 @@ +package io.github.whathecode.kotlinx.interval.datetime + +import io.github.whathecode.kotlinx.interval.test.IntervalTest +import kotlinx.datetime.Instant +import kotlin.time.Duration + + +private val a = Instant.fromEpochSeconds( 0, 50 ) +private val b = Instant.fromEpochSeconds( 0, 100 ) +private val c = Instant.fromEpochSeconds( 100, 50 ) + +object InstantIntervalTest : IntervalTest( a, b, c, b - a, InstantInterval.Operations ) diff --git a/kotlinx.interval.datetime/src/commonTest/kotlin/Readme.kt b/kotlinx.interval.datetime/src/commonTest/kotlin/Readme.kt new file mode 100644 index 0000000..86b4c67 --- /dev/null +++ b/kotlinx.interval.datetime/src/commonTest/kotlin/Readme.kt @@ -0,0 +1,19 @@ +package io.github.whathecode.kotlinx.interval.datetime + +import kotlinx.datetime.Clock +import kotlin.test.* +import kotlin.time.Duration +import kotlin.time.Duration.Companion.seconds + + +class Readme +{ + @Test + fun introduction_instant_interval_example() + { + val now = Clock.System.now() + val interval: InstantInterval = interval( now, now + 100.seconds ) + val areIncluded = now + 50.seconds in interval // true + val size: Duration = interval.size // 100 seconds + } +} diff --git a/kotlinx.interval.test/build.gradle.kts b/kotlinx.interval.test/build.gradle.kts new file mode 100644 index 0000000..d31cc93 --- /dev/null +++ b/kotlinx.interval.test/build.gradle.kts @@ -0,0 +1,31 @@ +group = rootProject.group +version = rootProject.version + +plugins { + id( "interval.library-conventions" ) +} + +publishing { + publications.filterIsInstance().forEach { + it.pom { + name.set("kotlinx-interval-test") + description.set("Base test classes for extensions of kotlinx.interval.") + } + } +} + +kotlin { + sourceSets { + commonMain { + dependencies { + api(project(":kotlinx-interval")) + implementation(kotlin("test")) + } + } + jvmMain { + dependencies { + implementation(kotlin("test-junit5")) + } + } + } +} diff --git a/src/commonTest/kotlin/IntervalTest.kt b/kotlinx.interval.test/src/commonMain/kotlin/IntervalTest.kt similarity index 96% rename from src/commonTest/kotlin/IntervalTest.kt rename to kotlinx.interval.test/src/commonMain/kotlin/IntervalTest.kt index 789d090..1d380a3 100644 --- a/src/commonTest/kotlin/IntervalTest.kt +++ b/kotlinx.interval.test/src/commonMain/kotlin/IntervalTest.kt @@ -1,5 +1,7 @@ -package io.github.whathecode.kotlinx.interval +package io.github.whathecode.kotlinx.interval.test +import io.github.whathecode.kotlinx.interval.Interval +import io.github.whathecode.kotlinx.interval.IntervalTypeOperations import kotlin.test.* diff --git a/src/commonTest/kotlin/TypeOperationsTest.kt b/kotlinx.interval.test/src/commonMain/kotlin/TypeOperationsTest.kt similarity index 94% rename from src/commonTest/kotlin/TypeOperationsTest.kt rename to kotlinx.interval.test/src/commonMain/kotlin/TypeOperationsTest.kt index 5007ebc..83bffa8 100644 --- a/src/commonTest/kotlin/TypeOperationsTest.kt +++ b/kotlinx.interval.test/src/commonMain/kotlin/TypeOperationsTest.kt @@ -1,5 +1,6 @@ -package io.github.whathecode.kotlinx.interval +package io.github.whathecode.kotlinx.interval.test +import io.github.whathecode.kotlinx.interval.TypeOperations import kotlin.test.* diff --git a/kotlinx.interval/build.gradle.kts b/kotlinx.interval/build.gradle.kts new file mode 100644 index 0000000..082d3b8 --- /dev/null +++ b/kotlinx.interval/build.gradle.kts @@ -0,0 +1,25 @@ +group = rootProject.group +version = rootProject.version + +plugins { + id( "interval.library-conventions" ) +} + +publishing { + publications.filterIsInstance().forEach { + it.pom { + name.set("kotlinx-interval") + description.set("Kotlin multiplatform bounded open/closed generic intervals.") + } + } +} + +kotlin { + sourceSets { + commonTest { + dependencies { + implementation(project(":kotlinx-interval-test")) + } + } + } +} diff --git a/src/commonMain/kotlin/BasicTypeIntervals.kt b/kotlinx.interval/src/commonMain/kotlin/BasicTypeIntervals.kt similarity index 100% rename from src/commonMain/kotlin/BasicTypeIntervals.kt rename to kotlinx.interval/src/commonMain/kotlin/BasicTypeIntervals.kt diff --git a/src/commonMain/kotlin/BasicTypeOperations.kt b/kotlinx.interval/src/commonMain/kotlin/BasicTypeOperations.kt similarity index 100% rename from src/commonMain/kotlin/BasicTypeOperations.kt rename to kotlinx.interval/src/commonMain/kotlin/BasicTypeOperations.kt diff --git a/src/commonMain/kotlin/Interval.kt b/kotlinx.interval/src/commonMain/kotlin/Interval.kt similarity index 100% rename from src/commonMain/kotlin/Interval.kt rename to kotlinx.interval/src/commonMain/kotlin/Interval.kt diff --git a/src/commonMain/kotlin/IntervalTypeOperations.kt b/kotlinx.interval/src/commonMain/kotlin/IntervalTypeOperations.kt similarity index 100% rename from src/commonMain/kotlin/IntervalTypeOperations.kt rename to kotlinx.interval/src/commonMain/kotlin/IntervalTypeOperations.kt diff --git a/src/commonMain/kotlin/TypeOperations.kt b/kotlinx.interval/src/commonMain/kotlin/TypeOperations.kt similarity index 100% rename from src/commonMain/kotlin/TypeOperations.kt rename to kotlinx.interval/src/commonMain/kotlin/TypeOperations.kt diff --git a/src/commonTest/kotlin/BasicTypeIntervalsTest.kt b/kotlinx.interval/src/commonTest/kotlin/BasicTypeIntervalsTest.kt similarity index 95% rename from src/commonTest/kotlin/BasicTypeIntervalsTest.kt rename to kotlinx.interval/src/commonTest/kotlin/BasicTypeIntervalsTest.kt index 0a05894..e7c055d 100644 --- a/src/commonTest/kotlin/BasicTypeIntervalsTest.kt +++ b/kotlinx.interval/src/commonTest/kotlin/BasicTypeIntervalsTest.kt @@ -1,5 +1,7 @@ package io.github.whathecode.kotlinx.interval +import io.github.whathecode.kotlinx.interval.test.IntervalTest + object ByteIntervalTest : IntervalTest( 0, 5, 10, 5.toUByte(), ByteInterval.Operations ) object ShortIntervalTest : IntervalTest( 0, 5, 10, 5.toUShort(), ShortInterval.Operations ) diff --git a/src/commonTest/kotlin/BasicTypeOperationsTest.kt b/kotlinx.interval/src/commonTest/kotlin/BasicTypeOperationsTest.kt similarity index 95% rename from src/commonTest/kotlin/BasicTypeOperationsTest.kt rename to kotlinx.interval/src/commonTest/kotlin/BasicTypeOperationsTest.kt index 5b3be57..1bca7c4 100644 --- a/src/commonTest/kotlin/BasicTypeOperationsTest.kt +++ b/kotlinx.interval/src/commonTest/kotlin/BasicTypeOperationsTest.kt @@ -1,5 +1,6 @@ package io.github.whathecode.kotlinx.interval +import io.github.whathecode.kotlinx.interval.test.TypeOperationsTest import kotlin.test.* diff --git a/src/commonTest/kotlin/Readme.kt b/kotlinx.interval/src/commonTest/kotlin/Readme.kt similarity index 89% rename from src/commonTest/kotlin/Readme.kt rename to kotlinx.interval/src/commonTest/kotlin/Readme.kt index 6c798e8..29ab726 100644 --- a/src/commonTest/kotlin/Readme.kt +++ b/kotlinx.interval/src/commonTest/kotlin/Readme.kt @@ -6,7 +6,7 @@ import kotlin.test.* class Readme { @Test - fun introduction_example() + fun introduction_int_interval_example() { val interval: IntInterval = interval( 0, 10, isEndIncluded = false ) val areIncluded = 0 in interval && 5 in interval // true diff --git a/settings.gradle.kts b/settings.gradle.kts index 8224f7b..f336af0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1 +1,8 @@ -rootProject.name = "kotlinx-interval" +include("kotlinx.interval") +project(":kotlinx.interval").name = "kotlinx-interval" + +include("kotlinx.interval.test") +project(":kotlinx.interval.test").name = "kotlinx-interval-test" + +include("kotlinx.interval.datetime") +project(":kotlinx.interval.datetime").name = "kotlinx-interval-datetime"