Skip to content

Commit

Permalink
Setting for publication and README change
Browse files Browse the repository at this point in the history
  • Loading branch information
svok committed Apr 20, 2024
1 parent 14b2d1f commit f805579
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
- name: Run Tests
uses: gradle/gradle-build-action@v2
with:
arguments: allTests
arguments: check -i
15 changes: 7 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ jobs:
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Decode
run: |
mkdir -p ~/.gradle
echo "${{secrets.OSSRH_SIGNING_SECRET_KEY_RING_FILE}}" > ~/.gradle/secring.gpg.b64
base64 -d ~/.gradle/secring.gpg.b64 > ~/.gradle/secring.gpg
- name: Publish package
run: ./gradlew --stacktrace deploy -Psigning.keyId=${{secrets.OSSRH_SIGNING_KEY_ID}} -Psigning.password='${{secrets.OSSRH_GPG_SECRET_KEY_PASSWORD}}' -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.gpg)
- name: Publish
uses: gradle/gradle-build-action@v2
with:
arguments: deploy
env:
SIGNING_KEY_ID: ${{ secrets.OSSRH_SIGNING_KEY_ID }}
SIGNING_KEY: ${{ secrets.OSSRH_SIGNING_SECRET_KEY_RING_FILE }}
SIGNING_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
NEXUS_HOST: ${{ secrets.OSSRH_HOST }}
NEXUS_USER: ${{ secrets.OSSRH_USER }}
NEXUS_PASS: ${{ secrets.OSSRH_PASS }}
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b

- name: Test package
run: gradle allTests
run: gradle check -i

- name: Report unit tests
uses: dorny/test-reporter@v1
Expand Down
62 changes: 49 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,48 @@ bizLogics.exec(ctx)
assertEquals(expected, ctx.objResponse)
```

Other option includes also custom settings of the pipeline that can be used during initialization and processing:

```kotlin
val settings = BizSettings(
repo = PostgresRepo(),
loggerProvider = { clazz: String -> LoggerFactory.getLogger(clazz) },
)
val bizLogics = rootChain<BizContext, CorSettings>(settings) {
readObject("Object reading from DB")
}
fun ICorDslAdd<BizContext, BizSettings>.readObject(title: String) = worker {
this.title = title
this.description = """
This worker handles reading object in question from DB.
The mandatory parameter is ID
"""
// Getting content of BizSettings to this.config,
// so that logger initialized during configuration step
val logger = this.config.loggerProvider("readObject")
on { state == RUNNING }
handle {
// But we can use logger in runtime area
logger.info("Handling $title")
objectRead = config.repo.read(this.toReadRequest())
}
except { e: Throwable ->
fail(e.toError())
logger.error("Error reading object from DB", e)
}
}
```

Such a representation of the business logics has the following advantages.

1. It is optimized for human readability. So, any developer will easily find the required operation.
2. It is extremely agile and allows easily change the business process without substantial refactoring.
3. Provides "code first" approach that is better suit the needs of developers.
2. It is extremely agile and allows easy change of the business process without substantial refactoring.
3. Provides "code first" approach that better suits the needs of developers.

### CoR vs BPMS

BPMS engines provide a "declaration first" approach where business logics is developed in a visual designer. This is
may be very convenient for analysts, architects or manager but brings few disadvantages to developers. The main problem
BPMS engines provide a "declaration first" approach where business logics is developed in a visual designer. This
may be very convenient for analysts, architects or managers but brings few disadvantages to developers. The main problem
is current engines use a schema: Visual Editor -> xml spec -> code.

1. This means that developers do not control the code. Any change by an analyst to BPM schema may break your application
Expand All @@ -50,10 +82,16 @@ is current engines use a schema: Visual Editor -> xml spec -> code.

This CoR library doesn't compete with BPM as is. But it allows developers to control the code themselves.

Compatibility between BPM and CoR is planned.
Compatibility between BPM code generators and CoR is planned.

## Installation

#### **`libs.versions.toml`**
```toml
[libraries]
cor = "com.crowdproj:kotlin-cor:0.6.0"
```

#### **`build.gradle.kts`**

```kotlin
Expand All @@ -62,23 +100,17 @@ repositories {
}

