Skip to content

Commit

Permalink
Merge pull request #146 from Angel-Studios/for-upstream-1
Browse files Browse the repository at this point in the history
Add support for compiling to Kotlin/JS targets
  • Loading branch information
vazarkevych authored Nov 7, 2024
2 parents a974b31 + c3554af commit 985a450
Show file tree
Hide file tree
Showing 19 changed files with 4,301 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main-without-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Gradle clean
run: ./gradlew clean --info
- name: Build with Gradle
run: ./gradlew :DefaultNetworkDispatcher:build :GrowthBook:build --info
run: ./gradlew kotlinUpgradeYarnLock :DefaultNetworkDispatcher:build :GrowthBook:build --info
# - name: release
# uses: actions/create-release@v1
# id: create_release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Gradle clean
run: ./gradlew clean --info
- name: Build with Gradle
run: ./gradlew -Pversion=$LIB_VERSION :GrowthBook:build --info
run: ./gradlew -Pversion=$LIB_VERSION kotlinUpgradeYarnLock :GrowthBook:build --info
- name: release
uses: actions/create-release@v1
id: create_release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-core-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
run: ./gradlew -Pversion=$CORE_MODULE_VERSION :Core:build --info
- name: Publish to maven central
run: |
GPG_PRIVATE_KEY="${{secrets.GPG_PRIVATE_KEY}}" GPG_PRIVATE_PASSWORD="${{secrets.GPG_PRIVATE_PASSWORD}}" GB_SONATYPE_USERNAME='${{secrets.GB_SONATYPE_USERNAME}}' GB_SONATYPE_PASSWORD='${{secrets.GB_SONATYPE_PASSWORD}}' ./gradlew -Pversion=$CORE_MODULE_VERSION :Core:publish
GPG_PRIVATE_KEY="${{secrets.GPG_PRIVATE_KEY}}" GPG_PRIVATE_PASSWORD="${{secrets.GPG_PRIVATE_PASSWORD}}" GB_SONATYPE_USERNAME='${{secrets.GB_SONATYPE_USERNAME}}' GB_SONATYPE_PASSWORD='${{secrets.GB_SONATYPE_PASSWORD}}' ./gradlew -Pversion=$CORE_MODULE_VERSION kotlinUpgradeYarnLock :Core:publish
2 changes: 1 addition & 1 deletion .github/workflows/publish-ktor-dispatcher-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
run: ./gradlew -Pversion=$DISPATCHER_VERSION :NetworkDispatcherKtor:build --info
- name: Publish to maven central
run: |
GPG_PRIVATE_KEY="${{secrets.GPG_PRIVATE_KEY}}" GPG_PRIVATE_PASSWORD="${{secrets.GPG_PRIVATE_PASSWORD}}" GB_SONATYPE_USERNAME='${{secrets.GB_SONATYPE_USERNAME}}' GB_SONATYPE_PASSWORD='${{secrets.GB_SONATYPE_PASSWORD}}' ./gradlew -Pversion=$DISPATCHER_VERSION :NetworkDispatcherKtor:publish
GPG_PRIVATE_KEY="${{secrets.GPG_PRIVATE_KEY}}" GPG_PRIVATE_PASSWORD="${{secrets.GPG_PRIVATE_PASSWORD}}" GB_SONATYPE_USERNAME='${{secrets.GB_SONATYPE_USERNAME}}' GB_SONATYPE_PASSWORD='${{secrets.GB_SONATYPE_PASSWORD}}' ./gradlew -Pversion=$DISPATCHER_VERSION kotlinUpgradeYarnLock :NetworkDispatcherKtor:publish
2 changes: 1 addition & 1 deletion .github/workflows/publish-okhttp-dispatcher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
run: ./gradlew -Pversion=$DISPATCHER_VERSION :NetworkDispatcherOkHttp:build --info
- name: Publish to maven central
run: |
GPG_PRIVATE_KEY="${{secrets.GPG_PRIVATE_KEY}}" GPG_PRIVATE_PASSWORD="${{secrets.GPG_PRIVATE_PASSWORD}}" GB_SONATYPE_USERNAME='${{secrets.GB_SONATYPE_USERNAME}}' GB_SONATYPE_PASSWORD='${{secrets.GB_SONATYPE_PASSWORD}}' ./gradlew -Pversion=$DISPATCHER_VERSION :NetworkDispatcherOkHttp:publish
GPG_PRIVATE_KEY="${{secrets.GPG_PRIVATE_KEY}}" GPG_PRIVATE_PASSWORD="${{secrets.GPG_PRIVATE_PASSWORD}}" GB_SONATYPE_USERNAME='${{secrets.GB_SONATYPE_USERNAME}}' GB_SONATYPE_PASSWORD='${{secrets.GB_SONATYPE_PASSWORD}}' ./gradlew -Pversion=$DISPATCHER_VERSION kotlinUpgradeYarnLock :NetworkDispatcherOkHttp:publish
2 changes: 1 addition & 1 deletion .github/workflows/upload-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Gradle clean
run: ./gradlew clean --info
- name: Build with Gradle
run: ./gradlew -Pversion=${{ env.LIB_VERSION }} build --info
run: ./gradlew -Pversion=${{ env.LIB_VERSION }} kotlinUpgradeYarnLock build --info
- name: release
uses: actions/create-release@v1
id: create_release
Expand Down
26 changes: 24 additions & 2 deletions Core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,20 +1,38 @@
import com.android.build.gradle.internal.utils.publishingFeatureOptIn
import org.gradle.kotlin.dsl.support.kotlinCompilerOptions
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackOutput
import org.jetbrains.kotlin.gradle.targets.js.yarn.yarn

