1- import co.touchlab.faktory.internal.GithubCalls
2- import co.touchlab.faktory.versionmanager.GitTagBasedVersionManager
3- import co.touchlab.faktory.versionmanager.GitTagVersionManager
4- import co.touchlab.faktory.versionmanager.GithubReleaseVersionWriter
5- import co.touchlab.faktory.versionmanager.VersionManager
6- import co.touchlab.faktory.versionmanager.VersionWriter
1+ import com.codingfeline.buildkonfig.compiler.FieldSpec.Type
72import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
8- import java.util.Date
93
104plugins {
115 kotlin(" multiplatform" )
12- kotlin(" native.cocoapods" )
136 kotlin(" plugin.serialization" )
147 id(" com.android.library" )
15- id(" co.touchlab.faktory. kmmbridge" ) version " 0.3.7 "
8+ id(" co.touchlab.kmmbridge" ) version " 0.5.0 "
169 `maven- publish`
1710 id(" dev.jamiecraane.plugins.kmmresources" ) version " 1.0.0-alpha11" // Shared localization
1811 id(" io.realm.kotlin" ) version " 1.10.2"
12+ id(" com.codingfeline.buildkonfig" )
1913}
2014
21- version = " 1.0" // Shared package has only 2 digit version, patch is managed by kmmbridge.
22-
23- val sharedNamespace = " org.datepollsystems.waiterrobot.shared"
2415val generatedLocalizationRoot: String =
2516 File (project.buildDir, " generated/localizations" ).absolutePath
2617val iosFrameworkName = " shared"
2718
19+ group = project.property(" SHARED_GROUP" ) as String
20+ version = project.property(
21+ if (project.hasProperty(" AUTO_VERSION" )) " AUTO_VERSION" else " SHARED_BASE_VERSION"
22+ ) as String
23+
2824kotlin {
29- android()
25+ // For some reason androidTarget is recognized by IntelliJ,
26+ // but when building it throws "Unresolved reference: androidTarget"
27+ // -> Just keep it till it is removed
28+ android {
29+ publishAllLibraryVariants()
30+ }
3031
31- iosX64()
32- iosArm64()
33- iosSimulatorArm64()
32+ listOf (
33+ iosX64(),
34+ iosArm64(),
35+ iosSimulatorArm64()
36+ ).forEach {
37+ it.binaries.framework {
38+ // Must be set to false for shared localization (otherwise resources are not available)
39+ isStatic = false
40+ }
41+ }
3442
3543 // needed to export kotlin documentation in objective-c headers
3644 targets.withType<KotlinNativeTarget > {
@@ -120,27 +128,13 @@ kotlin {
120128 }
121129 }
122130
123- // Needed for kmmbrigde to create swift package
124- cocoapods {
125- name = iosFrameworkName
126- summary = " Shared KMM iOS-module of the WaiterRobot app"
127- homepage = " https://github.com/DatepollSystems/waiterrobot-mobile_android-shared"
128- authors = " DatepollSystems"
129- ios.deploymentTarget = " 15"
130-
131- framework {
132- // Must be set to false for shared localization (otherwise resources are not available)
133- isStatic = false
134- }
135- }
136-
137131 sourceSets.all {
138132 languageSettings.optIn(" kotlin.RequiresOptIn" )
139133 }
140134}
141135
142136android {
143- namespace = sharedNamespace
137+ namespace = group as String
144138 compileSdk = Versions .androidCompileSdk
145139 defaultConfig {
146140 minSdk = Versions .androidMinSdk
@@ -151,25 +145,28 @@ android {
151145 sourceSets[" main" ].res.srcDir(" $generatedLocalizationRoot /androidMain/res" )
152146}
153147
148+ addGithubPackagesRepository()
154149kmmbridge {
155150 mavenPublishArtifacts()
156- /* * [co.touchlab.faktory.KmmBridgeExtension.githubReleaseVersions] */
157- versionManager.set(CustomGitVersionManager (GitTagVersionManager ))
158- versionWriter.set(GithubReleaseVersionWriter (GithubCalls )) // TODO modify to support draft releases, custom title and generation of release notes (for api see https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#create-a-release)?
159151 spm()
160- versionPrefix.set(version as String )
161152}
162- addGithubPackagesRepository()
163153
164154kmmResourcesConfig {
165- androidApplicationId.set(sharedNamespace ) // appId of the shared module
166- packageName.set(" ${sharedNamespace} .generated.localization" )
155+ androidApplicationId.set(group as String ) // appId of the shared module
156+ packageName.set(" $group .generated.localization" )
167157 defaultLanguage.set(" en" )
168158 input.set(File (project.projectDir, " localization.yml" ))
169159 output.set(project.projectDir)
170160 srcFolder.set(generatedLocalizationRoot) // place the generated files in the build folder
171161}
172162
163+ buildkonfig {
164+ packageName = " $group .buildkonfig"
165+ defaultConfigs {
166+ buildConfigField(Type .STRING , " sharedVersion" , version as String , const = true )
167+ }
168+ }
169+
173170tasks {
174171 // Plutil generates the localizations for ios
175172 val plutil = named(" executePlutil" ) {
@@ -210,30 +207,6 @@ tasks {
210207 }
211208}
212209
213- /* *
214- * Adds a suffix to the version when a lava/pre release is made
215- * see [co.touchlab.faktory.versionmanager.GitTagVersionManager]
216- */
217- class CustomGitVersionManager (
218- private val manager : GitTagBasedVersionManager
219- ) : VersionManager by manager {
220- override fun getVersion (
221- project : Project ,
222- versionPrefix : String ,
223- versionWriter : VersionWriter
224- ): String {
225- val baseVersion = manager.getVersion(project, versionPrefix, versionWriter)
226-
227- // Add version suffix for dev releases
228- // e.g. main -> 1.0.1, develop -> 1.0.1-lava-1676142940
229- return when (val branch = project.property(" GITHUB_BRANCH" )) {
230- " main" -> baseVersion
231- " develop" -> " $baseVersion -lava-${Date ().toInstant().epochSecond} "
232- else -> throw IllegalStateException (" Unexpected value for property GITHUB_BRANCH: $branch " )
233- }
234- }
235- }
236-
237210detekt {
238211 source.from(
239212 " src/androidMain/kotlin" ,
0 commit comments