dependencies {
val kotlinCorVersion: String by project
implementation("com.crowdproj:kotlin-cor:$kotlinCorVersion")
implementation(libs.cor)
}
```

#### **`gradle.properties`**

```properties
kotlinCorVersion=0.6.0+
```

## Usage

First, build a business chain

```kotlin
val chain = rootChain<TestContext> {
// This is a simple worker
worker {
title = "Status initialization"
description = "Check the status initialization at the buziness chain start"
Expand All @@ -88,6 +120,7 @@ val chain = rootChain<TestContext> {
except { status = CorStatuses.FAILING }
}

// Chain wraps a series of workers
chain {
on { status == CorStatuses.RUNNING }

Expand All @@ -99,6 +132,7 @@ val chain = rootChain<TestContext> {
}
}

// Nearly the same as `chain` but workers executed in parallel, so the order between them is not guaranteed
parallel {
on {
some < 15
Expand All @@ -108,6 +142,8 @@ val chain = rootChain<TestContext> {
some++
}
}
// You can represent your workers and chains as Kotlin extensions
// In this form they look more compact and easier
printResult()

}.build()
Expand Down
56 changes: 17 additions & 39 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
kotlin("multiplatform")
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.plugin.dokka)
`maven-publish`
id("signing")
id("org.jetbrains.dokka")
id("io.codearte.nexus-staging")
signing
}

group = "com.crowdproj"
Expand All @@ -18,15 +17,14 @@ repositories {
}

signing {
useInMemoryPgpKeys(
System.getenv("SIGNING_KEY_ID"),
System.getenv("SIGNING_KEY"),
System.getenv("SIGNING_PASSWORD")
)
sign(publishing.publications)
}

nexusStaging {
serverUrl = "https://s01.oss.sonatype.org/service/local/"
packageGroup = "com.crowdproj" //optional if packageGroup == project.getGroup()
// stagingProfileId = "yourStagingProfileId" //when not defined will be got from server using "packageGroup"
}

kotlin {
js {
browser()
Expand Down Expand Up @@ -54,28 +52,25 @@ kotlin {
mingwX64()

sourceSets {
val coroutinesVersion: String by project
val atomicfuVersion: String by project

all { languageSettings.optIn("kotlin.RequiresOptIn") }

commonMain {
val commonMain by getting {
dependencies {
implementation(kotlin("stdlib-common"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
implementation(libs.coroutines.core)
}
}

commonTest {
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion")
implementation("org.jetbrains.kotlinx:atomicfu:$atomicfuVersion")
implementation(libs.coroutines.test)
implementation(libs.atomicfu)
}
}

jsTest {
val jsTest by getting {
dependencies {
implementation(kotlin("test"))
}
Expand All @@ -87,7 +82,7 @@ kotlin {
}
}

jvmTest {
val jvmTest by getting {
dependencies {
implementation(kotlin("test"))
}
Expand All @@ -96,12 +91,11 @@ kotlin {
}

val dokkaHtml by tasks.getting(org.jetbrains.dokka.gradle.DokkaTask::class)

val javadocJar: TaskProvider<Jar> by tasks.registering(Jar::class) {
dependsOn(dokkaHtml)
group = "publishing"
group = JavaBasePlugin.DOCUMENTATION_GROUP
archiveClassifier.set("javadoc")
from(dokkaHtml.outputDirectory)
from(dokkaHtml)
}

publishing {
Expand All @@ -119,7 +113,6 @@ publishing {
}
}
}

}
publications {
withType(MavenPublication::class).configureEach {
Expand Down Expand Up @@ -158,31 +151,16 @@ publishing {
}

tasks {
closeAndReleaseRepository {
dependsOn(publish)
}

withType<Test> {
reports {
junitXml.required.set(true)
}
setupTestLogging()
}

withType<AbstractPublishToMaven>().configureEach {
mustRunAfter(withType<Sign>())
}

filter { it.name.startsWith("link") || it.name.startsWith("compile") }.forEach {
it.name {
mustRunAfter(withType<Sign>())
}
}

publish {
dependsOn(build)
}

create("deploy") {
group = "build"
dependsOn(publish)
Expand Down
8 changes: 0 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
kotlinVersion=1.9.23
dokkaVersion=1.9.20

coroutinesVersion=1.8.0
atomicfuVersion=0.23.2
nexusStagingVersion=0.30.0

# -native-mt
15 changes: 15 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[versions]
kotlin = "1.9.23"
dokka = "1.9.20"
nexus-publish-plugin = "2.0.0"

coroutines = "1.8.0"

[libraries]
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version = "0.23.2" }

[plugins]
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
plugin-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
13 changes: 0 additions & 13 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@
rootProject.name = "kotlin-cor"

pluginManagement {
plugins {
val kotlinVersion: String by settings
val dokkaVersion: String by settings
val nexusStagingVersion: String by settings

kotlin("multiplatform") version kotlinVersion
`maven-publish`
id("org.jetbrains.dokka") version dokkaVersion
id("io.codearte.nexus-staging") version nexusStagingVersion
}
}

0 comments on commit f805579

Please sign in to comment.