plugins {
kotlin("multiplatform")
id("com.android.library")
kotlin("plugin.serialization")
id("maven-publish")
id("signing")
id("org.jetbrains.dokka") version "1.8.10"
id("org.jetbrains.dokka") version "1.9.10"
}

group = "io.growthbook.sdk"
version = "1.0.2"

kotlin {
android {
androidTarget {
publishLibraryVariants("release")
}

js {
yarn.lockFileDirectory = file("kotlin-js-store")
browser {
commonWebpackConfig {
output = KotlinWebpackOutput(
library = project.name,
libraryTarget = KotlinWebpackOutput.Target.UMD,
globalObject = KotlinWebpackOutput.Target.WINDOW
)
}
}
}

jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
Expand Down Expand Up @@ -48,6 +66,10 @@ android {
isMinifyEnabled = false
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}

val dokkaOutputDir = "$buildDir/dokka"
Expand Down
8 changes: 8 additions & 0 deletions Core/src/jsMain/kotlin/com/sdk/growthbook/Dispatcher.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.sdk.growthbook

import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers

// 1
actual val PlatformDependentIODispatcher: CoroutineDispatcher =
Dispatchers.Unconfined
28 changes: 24 additions & 4 deletions GrowthBook/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackOutput
import org.jetbrains.kotlin.gradle.targets.js.yarn.yarn

plugins {
kotlin("multiplatform")
id("com.android.library")
kotlin("plugin.serialization")
id("maven-publish")
id("signing")
id("org.jetbrains.dokka") version "1.8.10"
id("org.jetbrains.dokka") version "1.9.10"
}

group = "io.growthbook.sdk"
Expand All @@ -16,10 +19,23 @@ kotlin {
val serializationVersion = "1.3.3"
val kryptoVersion = "2.7.0"

android {
androidTarget {
publishLibraryVariants("release")
}

js {
yarn.lockFileDirectory = file("kotlin-js-store")
browser {
commonWebpackConfig {
output = KotlinWebpackOutput(
library = project.name,
libraryTarget = KotlinWebpackOutput.Target.UMD,
globalObject = KotlinWebpackOutput.Target.WINDOW
)
}
}
}

jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
Expand All @@ -38,7 +54,7 @@ kotlin {
implementation("com.ionspin.kotlin:bignum:0.3.3")
implementation("com.soywiz.korlibs.krypto:krypto:$kryptoVersion")

api("io.growthbook.sdk:Core:1.0.2")
api(project(":Core"))
api(
"org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion"
)
Expand All @@ -60,7 +76,7 @@ kotlin {
implementation("com.soywiz.korlibs.krypto:krypto-android:$kryptoVersion")
}
}
val androidTest by getting {
val androidUnitTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("junit:junit:4.13.2")
Expand Down Expand Up @@ -111,6 +127,10 @@ android {
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}

val dokkaOutputDir = "$buildDir/dokka"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.sdk.growthbook.sandbox

import kotlinx.serialization.json.JsonElement

internal actual object CachingImpl {
actual fun getLayer() : CachingLayer {
return CachingJS()
}
}

internal class CachingJS : CachingLayer {
override fun saveContent(fileName: String, content: JsonElement){

}
override fun getContent(fileName: String) : JsonElement?{
return null
}
}
26 changes: 23 additions & 3 deletions NetworkDispatcherKtor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackOutput
import org.jetbrains.kotlin.gradle.targets.js.yarn.yarn

plugins {
kotlin("multiplatform")
id("com.android.library")
kotlin("plugin.serialization")
id("maven-publish")
id("signing")
id("org.jetbrains.dokka") version "1.8.10"
id("org.jetbrains.dokka") version "1.9.10"
}

group = "io.growthbook.sdk"
Expand All @@ -15,6 +18,19 @@ kotlin {
publishLibraryVariants("release")
}

js {
yarn.lockFileDirectory = file("kotlin-js-store")
browser {
commonWebpackConfig {
output = KotlinWebpackOutput(
library = project.name,
libraryTarget = KotlinWebpackOutput.Target.UMD,
globalObject = KotlinWebpackOutput.Target.WINDOW
)
}
}
}

jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
Expand All @@ -35,15 +51,15 @@ kotlin {
implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion")
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")

implementation("io.growthbook.sdk:Core:1.0.2")
implementation(project(":Core"))
}
}
val androidMain by getting {
dependencies {
implementation("io.ktor:ktor-client-android:$ktorVersion")
}
}
val androidTest by getting {
val androidUnitTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("io.ktor:ktor-client-mock:$ktorVersion")
Expand All @@ -66,6 +82,10 @@ android {
isMinifyEnabled = false
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}

val dokkaOutputDir = "$buildDir/dokka"
Expand Down
Loading

0 comments on commit 985a450

Please sign in to comment.