@@ -2,6 +2,8 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
2
2
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
3
3
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions
4
4
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree
5
+ import utils.TargetPlatform
6
+ import utils.toTargetPlatforms
5
7
6
8
/*
7
9
* Copyright (c) 2023 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license.
@@ -10,37 +12,40 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree
10
12
// this project is used only in tests to share common code. publishing is disabled in the root build.gradle.kts
11
13
12
14
version = " 0.0.1"
15
+ val supportedPlatforms = (project.property(" test-utils.supportedTargets" ) as String ).toTargetPlatforms()
13
16
14
17
plugins {
15
18
id(" com.android.library" )
16
19
kotlin(" multiplatform" )
17
20
kotlin(" plugin.serialization" )
18
21
}
19
22
20
- android {
21
- val minSdkVersion: Int by project
22
- val compileSdkVersion: Int by project
23
+ if (supportedPlatforms.contains(TargetPlatform .Android )) {
24
+ android {
25
+ val minSdkVersion: Int by project
26
+ val compileSdkVersion: Int by project
23
27
24
- compileSdk = compileSdkVersion
25
- namespace = " dev.gitlive.firebase.testUtils"
28
+ compileSdk = compileSdkVersion
29
+ namespace = " dev.gitlive.firebase.testUtils"
26
30
27
- defaultConfig {
28
- minSdk = minSdkVersion
29
- testInstrumentationRunner = " androidx.test.runner.AndroidJUnitRunner"
30
- }
31
+ defaultConfig {
32
+ minSdk = minSdkVersion
33
+ testInstrumentationRunner = " androidx.test.runner.AndroidJUnitRunner"
34
+ }
31
35
32
- compileOptions {
33
- sourceCompatibility = JavaVersion .VERSION_17
34
- targetCompatibility = JavaVersion .VERSION_17
35
- }
36
+ compileOptions {
37
+ sourceCompatibility = JavaVersion .VERSION_17
38
+ targetCompatibility = JavaVersion .VERSION_17
39
+ }
36
40
37
- packaging {
38
- resources.pickFirsts.add(" META-INF/kotlinx-serialization-core.kotlin_module" )
39
- resources.pickFirsts.add(" META-INF/AL2.0" )
40
- resources.pickFirsts.add(" META-INF/LGPL2.1" )
41
- }
42
- lint {
43
- abortOnError = false
41
+ packaging {
42
+ resources.pickFirsts.add(" META-INF/kotlinx-serialization-core.kotlin_module" )
43
+ resources.pickFirsts.add(" META-INF/AL2.0" )
44
+ resources.pickFirsts.add(" META-INF/LGPL2.1" )
45
+ }
46
+ lint {
47
+ abortOnError = false
48
+ }
44
49
}
45
50
}
46
51
@@ -62,32 +67,40 @@ kotlin {
62
67
}
63
68
}
64
69
65
- @Suppress(" OPT_IN_USAGE" )
66
- androidTarget {
67
- instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree .test)
68
- unitTestVariant.sourceSetTree.set(KotlinSourceSetTree .test)
69
- publishAllLibraryVariants()
70
+ if (supportedPlatforms.contains(TargetPlatform .Android )) {
71
+ @Suppress(" OPT_IN_USAGE" )
72
+ androidTarget {
73
+ instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree .test)
74
+ unitTestVariant.sourceSetTree.set(KotlinSourceSetTree .test)
75
+ publishAllLibraryVariants()
76
+ }
70
77
}
71
78
72
- jvm()
73
-
74
- val supportAppleTarget = project.property( " skipAppleTargets " ) != " true "
79
+ if (supportedPlatforms.contains( TargetPlatform . Jvm )) {
80
+ jvm()
81
+ }
75
82
76
- if (supportAppleTarget ) {
83
+ if (supportedPlatforms.contains( TargetPlatform . Ios ) ) {
77
84
iosArm64()
78
85
iosX64()
79
86
iosSimulatorArm64()
87
+ }
88
+ if (supportedPlatforms.contains(TargetPlatform .Tvos )) {
80
89
tvosX64()
81
90
tvosArm64()
82
91
tvosSimulatorArm64()
92
+ }
93
+ if (supportedPlatforms.contains(TargetPlatform .Macos )) {
83
94
macosArm64()
84
95
macosX64()
85
96
}
86
97
87
- js(IR ) {
88
- useCommonJs()
89
- nodejs()
90
- browser()
98
+ if (supportedPlatforms.contains(TargetPlatform .Js )) {
99
+ js(IR ) {
100
+ useCommonJs()
101
+ nodejs()
102
+ browser()
103
+ }
91
104
}
92
105
93
106
sourceSets {
@@ -111,15 +124,19 @@ kotlin {
111
124
}
112
125
}
113
126
114
- getByName(" jsMain" ) {
115
- dependencies {
116
- implementation(kotlin(" test-js" ))
127
+ if (supportedPlatforms.contains(TargetPlatform .Js )) {
128
+ getByName(" jsMain" ) {
129
+ dependencies {
130
+ implementation(kotlin(" test-js" ))
131
+ }
117
132
}
118
133
}
119
134
120
- getByName(" jvmMain" ) {
121
- dependencies {
122
- api(libs.kotlinx.coroutines.swing)
135
+ if (supportedPlatforms.contains(TargetPlatform .Jvm )) {
136
+ getByName(" jvmMain" ) {
137
+ dependencies {
138
+ api(libs.kotlinx.coroutines.swing)
139
+ }
123
140
}
124
141
}
125
142
}
0 commit comments