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

Feature/date time provider #26

Merged
merged 6 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Project exclude paths
/.gradle/
/.idea/
/build/
/build/classes/kotlin/jvm/main/
/build/classes/kotlin/jvm/test/
.gradle/
.idea/
build/
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# KCron Common
# KCron
Cron realization for Kotlin Multiplatform

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Scogun_kcron-common&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Scogun_kcron-common) ![GitHub](https://img.shields.io/github/license/Scogun/kcron-common?color=blue) ![Publish workflow](https://github.com/Scogun/kcron-common/actions/workflows/publish.yml/badge.svg) [![Maven Central with version prefix filter](https://img.shields.io/maven-central/v/com.ucasoft.kcron/kcron-common/0.9.2?color=blue)](https://search.maven.org/artifact/com.ucasoft.kcron/kcron-common/0.9.2/jar)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Scogun_kcron-common&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Scogun_kcron-common) ![GitHub](https://img.shields.io/github/license/Scogun/kcron-common?color=blue) ![Publish workflow](https://github.com/Scogun/kcron-common/actions/workflows/publish.yml/badge.svg) [![Maven Central with version prefix filter](https://img.shields.io/maven-central/v/com.ucasoft.kcron/kcron-common/0.10.0?color=blue)](https://search.maven.org/artifact/com.ucasoft.kcron/kcron-common/0.10.0/jar)

### Features
* Kotlin Multiplatform library
Expand Down Expand Up @@ -31,14 +31,16 @@ builder
* macOS
* Javascript
* iOS
* Support different DateTime libraries (via DateTime Provider Abstractions)
### Usage
#### KCron-Common library as default implementation uses [Kotlinx-DateTime](https://github.com/Kotlin/kotlinx-datetime) library
***Add with Gradle***
```groovy
kotlin {
sourceSets {
commonMain {
dependencies {
implementation 'com.ucasoft.kcron:kcron-common:0.9.2'
implementation 'com.ucasoft.kcron:kcron-common:0.10.0'
}
}
}
Expand Down Expand Up @@ -103,6 +105,6 @@ builder.years(2021..2025)
println(builder.expression) // 0/10 5-25 5,12 ? * SUN#5 2021-2025
```
### Current status
This library is on beta version `0.9.2`.
However, it will be a part of another cool library.
Check the news!
This library is on beta version `0.10.0`.
It is continuing to develop.
Check the news!
127 changes: 9 additions & 118 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,125 +1,16 @@
plugins {
alias(libs.plugins.multiplatform)
id("maven-publish")
id("signing")
}
allprojects {

group = "com.ucasoft.kcron"
version = "0.9.2"
group = "com.ucasoft.kcron"

repositories {
mavenCentral()
}
kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
linuxX64()
linuxArm64()
mingwX64()
macosX64()
macosArm64()
js(IR) {
browser()
nodejs()
}
iosX64()
iosArm64()
iosSimulatorArm64()
sourceSets {
commonMain {
dependencies {
implementation(libs.kotlinx.datetime)
}
}
commonTest {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
implementation(libs.kotest.assetions)
}
}
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit"))
}
}
}
}

val stubSources by tasks.creating(Jar::class) {
archiveClassifier.set("sources")
}
version = "0.10.0"

val stubJavadoc by tasks.creating(Jar::class) {
archiveClassifier.set("javadoc")
}

val sourceJar by tasks.creating(Jar::class) {
archiveClassifier.set("sources")
from(kotlin.sourceSets.commonMain.get().kotlin)
}

publishing {
publications.configureEach {
if (this is MavenPublication) {
if (name != "kotlinMultiplatform") {
artifact(stubJavadoc)
}
pom {
name.set("KCron Common")
description.set("Cron realization for Kotlin Multiplatform")
url.set("https://github.com/Scogun/kcron-common")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("Scogun")
name.set("Sergey Antonov")
email.set("SAntonov@ucasoft.com")
}
developer {
id.set("Myshkouski")
name.set("Alexei Myshkouski")
email.set("alexeimyshkouski@gmail.com")
}
}
scm {
connection.set("scm:git:git://github.com/Scogun/kcron-common.git")
developerConnection.set("scm:git:ssh://github.com:Scogun/kcron-common.git")
url.set("https://github.com/Scogun/kcron-common")
}
}
}
}
repositories {
maven {
name = "MavenCentral"
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
mavenCentral()
}
}

