Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Make the Common project available for iOS from Core module #13

Merged
merged 3 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion STCore/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ plugins {
id("infomaniak.publishPlugin")
}

private val commonProject = project(":STCommon")

kotlinMultiplatformConfig {
appleExportedProjects = listOf(commonProject)
}

kotlin {
sourceSets {
commonMain.dependencies {
implementation(project(":STCommon"))
api(commonProject)
implementation(project(":STDatabase"))
implementation(project(":STNetwork"))
}
Expand Down
2 changes: 1 addition & 1 deletion STNetwork/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
kotlin {
sourceSets {
commonMain.dependencies {
api(project(":STCommon"))
implementation(project(":STCommon"))
implementation(libs.ktor.client.core)
implementation(libs.ktor.client.content.negociation)
implementation(libs.ktor.client.json)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@

package com.infomaniak.gradle.extensions

import com.infomaniak.gradle.plugins.STMultiplatformExtension
import com.infomaniak.gradle.utils.Versions
import org.gradle.api.Project
import org.gradle.kotlin.dsl.create
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework

internal fun Project.configureKotlinMultiplatform(extension: KotlinMultiplatformExtension) = extension.apply {
// Create the STMultiplatformExtension and add it to the project
val stMultiplatformExtension = extensions.create<STMultiplatformExtension>(STMultiplatformExtension.EXTENSION_NAME)

// Do not generate source code for all platforms, only for Android
withSourcesJar(publish = false)
// Targets
androidTarget {
Expand All @@ -47,6 +53,9 @@ internal fun Project.configureKotlinMultiplatform(extension: KotlinMultiplatform
it.binaries.framework {
baseName = xcframeworkName
binaryOption("bundleId", "com.infomaniak.multiplatform_swisstransfer.${xcframeworkName}")
stMultiplatformExtension.appleExportedProjects.forEach { stProject ->
export(stProject)
}
xcf.add(this)
isStatic = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ open class PublishExtension {
var mavenName: String? = null

companion object {
internal const val extensionName = "publishConfig"
internal const val EXTENSION_NAME = "publishConfig"

fun Project.publishConfig(configure: Action<PublishExtension>): Unit =
(this as ExtensionAware).extensions.configure(extensionName, configure)
(this as ExtensionAware).extensions.configure(EXTENSION_NAME, configure)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PublishPlugin : Plugin<Project> {
target.plugins.apply("maven-publish")

// Create the PublishExtension and add it to the project
val extension = target.extensions.create<PublishExtension>(PublishExtension.extensionName)
val extension = target.extensions.create<PublishExtension>(PublishExtension.EXTENSION_NAME)

target.group = "com.github.infomaniak.multiplatform_swisstransfer"
target.version = Versions.mavenVersionName
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Infomaniak SwissTransfer - Multiplatform
* Copyright (C) 2024 Infomaniak Network SA
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.infomaniak.gradle.plugins

import org.gradle.api.Action
import org.gradle.api.Project
import org.gradle.api.plugins.ExtensionAware

open class STMultiplatformExtension {
var appleExportedProjects = listOf<Project>()

companion object {
internal const val EXTENSION_NAME = "kotlinMultiplatformConfig"

fun Project.kotlinMultiplatformConfig(configure: Action<STMultiplatformExtension>): Unit =
(this as ExtensionAware).extensions.configure(EXTENSION_NAME, configure)
}
}
Loading