Skip to content

Commit dc92ee6

Browse files
Add no-op support for JVM / JS targets (#102)
1 parent b6556f1 commit dc92ee6

12 files changed

Lines changed: 2319 additions & 1 deletion

File tree

‎.github/workflows/build.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: build
2-
#on: workflow_dispatch
2+
33
on:
44
pull_request:
55
branches:

‎bugsnag/build.gradle.kts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* or implied. See the License for the specific language governing permissions and limitations under
1111
* the License.
1212
*/
13+
1314
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1415

1516
plugins {
@@ -38,6 +39,17 @@ kotlin {
3839
}
3940
}
4041

42+
jvm {
43+
compilerOptions {
44+
jvmTarget.set(JvmTarget.JVM_1_8)
45+
}
46+
}
47+
48+
js {
49+
nodejs()
50+
browser()
51+
}
52+
4153
macosX64()
4254
macosArm64()
4355
iosX64()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package co.touchlab.crashkios.bugsnag
2+
3+
/**
4+
* No-op implementation for targets without a Bugsnag SDK. Lets CrashKiOS be declared once in
5+
* `commonMain` in projects that also target JS.
6+
*/
7+
actual class BugsnagCallsActual : BugsnagCalls {
8+
actual override fun logMessage(message: String) {
9+
}
10+
11+
actual override fun sendHandledException(throwable: Throwable) {
12+
}
13+
14+
actual override fun sendFatalException(throwable: Throwable) {
15+
}
16+
17+
actual override fun setCustomValue(section: String, key: String, value: Any) {
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package co.touchlab.crashkios.bugsnag
2+
3+
/**
4+
* No-op implementation for targets without a Bugsnag SDK. Lets CrashKiOS be declared once in
5+
* `commonMain` in projects that also target JVM.
6+
*/
7+
actual class BugsnagCallsActual : BugsnagCalls {
8+
actual override fun logMessage(message: String) {
9+
}
10+
11+
actual override fun sendHandledException(throwable: Throwable) {
12+
}
13+
14+
actual override fun sendFatalException(throwable: Throwable) {
15+
}
16+
17+
actual override fun setCustomValue(section: String, key: String, value: Any) {
18+
}
19+
}

‎core/build.gradle.kts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ kotlin {
3838
}
3939
}
4040

41+
jvm {
42+
compilerOptions {
43+
jvmTarget.set(JvmTarget.JVM_1_8)
44+
}
45+
}
46+
47+
js {
48+
nodejs()
49+
browser()
50+
}
51+
4152
macosX64()
4253
macosArm64()
4354
iosX64()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package co.touchlab.crashkios.core
2+
3+
import kotlin.reflect.KProperty
4+
5+
actual class ThreadSafeVar<T> actual constructor(private var target: T) {
6+
actual operator fun getValue(thisRef: Any?, property: KProperty<*>): T = target
7+
8+
actual operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {
9+
target = value
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package co.touchlab.crashkios.core
2+
3+
import kotlin.reflect.KProperty
4+
5+
actual class ThreadSafeVar<T> actual constructor(@Volatile private var target: T) {
6+
actual operator fun getValue(thisRef: Any?, property: KProperty<*>): T = target
7+
8+
actual operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {
9+
target = value
10+
}
11+
}

‎crashlytics/build.gradle.kts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* or implied. See the License for the specific language governing permissions and limitations under
1111
* the License.
1212
*/
13+
1314
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1415

1516
plugins {
@@ -38,6 +39,17 @@ kotlin {
3839
}
3940
}
4041

42+
jvm {
43+
compilerOptions {
44+
jvmTarget.set(JvmTarget.JVM_1_8)
45+
}
46+
}
47+
48+
js {
49+
nodejs()
50+
browser()
51+
}
52+
4153
macosX64()
4254
macosArm64()
4355
iosX64()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package co.touchlab.crashkios.crashlytics
2+
3+
/**
4+
* No-op implementation for targets without a Crashlytics SDK. Lets CrashKiOS be declared once in
5+
* `commonMain` in projects that also target JS.
6+
*/
7+
actual class CrashlyticsCallsActual : CrashlyticsCalls {
8+
actual override fun logMessage(message: String) {
9+
}
10+
11+
actual override fun sendHandledException(throwable: Throwable) {
12+
}
13+
14+
actual override fun sendFatalException(throwable: Throwable) {
15+
}
16+
17+
actual override fun setCustomValue(key: String, value: Any) {
18+
}
19+
20+
actual override fun setUserId(identifier: String) {
21+
}
22+
23+
actual override fun setCollectionEnabled(enabled: Boolean) {
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package co.touchlab.crashkios.crashlytics
2+
3+
/**
4+
* No-op implementation for targets without a Crashlytics SDK. Lets CrashKiOS be declared once in
5+
* `commonMain` in projects that also target JVM.
6+
*/
7+
actual class CrashlyticsCallsActual : CrashlyticsCalls {
8+
actual override fun logMessage(message: String) {
9+
}
10+
11+
actual override fun sendHandledException(throwable: Throwable) {
12+
}
13+
14+
actual override fun sendFatalException(throwable: Throwable) {
15+
}
16+
17+
actual override fun setCustomValue(key: String, value: Any) {
18+
}
19+
20+
actual override fun setUserId(identifier: String) {
21+
}
22+
23+
actual override fun setCollectionEnabled(enabled: Boolean) {
24+
}
25+
}

0 commit comments

Comments
 (0)