signing {
sign(publishing.publications)
}

tasks.withType<AbstractPublishToMaven>().configureEach {
val signingTasks = tasks.withType<Sign>()
mustRunAfter(signingTasks)
tasks.withType<Test> {
reports {
junitXml.required.set(true)
}
}
}
7 changes: 7 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
}
7 changes: 7 additions & 0 deletions buildSrc/src/main/kotlin/PublishingExtension.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import org.gradle.api.model.ObjectFactory
import org.gradle.kotlin.dsl.property

open class PublishingExtension(factory: ObjectFactory) {
val name = factory.property<String>()
val description = factory.property<String>()
}
67 changes: 67 additions & 0 deletions buildSrc/src/main/kotlin/publish.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
plugins {
`maven-publish`
signing
}

val libraryData = extensions.create("libraryData", PublishingExtension::class)

val stubJavadoc by tasks.creating(Jar::class) {
archiveClassifier.set("javadoc")
}

publishing {
publications.configureEach {
if (this is MavenPublication) {
if (name != "kotlinMultiplatform") {
artifact(stubJavadoc)
}
pom {
name.set(libraryData.name)
description.set(libraryData.description)
url.set("https://github.com/Scogun/kcron-common")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("Scogun")
name.set("Sergey Antonov")
email.set("SAntonov@ucasoft.com")
}
developer {
id.set("Myshkouski")
name.set("Alexei Myshkouski")
email.set("alexeimyshkouski@gmail.com")
}
}
scm {
connection.set("scm:git:git://github.com/Scogun/kcron-common.git")
developerConnection.set("scm:git:ssh://github.com:Scogun/kcron-common.git")
url.set("https://github.com/Scogun/kcron-common")
}
}
}
}
repositories {
maven {
name = "MavenCentral"
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
}
}

signing {
sign(publishing.publications)
}

tasks.withType<AbstractPublishToMaven>().configureEach {
val signingTasks = tasks.withType<Sign>()
mustRunAfter(signingTasks)
}
32 changes: 32 additions & 0 deletions kcron-abstractions/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
plugins {
alias(libs.plugins.multiplatform)
id("publish")
}

kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
linuxX64()
linuxArm64()
mingwX64()
macosX64()
macosArm64()
js(IR) {
browser()
nodejs()
}
iosX64()
iosArm64()
iosSimulatorArm64()
sourceSets {
commonMain
}
}

libraryData {
name.set("KCron Abstractions")
description.set("Abstractions for Kotlin Multiplatform Cron realization")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.ucasoft.kcron.abstractions

interface CronDateTime<out T> {

val year: Int

val month: Int

val dayOfMonth: Int

val isoDayOfWeek: Int

val hour: Int

val minute: Int

val second: Int

fun cast() : T

fun plusDays(days: Int): CronDateTime<T>

fun minusDays(days: Int): CronDateTime<T>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.ucasoft.kcron.abstractions

interface CronDateTimeProvider<T, out D> where D: CronDateTime<T> {

fun now(): D

fun from(year: Int, month: Int, day: Int, hours: Int = 0, minutes: Int = 0, seconds: Int = 0): D

fun from(original: T) : D
}
43 changes: 43 additions & 0 deletions kcron-common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
plugins {
alias(libs.plugins.multiplatform)
id("publish")
}

kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
linuxX64()
linuxArm64()
mingwX64()
macosX64()
macosArm64()
js(IR) {
browser()
nodejs()
}
iosX64()
iosArm64()
iosSimulatorArm64()
sourceSets {
commonMain {
dependencies {
implementation(project(":kcron-core"))
implementation(project(":kcron-kotlinx-datetime"))
}
}
commonTest {
dependencies {
implementation(kotlin("test"))
implementation(libs.kotest.assetions)
}
}
}
}

libraryData {
name.set("KCron Common")
description.set("Cron realization for Kotlin Multiplatform with Kotlinx DateTime Provider")
}
Loading
Loading