Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit b82c822

Browse files
authored
Merge pull request #11 from bnorm/bn/multiplatform
Update sample to be a multiplatform project
2 parents 8fe3f11 + f0407e5 commit b82c822

File tree

4 files changed

+122
-23
lines changed

4 files changed

+122
-23
lines changed

sample/build.gradle.kts

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,85 @@
11
buildscript {
22
dependencies {
3-
classpath("gradle.plugin.com.bnorm.power:kotlin-power-assert-gradle:0.2.0")
3+
classpath("gradle.plugin.com.bnorm.power:kotlin-power-assert-gradle:0.3.0")
44
}
55
}
66

77
plugins {
8-
kotlin("jvm") version "1.3.70"
8+
kotlin("multiplatform") version "1.3.70"
99
}
1010
apply(plugin = "com.bnorm.power.kotlin-power-assert")
1111

1212
repositories {
1313
mavenCentral()
1414
}
1515

16-
dependencies {
17-
implementation(kotlin("stdlib-jdk8"))
18-
testImplementation(kotlin("test-junit"))
19-
}
2016

21-
tasks.compileTestKotlin {
22-
kotlinOptions.jvmTarget = "1.8"
23-
kotlinOptions.useIR = true
17+
kotlin {
18+
jvm {
19+
compilations.all {
20+
kotlinOptions {
21+
kotlinOptions.jvmTarget = "1.8"
22+
kotlinOptions.useIR = true
23+
}
24+
}
25+
}
26+
js {
27+
browser()
28+
nodejs()
29+
30+
compilations.all {
31+
kotlinOptions {
32+
kotlinOptions.freeCompilerArgs += listOf("-Xir-produce-klib-dir", "-Xir-produce-js")
33+
}
34+
}
35+
}
36+
37+
val osName = System.getProperty("os.name")
38+
when {
39+
"Windows" in osName -> mingwX64("native")
40+
"Mac OS" in osName -> macosX64("native")
41+
else -> linuxX64("native")
42+
}
43+
44+
sourceSets {
45+
val commonMain by getting {
46+
dependencies {
47+
implementation(kotlin("stdlib"))
48+
}
49+
}
50+
val commonTest by getting {
51+
dependencies {
52+
implementation(kotlin("test-common"))
53+
implementation(kotlin("test-annotations-common"))
54+
}
55+
}
56+
val jvmMain by getting {
57+
dependencies {
58+
implementation(kotlin("stdlib-jdk8"))
59+
}
60+
}
61+
val jvmTest by getting {
62+
dependencies {
63+
implementation(kotlin("test-junit"))
64+
}
65+
}
66+
val jsMain by getting {
67+
dependencies {
68+
implementation(kotlin("stdlib-js"))
69+
}
70+
}
71+
val jsTest by getting {
72+
dependencies {
73+
implementation(kotlin("test-js"))
74+
}
75+
}
76+
val nativeMain by getting {
77+
dependsOn(commonMain)
78+
}
79+
val nativeTest by getting {
80+
dependsOn(commonTest)
81+
}
82+
}
2483
}
2584

2685
configure<com.bnorm.power.PowerAssertGradleExtension> {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (C) 2020 Brian Norman
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.bnorm.power
18+
19+
data class Person(
20+
val firstName: String,
21+
val lastName: String
22+
) {
23+
companion object {
24+
val UNKNOWN = listOf(Person("John", "Doe"), Person("Jane", "Doe"))
25+
}
26+
}

sample/src/test/kotlin/com/bnorm/power/PowerAssertTest.kt renamed to sample/src/commonTest/kotlin/com/bnorm/power/PowerAssertTest.kt

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,14 @@ package com.bnorm.power
1919
import kotlin.test.Test
2020
import kotlin.test.assertTrue
2121

22-
data class Person(
23-
val firstName: String,
24-
val lastName: String
25-
)
26-
2722
class PowerAssertTest {
28-
private val people = listOf(Person("John", "Doe"), Person("Jane", "Doe"))
29-
3023
@Test
3124
fun assertTrue() {
32-
assertTrue(people.size == 1)
33-
}
34-
35-
@Test
36-
fun assert() {
37-
assert(people.size == 1)
25+
assertTrue(Person.UNKNOWN.size == 1)
3826
}
3927

4028
@Test
4129
fun require() {
42-
require(people.size == 1)
30+
require(Person.UNKNOWN.size == 1)
4331
}
4432
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (C) 2020 Brian Norman
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.bnorm.power
18+
19+
import kotlin.test.Test
20+
21+
class JvmPowerAssertTest {
22+
@Test
23+
fun assert() {
24+
assert(Person.UNKNOWN.size == 1)
25+
}
26+
}

0 commit comments

Comments
 (0)