Skip to content

Commit e75eff3

Browse files
authored
feat: Update to [email protected], set up Dokka and publishing (#15)
<!-- Please use this template for your pull request. --> <!-- Please use the sections that you need and delete other sections --> ## This PR - Upgrades to the first Multiplatform-compatible Kotlin SDK version, which allows the CI to finally pass. - Sets up Dokka and publishing (using the [Gradle Maven Publish Plugin by vanniktech](https://vanniktech.github.io/gradle-maven-publish-plugin/)) similar to open-feature/kotlin-sdk#166 ### Follow-up Tasks Release Please can eventually be set up after this (#2). ### How to test <!-- if applicable, add testing instructions under this section --> The CI should pass for the first time. The publishing can be tested with `./gradlew publishToMavenLocal`. It should create the artifacts of the env-var provider under `~/.m2/repository/dev/openfeature/kotlin/contrib/providers/`. --------- Signed-off-by: Bence Hornák <[email protected]>
1 parent e69e9e8 commit e75eff3

File tree

13 files changed

+181
-35
lines changed

13 files changed

+181
-35
lines changed

buildSrc/build.gradle.kts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
dependencies {
6+
implementation(plugin(libs.plugins.binary.compatibility.validator))
7+
implementation(plugin(libs.plugins.ktlint))
8+
implementation(plugin(libs.plugins.kotlin.multiplatform))
9+
implementation(plugin(libs.plugins.dokka))
10+
implementation(plugin(libs.plugins.vanniktech.maven.publish))
11+
}
12+
13+
/**
14+
* Helper function that transforms a Gradle Plugin alias from a Version Catalog into a valid
15+
* dependency notation for buildSrc. Taken from
16+
* https://docs.gradle.org/current/userguide/version_catalogs.html#sec:buildsrc-version-catalog
17+
*/
18+
private fun DependencyHandlerScope.plugin(plugin: Provider<PluginDependency>) =
19+
plugin.map { "${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version}" }

buildSrc/gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Enable the v2 syntax of the Dokka Gradle Plugin
2+
# https://kotlinlang.org/docs/dokka-migration.html
3+
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
4+
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true

buildSrc/settings.gradle.kts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
pluginManagement {
2+
repositories {
3+
google()
4+
mavenCentral()
5+
gradlePluginPortal()
6+
}
7+
}
8+
9+
dependencyResolutionManagement {
10+
repositories {
11+
google()
12+
mavenLocal()
13+
mavenCentral()
14+
gradlePluginPortal()
15+
}
16+
17+
versionCatalogs {
18+
create("libs") {
19+
from(files("../gradle/libs.versions.toml"))
20+
}
21+
}
22+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import com.vanniktech.maven.publish.JavadocJar
2+
import com.vanniktech.maven.publish.KotlinMultiplatform
3+
4+
plugins {
5+
id("org.jetbrains.kotlin.multiplatform")
6+
id("org.jetbrains.kotlinx.binary-compatibility-validator")
7+
id("org.jlleitschuh.gradle.ktlint")
8+
id("com.vanniktech.maven.publish")
9+
id("org.jetbrains.dokka")
10+
}
11+
12+
// Configure Dokka for documentation
13+
dokka {
14+
dokkaPublications.html {
15+
suppressInheritedMembers.set(true)
16+
failOnWarning.set(true)
17+
}
18+
dokkaSourceSets.commonMain {
19+
sourceLink {
20+
localDirectory.set(file("src/"))
21+
remoteUrl("https://github.com/open-feature/kotlin-sdk/tree/main/kotlin-sdk/src")
22+
remoteLineSuffix.set("#L")
23+
}
24+
}
25+
}
26+
27+
mavenPublishing {
28+
configure(
29+
KotlinMultiplatform(
30+
javadocJar = JavadocJar.Dokka("dokkaGeneratePublicationHtml"),
31+
sourcesJar = true,
32+
androidVariantsToPublish = listOf("release")
33+
)
34+
)
35+
signAllPublications()
36+
coordinates(
37+
groupId = "dev.openfeature.kotlin.contrib.providers",
38+
version = findProperty("version").toString()
39+
)
40+
pom {
41+
url.set("https://openfeature.dev")
42+
licenses {
43+
license {
44+
name.set("The Apache License, Version 2.0")
45+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
46+
}
47+
}
48+
developers {
49+
developer {
50+
id.set("vahidlazio")
51+
name.set("Vahid Torkaman")
52+
email.set("[email protected]")
53+
}
54+
developer {
55+
id.set("fabriziodemaria")
56+
name.set("Fabrizio Demaria")
57+
email.set("[email protected]")
58+
}
59+
developer {
60+
id.set("nicklasl")
61+
name.set("Nicklas Lundin")
62+
email.set("[email protected]")
63+
}
64+
developer {
65+
id.set("nickybondarenko")
66+
name.set("Nicky Bondarenko")
67+
email.set("[email protected]")
68+
}
69+
developer {
70+
id.set("bencehornak")
71+
name.set("Bence Hornák")
72+
email.set("[email protected]")
73+
}
74+
}
75+
scm {
76+
connection.set(
77+
"scm:git:https://github.com/open-feature/kotlin-sdk-contrib.git"
78+
)
79+
developerConnection.set(
80+
"scm:git:ssh://open-feature/kotlin-sdk-contrib.git"
81+
)
82+
url.set("https://github.com/open-feature/kotlin-sdk-contrib")
83+
}
84+
}
85+
}
86+

gradle.properties

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
version=0.1.0
12
org.gradle.configuration-cache=true
23

34
# This seems to be necessary for Coroutines to work on JS. Otherwise getting the following error:
45
# > Task :providers:env-var:compileTestDevelopmentExecutableKotlinJs FAILED
56
# e: java.lang.IllegalStateException: IC internal error: can not find library org.jetbrains.kotlin:kotlinx-atomicfu-runtime
6-
kotlinx.atomicfu.enableJsIrTransformation=true
7+
kotlinx.atomicfu.enableJsIrTransformation=true
8+
9+
# Enable the v2 syntax of the Dokka Gradle Plugin
10+
# https://kotlinlang.org/docs/dokka-migration.html
11+
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
12+
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true

gradle/libs.versions.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[versions]
22
kotlin = "2.1.21"
33
kotlinx-coroutines = "1.10.2"
4-
open-feature-kotlin-sdk = "0.4.1"
4+
open-feature-kotlin-sdk = "0.6.2"
55

66
[libraries]
77
openfeature-kotlin-sdk = { group="dev.openfeature", name="kotlin-sdk", version.ref="open-feature-kotlin-sdk" }
@@ -10,8 +10,10 @@ kotlinx-coroutines-core = { group="org.jetbrains.kotlinx", name="kotlinx-corouti
1010
kotlinx-coroutines-test = { group="org.jetbrains.kotlinx", name="kotlinx-coroutines-test", version.ref="kotlinx-coroutines" }
1111

1212
[plugins]
13+
dokka = { id="org.jetbrains.dokka", version="2.0.0" }
1314
kotlin-multiplatform = { id="org.jetbrains.kotlin.multiplatform", version.ref="kotlin" }
1415
kotlinx-atomicfu = { id="org.jetbrains.kotlinx.atomicfu", version="0.27.0" }
1516
ktlint = { id="org.jlleitschuh.gradle.ktlint", version="12.3.0" }
1617
nexus-publish = { id="io.github.gradle-nexus.publish-plugin", version="2.0.0" }
17-
binary-compatibility-validator = { id="org.jetbrains.kotlinx.binary-compatibility-validator", version="0.17.0" }
18+
binary-compatibility-validator = { id="org.jetbrains.kotlinx.binary-compatibility-validator", version="0.17.0" }
19+
vanniktech-maven-publish = { id="com.vanniktech.maven.publish", version="0.34.0" }

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

providers/env-var/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Environment Variables Kotlin Provider
22

3-
Environment Variables provider allows you to read feature flags from the [process's environment](https://en.wikipedia.org/wiki/Environment_variable).
3+
The Environment Variables provider allows you to read feature flags from the [process's environment](https://en.wikipedia.org/wiki/Environment_variable).
44

55
## Supported platforms
66

providers/env-var/api/env-var.api

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
public final class dev/openfeature/kotlin/contrib/providers/envvar/EnvVarProvider : dev/openfeature/sdk/FeatureProvider {
1+
public final class dev/openfeature/kotlin/contrib/providers/envvar/EnvVarProvider : dev/openfeature/kotlin/sdk/FeatureProvider {
22
public static final field Companion Ldev/openfeature/kotlin/contrib/providers/envvar/EnvVarProvider$Companion;
33
public fun <init> ()V
44
public fun <init> (Ldev/openfeature/kotlin/contrib/providers/envvar/EnvironmentGateway;Ldev/openfeature/kotlin/contrib/providers/envvar/EnvironmentKeyTransformer;)V
55
public synthetic fun <init> (Ldev/openfeature/kotlin/contrib/providers/envvar/EnvironmentGateway;Ldev/openfeature/kotlin/contrib/providers/envvar/EnvironmentKeyTransformer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
6-
public fun getBooleanEvaluation (Ljava/lang/String;ZLdev/openfeature/sdk/EvaluationContext;)Ldev/openfeature/sdk/ProviderEvaluation;
7-
public fun getDoubleEvaluation (Ljava/lang/String;DLdev/openfeature/sdk/EvaluationContext;)Ldev/openfeature/sdk/ProviderEvaluation;
6+
public fun getBooleanEvaluation (Ljava/lang/String;ZLdev/openfeature/kotlin/sdk/EvaluationContext;)Ldev/openfeature/kotlin/sdk/ProviderEvaluation;
7+
public fun getDoubleEvaluation (Ljava/lang/String;DLdev/openfeature/kotlin/sdk/EvaluationContext;)Ldev/openfeature/kotlin/sdk/ProviderEvaluation;
88
public fun getHooks ()Ljava/util/List;
9-
public fun getIntegerEvaluation (Ljava/lang/String;ILdev/openfeature/sdk/EvaluationContext;)Ldev/openfeature/sdk/ProviderEvaluation;
10-
public fun getMetadata ()Ldev/openfeature/sdk/ProviderMetadata;
11-
public fun getObjectEvaluation (Ljava/lang/String;Ldev/openfeature/sdk/Value;Ldev/openfeature/sdk/EvaluationContext;)Ldev/openfeature/sdk/ProviderEvaluation;
12-
public fun getStringEvaluation (Ljava/lang/String;Ljava/lang/String;Ldev/openfeature/sdk/EvaluationContext;)Ldev/openfeature/sdk/ProviderEvaluation;
13-
public fun initialize (Ldev/openfeature/sdk/EvaluationContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
9+
public fun getIntegerEvaluation (Ljava/lang/String;ILdev/openfeature/kotlin/sdk/EvaluationContext;)Ldev/openfeature/kotlin/sdk/ProviderEvaluation;
10+
public fun getMetadata ()Ldev/openfeature/kotlin/sdk/ProviderMetadata;
11+
public fun getObjectEvaluation (Ljava/lang/String;Ldev/openfeature/kotlin/sdk/Value;Ldev/openfeature/kotlin/sdk/EvaluationContext;)Ldev/openfeature/kotlin/sdk/ProviderEvaluation;
12+
public fun getStringEvaluation (Ljava/lang/String;Ljava/lang/String;Ldev/openfeature/kotlin/sdk/EvaluationContext;)Ldev/openfeature/kotlin/sdk/ProviderEvaluation;
13+
public fun initialize (Ldev/openfeature/kotlin/sdk/EvaluationContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
1414
public fun observe ()Lkotlinx/coroutines/flow/Flow;
15-
public fun onContextSet (Ldev/openfeature/sdk/EvaluationContext;Ldev/openfeature/sdk/EvaluationContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
15+
public fun onContextSet (Ldev/openfeature/kotlin/sdk/EvaluationContext;Ldev/openfeature/kotlin/sdk/EvaluationContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
1616
public fun shutdown ()V
17-
public fun track (Ljava/lang/String;Ldev/openfeature/sdk/EvaluationContext;Ldev/openfeature/sdk/TrackingEventDetails;)V
17+
public fun track (Ljava/lang/String;Ldev/openfeature/kotlin/sdk/EvaluationContext;Ldev/openfeature/kotlin/sdk/TrackingEventDetails;)V
1818
}
1919

2020
public final class dev/openfeature/kotlin/contrib/providers/envvar/EnvVarProvider$Companion {

providers/env-var/build.gradle.kts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
33
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
44

55
plugins {
6-
alias(libs.plugins.kotlin.multiplatform)
7-
alias(libs.plugins.binary.compatibility.validator)
8-
alias(libs.plugins.ktlint)
6+
id("dev.openfeature.provider-conventions")
97
// Needed for the JS coroutine support for the tests
108
alias(libs.plugins.kotlinx.atomicfu)
119
}
@@ -37,6 +35,15 @@ kotlin {
3735
}
3836
}
3937

38+
mavenPublishing {
39+
pom {
40+
name.set("OpenFeature Environment Variables Kotlin Provider")
41+
description.set(
42+
"The Environment Variables provider allows you to read feature flags from the process's environment.",
43+
)
44+
}
45+
}
46+
4047
// Set test environment variable for tests
4148
// Used in ./commonTest/kotlin/dev/openfeature/kotlin/contrib/providers/envvar/PlatformSpecificEnvironmentGatewayTest.kt
4249
val testEnvironmentVariable = "TEST_ENVIRONMENT_VARIABLE" to "foo"

0 commit comments

Comments
 (0)