@@ -10,6 +10,7 @@ android {
10
10
targetSdkVersion 29
11
11
versionCode 1
12
12
versionName " 1.0"
13
+ testInstrumentationRunner " androidx.test.runner.AndroidJUnitRunner"
13
14
}
14
15
buildTypes {
15
16
release {
@@ -37,8 +38,15 @@ kotlin {
37
38
embedBitcode(" disable" )
38
39
linkerOpts(" -F$projectDir /../Carthage/Build/iOS" )
39
40
}
41
+ getTest(" DEBUG" ). linkerOpts(" -F../Carthage/Build/iOS" , " -framework" , " GCDWebServers" )
42
+ // getTest("DEBUG").linkerOpts.add("-framework GCDWebServers".toString())
43
+ // getTest("DEBUG").linkerOpts.add("-F../Carthage/Build/iOS".toString())
44
+ // getTest("DEBUG").freeCompilerArgs.add("-framework GCDWebServers".toString())
40
45
}
41
46
47
+ // [compilations.main, compilations.test].each {
48
+ // it.cinterops {
49
+ // }
42
50
compilations. main. cinterops {
43
51
gcdWebServer {
44
52
defFile(" gcdWebServer.def" )
@@ -60,29 +68,64 @@ kotlin {
60
68
}
61
69
}
62
70
63
- // posixMain {
64
- // kotlin.srcDir("src/posix/kotlin")
65
- // dependencies {
66
- // implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core-native', version: "1.3.4"
67
- // }
68
- // }
71
+ commonTest {
72
+ dependencies {
73
+ implementation ' org.jetbrains.kotlin:kotlin-test-common'
74
+ implementation ' org.jetbrains.kotlin:kotlin-test-annotations-common'
75
+ implementation ' io.ktor:ktor-client-core:1.3.2'
76
+ implementation ' org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
77
+ }
78
+ }
69
79
70
80
androidMain {
71
- dependencies {
72
- implementation ' org.jetbrains.kotlin:kotlin-stdlib'
73
- implementation ' com.squareup.okhttp3:mockwebserver:4.4.0'
74
- api ' com.squareup.okio:okio:2.6.0' // needed because of actual typalias Data
75
- }
81
+ dependencies {
82
+ implementation ' org.jetbrains.kotlin:kotlin-stdlib'
83
+ implementation ' com.squareup.okhttp3:mockwebserver:4.4.0'
84
+ api ' com.squareup.okio:okio:2.6.0' // needed because of actual typalias Data
85
+ }
86
+ }
87
+
88
+ androidTest {
89
+ dependencies {
90
+ implementation ' org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.7'
91
+ implementation ' androidx.test.ext:junit:1.1.1'
92
+ }
76
93
}
77
94
78
- iosMain {
79
- // kotlin.srcDirs('src/posix/kotlin')
80
- // dependsOn posixMain
95
+ iosTest {
96
+ dependencies {
97
+ implementation ' org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.7'
98
+ implementation ' io.ktor:ktor-client-ios:1.3.2'
99
+ }
81
100
}
82
101
83
- // macOsMain {
84
- // kotlin.srcDirs('src/iOSMain/kotlin')
85
- // // dependsOn posixMain
86
- // }
87
102
}
88
- }
103
+ }
104
+
105
+ def testOutputFile () {
106
+ return kotlin. targets[" iosX64" ]. binaries. getTest(' DEBUG' ). outputFile
107
+ }
108
+
109
+ task copyGCDWebServers (type : Copy ) {
110
+ def testDir = testOutputFile(). parentFile. absolutePath
111
+ def path = " $testDir /Frameworks/GCDWebServers.framework"
112
+
113
+ from " $projectDir /../Carthage/Build/iOS/GCDWebServers.framework"
114
+ into path
115
+ }
116
+
117
+ task iosTest {
118
+ dependsOn ' linkDebugTestIosX64'
119
+ group = JavaBasePlugin . VERIFICATION_GROUP
120
+ description = " Runs tests for target 'ios' on an iOS simulator"
121
+
122
+ doLast {
123
+ def binary = testOutputFile(). absolutePath
124
+ exec {
125
+ commandLine ' xcrun' , ' simctl' , ' spawn' , ' booted' , binary
126
+ }
127
+ }
128
+ }
129
+
130
+ iosTest. dependsOn copyGCDWebServers
131
+ copyGCDWebServers. mustRunAfter(linkDebugTestIosX64)
0 commit comments